🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by Gerald O'Brien Mon, 07 Apr 2003 16:42
Mapping to user-defined Windows Message
#17146
Author: Gerald O'Brien
Date: Mon, 07 Apr 2003 16:42
30 lines
2010 bytes
I have defined a RegisteredWindowsMessage like this:

static const UINT UWM_U_R_ME = 
::RegisterWindowMessage("UWM_U_R_ME-5B76225D-E886-4ce1-BE1F-A983F759EC8A");

Now I need to map the message in the application that is to receive it.

The Help File example looks like this:

#define CM_CHANGECOLOR (WM_APP + 400)
...
BEGIN_MESSAGE_MAP
   MESSAGE_HANDLER(CM_CHANGECOLOR, TMessage, CMChangeColor)
END_MESSAGE_MAP(TControl)

but that is for a constant message not a Registered Windows Message.

The mapping line in the example I have been reading looks like this:

ON_REGISTERED_MESSAGE(UWM_U_R_ME, OnURMe)

but that causes a compiler error in BCB 4.0, undefined funtion. Can 
anybody tell me how to map correctly a Registered Windows Message?

The full problem is to keep the instances of an MDI application to one 
but still open as new child windows any files that may be clicked on by 
the user. If anyone knows the source of any example of this, then that 
would be much appreciated.

As always, all suggestions gratefully received.
Re: Mapping to user-defined Windows Message
#17147
Author: Michel Leunen
Date: Mon, 07 Apr 2003 16:57
25 lines
1712 bytes
Gerald O'Brien wrote:
> I have defined a RegisteredWindowsMessage like this:
> 
> static const UINT UWM_U_R_ME = 
> ::RegisterWindowMessage("UWM_U_R_ME-5B76225D-E886-4ce1-BE1F-A983F759EC8A");

You have to override the Form's WndProc(). Don't use a message map:

void __fastcall TForm1::WndProc(TMessage &Message)
{
   if(Message.Msg == UWM_U_R_ME)
   {
     // Your code here
     Message.Result=true;
   }
   else  TForm::Dispatch(&Message);
}

Michel
-- 
----------------------------------------
Michel Leunen
mailto:michel@leunen.com
http://www.leunen.com/cbuilder/
----------------------------------------
Re: Mapping to user-defined Windows Message
#17148
Author: Remy Lebeau (TeamB)
Date: Mon, 07 Apr 2003 17:11
20 lines
1549 bytes
"Gerald O'Brien" <gob@the-ideas-organiser.com> wrote in message
news:3e91aa4b$1@newsgroups.borland.com...

> BEGIN_MESSAGE_MAP
>    MESSAGE_HANDLER(CM_CHANGECOLOR, TMessage, CMChangeColor)
> END_MESSAGE_MAP(TControl)
>
> but that is for a constant message not a Registered Windows Message.

Correct.  You can't use a MESSAGE_MAP with a dynamic message value obtained
at runtime, the value has to be known at compile-time.

> Can anybody tell me how to map correctly a Registered Windows Message?

You need to override the receiving form's WndProc() method and catch the
message there instead.


Gambit
Re: Mapping to user-defined Windows Message
#17161
Author: Gerald O'Brien
Date: Tue, 08 Apr 2003 01:23
5 lines
1223 bytes
> You need to override the receiving form's WndProc() method and catch the
> message there instead.
> 
Thanks guys, that did the trick.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads