Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Unknown type name "TMessage"


This question is answered.


Permlink Replies: 3 - Last Post: Jan 24, 2018 3:59 PM Last Post By: Remy Lebeau (Te...
Krzysztof Bzoma

Posts: 7
Registered: 2/20/18
Unknown type name "TMessage"  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 1:24 PM
I'm using (http://docwiki.embarcadero.com/RADStudio/Berlin/en/Taking_Pictures_Using_FireMonkey_Interfaces) tutorial to make working camera in Rad Studio (10.2 if thats important), i included libraries as it was said here and i still have error "unknown type name 'TMessage'" and "expected ')' to line
void __fastcall DoMessageListener(const TObject *Sender, TMessage const *M);
in .h file. If i make void __fastcall DoMessageListener(const TObject *Sender, TMessage *M); it solve 2nd error but 1st i still staying.
Can anyone help me? I read documentation of TMessage (http://docwiki.embarcadero.com/Libraries/Tokyo/en/Winapi.Messages.TMessage) but i didn't helped anyhow.

Edited by: Krzysztof Bzoma on Jan 24, 2018 1:25 PM

Edited by: Krzysztof Bzoma on Jan 24, 2018 1:48 PM

Edited by: Krzysztof Bzoma on Jan 24, 2018 2:14 PM

Edited by: Krzysztof Bzoma on Jan 24, 2018 2:18 PM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unknown type name "TMessage"  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 2:46 PM   in response to: Krzysztof Bzoma in response to: Krzysztof Bzoma
Krzysztof Bzoma wrote:
i still have error "unknown type name 'TMessage'" and "expected ')' to line
void __fastcall DoMessageListener(const TObject *Sender, TMessage const *M);
in .h file.

In Delphi, add the 'System.Messaging' unit to your 'uses' clause.

In C++, add an '#include <System.Messaging.hpp>' statement to your code.

This is clearly stated in step #1 of the tutorial that you are following.

Also, per http://docwiki.embarcadero.com/RADStudio/en/Sending_and_Receiving_Messages_Using_the_RTL:

Note: For C++ projects use TMessageBase instead of TMessage.

I read documentation of TMessage (http://docwiki.embarcadero.com/Libraries/Tokyo/en/Winapi.Messages.TMessage) but i didn't helped anyhow.

That is a different type of TMessage, related to Win32 API window messages. That is not what you are looking for in this situation. You want the TMessage that is related to the RTL's own message manager instead.

--
Remy Lebeau (TeamB)
Krzysztof Bzoma

Posts: 7
Registered: 2/20/18
Re: Unknown type name "TMessage"  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 2:57 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
In C++, add an '#include <System.Messaging.hpp>' statement to your code.

This is clearly stated in step #1 of the tutorial that you are following.

Yes, and i have all 3
#include <FMX.Platform.hpp>
#include <FMX.MediaLibrary.hpp>
#include <System.Messaging.hpp>
in my .h file.
If i'm trying to compile it on Win64 i don't get TMessage error but
[bcc64 Error] Unit1.cpp(26): Casting from non-Delphi class 'const Winapi::Messages::TMessage' to Delphi class 'const Fmx::Medialibrary::TMessageDidFinishTakingImageFromLibrary' is not allowed
for line
TMessageDidFinishTakingImageFromLibrary const *v = dynamic_cast<TMessageDidFinishTakingImageFromLibrary const *>(M);
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unknown type name "TMessage"
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2018 3:59 PM   in response to: Krzysztof Bzoma in response to: Krzysztof Bzoma
Krzysztof Bzoma wrote:

If i'm trying to compile it on Win64 i don't get TMessage error but
[bcc64 Error] Unit1.cpp(26): Casting from non-Delphi class 'const
Winapi::Messages::TMessage' to Delphi class 'const
Fmx::Medialibrary::TMessageDidFinishTakingImageFromLibrary' is not
allowed for line TMessageDidFinishTakingImageFromLibrary const *v =
dynamic_cast<TMessageDidFinishTakingImageFromLibrary const *>(M);

Again, you are using the wrong TMessage type. You need to use the one
from the System.Messaging unit, not the one from the Winapi.Messages
unit. If both definitions of TMessage are in scope in your code, you
will have to fully qualify which one you want to use, eg:

void __fastcall DoMessageListener(const TObject *Sender,
System::Messaging::TMessage const *M);


Though, like the documentation says, you should be using TMessageBase
instead of TMessage, then you wouldn't have this conflict anymore
(since Winapi::Messages::TMessage does not derive from TMessageBase):

void __fastcall DoMessageListener(const TObject *Sender, TMessageBase
const *M);


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02