I use C++ Builder and I pass messages to window which are handled in WndProc
to update user interface. Something like:
struct TWmGuiUpdatedStruct
{
int id1;
int id2;
};
TWmGuiUpdatedStruct gui { 1, 2 };
TMessage msg;
msg.Message = WM_MY_GUI_UPDATED;
msg.WParam = WM_MY_GUI_UPDATED_MESSAGE_LIST;
msg.LParam = reinterpret_cast<NativeInt>(&guiparam);
// send to all forms in a loop
for (int i = 0; i < Screen->FormCount; i++) Screen->Forms[i]->Perform(msg.Message, msg.WParam, msg.LParam);
// in WndProc
if (fMessage.Msg == WM_MY_GUI_UPDATED && msg.WParam == WM_MY_GUI_UPDATED_MESSAGE_LIST)
{
TWmGuiUpdatedStruct* gui = reinterpret_cast<TWmGuiUpdatedStruct*>(fMessage.LParam);
// use gui->id1 and guid->id2 here...
fMessage.Result = 0;
return;
}
TForm::WndProc(fMessage);
I find it over-complicated to initialize all in so many lines.
I need something simpler, like:
TMessage msg { WM_MY_GUI_UPDATED, {WM_MY_GUI_UPDATED_MESSAGE_LIST, reinterpret_cast<NativeInt>(&guiparam), 0} };
But it doesn't compile - it wants System::Word
instead.
Is there a simpler way to initialize this to pass such GUI update messages?