PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 11, 2022

[FIXED] How to handle message send from view class to dialog?

 July 11, 2022     cview, message, mfc, sdi     No comments   

Issue

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.


Solution

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);


Answered By - Jabberwocky
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing