Solved

AfxMessageBox windows message

Posted on 2009-05-16
7
520 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pre4 challenge 19 100
scoreUp challenge 14 62
Making an alias 7 95
c++, dynamic object by json 1 42
If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

770 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