Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

MessageBox is hidden

reidar
New User
188 Views

In a win 32 program I use the MessageBox function to pass information the user. For example:

iret = MessageBox(NULL,'File saved '//""C,'TVA'//" "C,MB_OK)

I apply the function from subroutines and from call-back functions.

Some times it show up in the foreground as intended but in most cases the massage box is hidden behind the application's main window.

Can somebody give me a hint ?

Regards, Reidar

 

0 Kudos
5 Replies
Eugene_E_Intel
Employee
188 Views

Hello,

If the first parameter to MessageBox() is NULL, then the message box window has no owner window and can really appear anywhere.  (See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-messagebox ).  In order for the message box to appear in front of a particular window, you need to pass that window's handle as the first parameter of MessageBox() function.

Robert_van_Amerongen
New Contributor III
188 Views

Reidar,

Try to use the result of a call to GetDesktopWindow as the first argument of the MessageBox call.

Robert

 

Steve_Lionel
Black Belt Retired Employee
188 Views

That could still leave the box hidden. Ideally you want the handle of the current window (or the topmost window). GetTopWindow() will do that.

reidar
New User
188 Views

I arranged the code as shown below, in most cases it works.  I am questioning my use of hwnd in the call to SendMessage, see below.

    case (WM_CLOSE)
!  Free the INFO data that associates with this 
!  window also, reset the menu.    
      hclose=GetTopWindow(hWnd)
      iret = messagebox(hclose,'OK to close the file?'//""C, &                     
!      iret = messagebox(GetDesktopWindow(),'OK to close the file?'//""C, &        ! Does not work
                   'TVA'//""C, MB_ICONQUESTION.OR. &
                   MB_OKCANCEL)
			if(iret == IDCANCEL) then
			   MDIWndProc = 0
               return
            else
               iret = SendMessage(GetParent(hwnd), &        ! should be hClose rather than hwnd ?
                   WM_MDISETMENU,ghMenu,ghMenuWindow)                                       
               iret = DrawMenuBar(GetParent(GetParent(hwnd))) 
               hInfo = GetWindowLong(hClose, 0)
               iret = LocalFree(hInfo)
			end if

 

Eugene_E_Intel
Employee
188 Views

reidar wrote:

I arranged the code as shown below, in most cases it works.  I am questioning my use of hwnd in the call to SendMessage, see below.

WM_MDISETMENU must be sent to the MDI window with a menu.  Not knowing, how your windows are structured and their child-parent relationships, it's hard to give advice.

I recommend that when you originally create MDI window, you save its handle somewhere and then use that handle to send WM_MDISETMENU message.

Reply