Link to home
Start Free TrialLog in
Avatar of huochai
huochai

asked on

How to display a message once the buttom is pressed>>??

Hi all,
       How to display message once a button is pressed>>?/
       Let says i want to display the message "hello" once the button "Click Me" is pressed>> ??
       Hope someone can help me..
       I not using MFC...
Thanks in advance
huochai
Avatar of frogger1999
frogger1999

Assuming that you know when the button is clicked you could just do this:

int MessageBox(
  NULL,          // handle of owner window
  "Hello",     // address of text in message box
  "Hello box",  // address of title of message box
  MB_OK          // style of message box
);


there are lots of other settings you can use like changing the window style to modal, putting in a standard system icon etc.

Just look up MessageBox on MSDN
ASKER CERTIFIED SOLUTION
Avatar of gotenks
gotenks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A slight corrections to gotenks' code.  BN_CLICKED will show up in the HIWORD of wParam, not the loword.  So if all you care about is clicks, you'd do:

case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
              MessageBox(hwnd, "Hello", "Hello Message", MB_OK);
        }


To make sure the correct button was clicked:
case WM_COMMAND:
     switch(HIWORD(wParam))
     {
          case BN_CLICKED:
               switch(LOWORD(wParam))
               {
                    case IDC_MYBUTTON:
                         DoStuff();
                         break;
               }
               break;
     }

and so forth...

-Tele
sorry, and thanks for the correction, Tele.

gotenks
Nothing has happened on this question in more than 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by gotenks.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer