🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #684

Re: How to use traditional Windows message and API function ?

#684
From: Luka Gabri�
Date: Sat, 23 Feb 2008 00:06
71 lines
3324 bytes
This code seems to be working, but I still need to do some testing!

Message receiving code:

// application header

 MESSAGE void __fastcall func_name(TMessage &Message);
 BEGIN_MESSAGE_MAP
  VCL_MESSAGE_HANDLER(xxxx,TMessage,func_name); //xxxx - message identifier, 
 > 1024
  END_MESSAGE_MAP(TForm);

//  application cpp file

MESSAGE void __fastcall TFormX::func_name(TMessage &Message)
{
 ShowMessage("Message received, parameter1 = " + IntToStr(Message.LParam) + 
", parameter2 = " + IntToStr(Message.WParam));
}

Code to send a message

SendMessageA(hinst,xxxx,5,7);

//hinst - app form handle, xxxx - message identifier (same as in main 
application), parameter1=5, parameter2=7.


> I would like my DLL to comunicate with my application in any way. Windows
> message api function seems like a good idea. This is the code for 
> receiving
> a message on date time change. When the message on date time change is
> received, an event (or function) is triggered. I would like to "trigger" a
> handler function in my application from my DLL, and pass some parameters 
> if
> possible.
>
> Something like this should be in my application (this works for date/time
> change i would like a handler for messages from another application, not
> date/time)!
>
> class TMyForm : public TForm
> {
> private:
>    // declare a handler function for your message
>    MESSAGE void __fastcall WM_TimeChange(TMessage &Message);
>
> BEGIN_MESSAGE_MAP
>    // associate your handler function with some message
>    VCL_MESSAGE_HANDLER(WM_TIMECHANGE,              TMessage,
> WM_TimeChange);
> END_MESSAGE_MAP(TForm);
> };
>
> // in your source file
> // define the handler function
> MESSAGE void __fastcall TMyForm::WM_TimeChange(TMessage &Message)
> {
>    ShowMessage("Date or time has been changed!");
> }
>
> Now I need the code to send a meessage from DLL (or another application) 
> to
> my application. (I think it's the PostMessage method, but I'm not sure)!
>
> I hope this clears what I want the code for.
>
> Thanks,
> Luka.
>
> 
Technical Details
Message-ID: <47bf6340$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!194.134.4.77.MISMATCH!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <47b02ecf$1@newsgroups.borland.com> <MPG.221a525c60a3d10c989a5f@newsgroups.borland.com> <47b0d385$1@newsgroups.borland.com> <47b0d5c9$1@newsgroups.borland.com> <47be2fa2$1@newsgroups.borland.com> <47be52e0$1@newsgroups.borland.com> <47bf296d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,985e142ee2266c4
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Luka Gabri�" <luka.gabric@gmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <47b02ecf$1@newsgroups.borland.com> <MPG.221a525c60a3d10c989a5f@newsgroups.borland.com> <47b0d385$1@newsgroups.borland.com> <47b0d5c9$1@newsgroups.borland.com> <47be2fa2$1@newsgroups.borland.com> <47be52e0$1@newsgroups.borland.com> <47bf296d@newsgroups.borland.com>
Subject: Re: How to use traditional Windows message and API function ?
Date: Sat, 23 Feb 2008 01:06:45 +0100
Lines: 73
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 89.201.143.116
Message-ID: <47bf6340$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1203725120 89.201.143.116 (22 Feb 2008 16:05:20 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!194.134.4.77.MISMATCH!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail