I have SDI application that hand view, doc and mainframe. In view class, I have button to open another dialog, let say Chartering dialog. I would like to open that dialog and send initial value from view to assign some variable at dialog, but I can not catch message event at dialog class. Below as my code:
// button onclick to show new dialog
charteringDlg = new CharteringDlg();
// show chartering dialog
if(charteringDlg->Create(IDD_DIALOG_CHATTERING, GetDesktopWindow()))
{
bChartering = true;
charteringDlg->MoveWindow(900,300,450,300);
charteringDlg->ShowWindow(SW_SHOW);
int temp = 12;
GetMain()->SendMessage(UWM_MYMESSAGE_CHARTERING, 0,(LPARAM)&temp);
}
and in chartering dialog I handle message like below
ON_MESSAGE(UWM_MYMESSAGE_CHARTERING, &CharteringDlg::OnSetShowTemp)
chartering function
LRESULT CharteringDlg::OnSetShowTemp(WPARAM, LPARAM lParam)
{
int * s = (int *)lParam;
return 0;
}
I set break point at OnSetShowTemp() function but it cannot jump there. Any idea would be great appreciated.
For assigning an initial value to one of your dialog's members you don't need to send it a message.
You can just assign the value directly:
So instead of
GetMain()->SendMessage(UWM_MYMESSAGE_CHARTERING, 0,(LPARAM)&temp);
you should have something like:
charteringDlg->thevalueorwhatever = 12;
And BTW:
GetMain()->SendMessage(UWM_MYMESSAGE_CHARTERING, 0,(LPARAM)&temp);
is wrong anyway, you should send the message to the dialog and not to the main window:
charteringDlg->SendMessage(UWM_MYMESSAGE_CHARTERING, 0,(LPARAM)&temp);