Home > Back-end >  How to receive other programs from a custom message
How to receive other programs from a custom message

Time:10-01

Hope application receives a vc + + Dll transfer to the message, the message declared:
UINT nReplyMsg=RegisterWindowMessage (Custom "Message");

In the Form of overloading Dispatch () function, as follows:
Void __fastcall TDemoDlg: : Dispatch (void * Message)
{
PMessage pMsg=(PMessage) Message;
If (pMsg - & gt; Msg==(unsigned int) nReplyMsg)
OnReply (pMsg - & gt; WParam, pMsg - & gt; LParam);//response message function
TForm: : Dispatch (Message);
}

Showed that DLL call has been successful, but the program can't receive from the news, can you tell me how to implement?

Written in VC receiving code for:
BEGIN_MESSAGE_MAP (CDemoDlg CDialog)
ON_BN_CLICKED (IDC_CLEAR_PREV_ASK OnClearPrevAsk)
.
ON_REGISTERED_MESSAGE (nReplyMsg OnReply)
END_MESSAGE_MAP ()
This process the message statement after compilation is able to receive, DLL is no problem,

CodePudding user response:

RegisterWindowMessage return value is not fixed, it is recommended that you declare a message constants in VC, in other applications also use the same value as the message ID

CodePudding user response:

Thank you for your advice, but not because the Dll source code, so that can't change, can only receive it according to its original definition,

CodePudding user response:

In this case, that you to reconfirm, VC in the Custom Windows Message string, and used in the c + + Builder string must be consistent, more than one space is not, is: RegisterWindowMessage (" Custom Message "); In the the Custom Message because I saw you in the post this line of code, the Custom is a blank space, in front of the screen from here first,

CodePudding user response:

Message string that's right, just can not receive the news, it is not found in the CB application RegisterWindowMessage sample () function to handle the news, no one to use?

CodePudding user response:

What a Windows API also looking for example, as long as the registration window message string is no problem to go,
I want to ask, DemoDlg window handle to the right to a DLL? This DLL how to know to which window to send a custom message?

CodePudding user response:

A window handle in FormCreate function, passed to DLL
_Init sca.//the parameters of the structure according to the definition of DLL
Memset (& amp; Sca, 0, sizeof (sca));
Sca. M_Head. M_nType=_INIT;
HWND HWND=Handle;
Sca. M_hWnd=HWND;
Sca. M_nMsg=nReplyMsg;
//DLL initialization function call
Bool f=m_Dll. SCInit (& amp; Sca, sizeof (sca));
The return value is true

Generally see are custom constants message, I am also not familiar with the API, so is fumbling


CodePudding user response:

May have to call API function GetMessage () to get the same MSG type of message, but how to use this function in CB?

CodePudding user response:

I also encountered this problem before and didn't try out of the way, finally use the other way around,

Under the Mark of LZ follow-up how to solve

CodePudding user response:

Only do CB between programs compiled application type variable custom message transmission, cross-platform didn't succeed, also prepared a detour,
  • Related