Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

MessageBox is hidden

reidar
Novo usuário
1.590 Visualizações

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 Respostas
Eugene_E_Intel
Funcionário
1.591 Visualizações

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
Novo colaborador III
1.591 Visualizações

Reidar,

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

Robert

 

Steve_Lionel
Colaborador honorário III
1.591 Visualizações

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
Novo usuário
1.591 Visualizações

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
Funcionário
1.591 Visualizações

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.

Responder