Solved

AfxMessageBox windows message

Posted on 2009-05-16
7
514 Views
Last Modified: 2013-12-27
When I pop up a message box like so:
AfxMessageBox(_T("message"));

What windows message is posted when the user presses OK?
0
Comment
Question by:Wanting2LearnMan
7 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 100 total points
ID: 24401779
None.

The code waits until the user dismisses the message box.  The message box will return a value dependig on what button was pressed (as described in the help files).
0
 
LVL 24

Assisted Solution

by:alexey_gusev
alexey_gusev earned 50 total points
ID: 24401801
to be precise, you'd get IDOK (in your particular sample), IDCANCEL, IDYES, IDNO etc, depending on the buttons you requested to display
0
 
LVL 7

Assisted Solution

by:lucky_james
lucky_james earned 100 total points
ID: 24401835
As already described by Andy, it is the value which will be returned to the caller code, rather than a message getting posted.

check out:
http://msdn.microsoft.com/ja-jp/library/cc417604.aspx

..
James
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Wanting2LearnMan
ID: 24401841
Thanks.  Would the AfxMessageBox function couse the OnActivatefunction to be called?  My problem is that I want my dialog fullscreen.  I have a tab control in my dialog and it is doing something funny as the dialog does not go fullscreen once the tabs dialogs are created.  If I put in AfxMessageBox in my OnInit then after I press OK it goes fullscreen.

BOOL CMyClass::OnInitDialog()
{
      SHINITDLGINFO shidi;
      shidi.dwMask = SHIDIM_FLAGS;
      shidi.dwFlags =SHIDIF_FULLSCREENNOMENUBAR;
      shidi.hDlg = m_hWnd;
      ::SHInitDialog(&shidi);

      SetForegroundWindow();

      SHFullScreen( m_hWnd, SHFS_HIDESTARTICON|
      SHFS_HIDETASKBAR|
      SHFS_HIDESIPBUTTON );

      MoveWindow(0,0,240,320,TRUE);

      HWND hWnd;
      hWnd = ::SHFindMenuBar(this->m_hWnd);
      ::ShowWindow(hWnd, SW_HIDE);
}

AND
void COptions::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
     CDialog::OnActivate(nState, pWndOther, bMinimized);

     SHFullScreen( m_hWnd, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|
                                                SHFS_HIDESIPBUTTON );

     MoveWindow(0,0,240,320,TRUE);

     HWND hWnd;
     hWnd = ::SHFindMenuBar(this->m_hWnd);
     ::ShowWindow(hWnd, SW_HIDE);

}

I create the dialogs for my tab control in the OnInit of my dialog like so:
//Tab Options
     dlgTab1Dlg = new CTab1(this);
     dlgTab1Dlg->Create(IDD_TAB1_DIALOG, this);
     dlgTab1Dlg->SetParent(&m_tabOptions);
     dlgTab1Dlg->ShowWindow(SW_SHOW);
     dlgTab1Dlg->SetWindowPos(NULL, rTab.left, rTab.top, rTab.Width(), rTab.Height(), SWP_NOZORDER);

     dlgTab2Dlg = new CTab2(this);
     dlgTab2Dlg->Create(IDD_TAB2_DIALOG, this);
     dlgTab2Dlg->SetParent(&m_tabOptions);
     dlgTab2Dlg->ShowWindow(SW_SHOW);
     dlgTab2Dlg->SetWindowPos(NULL, rTab.left, rTab.top, rTab.Width(), rTab.Height(), SWP_NOZORDER);
0
 

Author Comment

by:Wanting2LearnMan
ID: 24401851
The above OnInit should be:
BOOL CMyClass::OnInitDialog()
{
//Tab Options
     m_tabOptions.InsertItem(0, _T("Tab 1"));
     m_tabOptions.InsertItem(1, _T("Tab 2"));
......
.....
     dlgTab1Dlg = new CTab1(this);
     dlgTab1Dlg->Create(IDD_TAB1_DIALOG, this);
     dlgTab1Dlg->SetParent(&m_tabOptions);
     dlgTab1Dlg->ShowWindow(SW_SHOW);
     dlgTab1Dlg->SetWindowPos(NULL, rTab.left, rTab.top, rTab.Width(), rTab.Height(), SWP_NOZORDER);

     dlgTab2Dlg = new CTab2(this);
     dlgTab2Dlg->Create(IDD_TAB2_DIALOG, this);
     dlgTab2Dlg->SetParent(&m_tabOptions);
     dlgTab2Dlg->ShowWindow(SW_SHOW);
     dlgTab2Dlg->SetWindowPos(NULL, rTab.left, rTab.top, rTab.Width(), rTab.Height(), SWP_NOZORDER);


      SHINITDLGINFO shidi;
      shidi.dwMask = SHIDIM_FLAGS;
      shidi.dwFlags =SHIDIF_FULLSCREENNOMENUBAR;
      shidi.hDlg = m_hWnd;
      ::SHInitDialog(&shidi);

      SetForegroundWindow();

      SHFullScreen( m_hWnd, SHFS_HIDESTARTICON|
      SHFS_HIDETASKBAR|
      SHFS_HIDESIPBUTTON );

      MoveWindow(0,0,240,320,TRUE);

      HWND hWnd;
      hWnd = ::SHFindMenuBar(this->m_hWnd);
      ::ShowWindow(hWnd, SW_HIDE);
}

0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 100 total points
ID: 24403436
Your app probably receives an onActive after the OnInitDialog completes as part of the normal procedure.  
The dialog is initialised, OnInit leaves then the dialog is actually shown then (I assume it is a dialog based app) a WM_ACTIVATE message is pumped to the app to indicate it is now the active window.

I guess you have something else not correct in your app.


ps.  I don't think it is very good to use the OnActivate to make it full screen.  
0
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 250 total points
ID: 24405379
Yes, you will receive WM_ACTIVATE each time when your window become active or inactive. One of the parameters of this message say if it is interprocess switch or not. Please take more details from here:
http://msdn.microsoft.com/en-us/library/aa922525.aspx
there is the following text: "This handle can be NULL, and is always NULL when the window being activated and the window being deactivated are in separate processes"
I saw a problem with it on old Pocket PCs, but I hope on Windows Mobile it will work fine.
So nice to meet someone who use C++ for his mobile development and not .NET. :)
Here is a part from my handling:
UINT nFlags = LOWORD(wParam);
BOOL bMinimized = (BOOL)HIWORD(wParam);
HWND hWnd = (HWND)lParam;
And this last handle is NULL if you have switch from another thread.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now