- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm using DVF 6.0 and i've build a Fortran windows application (although i don't use Win32 API functions). The application opens a dialog box at startup. After this, it is possible to open a second dialog box by clicking on a control button in the dialog box. Now i want to switch between the first and second dialog box with the help of the mouse. When i click on the first dialog box, this box becomes active but the second dialog box remains to the foreground, not the first dialog box. So, if the boxes overlap, i can't work with the first dialog box anymore.
Does anyone know what i've done wrong? Below, a simplified version of my code is listed.
I'm using DVF 6.0 and i've build a Fortran windows application (although i don't use Win32 API functions). The application opens a dialog box at startup. After this, it is possible to open a second dialog box by clicking on a control button in the dialog box. Now i want to switch between the first and second dialog box with the help of the mouse. When i click on the first dialog box, this box becomes active but the second dialog box remains to the foreground, not the first dialog box. So, if the boxes overlap, i can't work with the first dialog box anymore.
Does anyone know what i've done wrong? Below, a simplified version of my code is listed.
integer(4) function ShowDialog(iM1,iM2,iM3,iM4) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: ShowDialog !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinMain' :: ShowDialog !DEC$ ENDIF use dfwin use dflogm implicit none integer(4) iM1,iM2,iM3,iM4 include "resource.fd" type (dialog) dFirst external eCallback integer(4) iRet logical lRet lRet = dlginit(idd_dialog1,dFirst) lRet = dlgsetsub(dFirst,idc_button,eCallback,dlg_clicked) iRet = dlgmodal(dFirst) ShowDialog = 0 end function ShowDialog Subroutine eCallback(dFirst,iID,iCallbacktype) use dflogm implicit none include "resource.fd" ! global type (dialog) dFirst integer(4) iID,iCallbacktype ! local type (dialog) dSecond logical lRet lRet = dlginit(idd_dialog2,dSecond) lRet = dlgmodeless(dSecond) end Subroutine eCallback
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bruce,
I am afraid I have no solution for you - if indeed one exists.
However I do know that you can't use dlgmodeless in a QuickWin application
(lRet = dlgmodeless(dSecond))
Lars
I am afraid I have no solution for you - if indeed one exists.
However I do know that you can't use dlgmodeless in a QuickWin application
(lRet = dlgmodeless(dSecond))
Lars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By default, if you don't specify dialog's parent (owner) window in call to DlgModeless, the existing dialog is taken as parent, causing it to always lie underneath the modeless dialog. There's an optional argument to DlgModeless where you can specify the parent window -- if you specify 0, desktop is the parent. Try:
HTH
Jugoslav
lRet = DlgModeless(dSecond, hwndParent=0)
HTH
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav,
When i implement the code lRet = DlgModeless(dSecond, hwndParent=0), not the desktop becomes the parent window, but the second dialog box.
What goes wrong?
Bruce
When i implement the code lRet = DlgModeless(dSecond, hwndParent=0), not the desktop becomes the parent window, but the second dialog box.
What goes wrong?
Bruce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I pasted your code in a simple workspace with addition of hwndParent=0 and it seems to work, in the sense that you can freely switch between two dialogs using the mouse and the second does not always overlap the first. It's not 100% clear to me what you want to obtain: if you want that dFirst keeps the focus after clicking the idc_button, just add the following line at the end of eCallback:
Also, you can play with window-positioning functions. The following piece of code in eCallback will move dSecond so that it appears next to the right border of dFirst:
HTH
Jugoslav
use dfwin ... iSt = SetFocus(dFirst%hWnd)
Also, you can play with window-positioning functions. The following piece of code in eCallback will move dSecond so that it appears next to the right border of dFirst:
type (t_rect) rect ... lRet = dlgmodeless(dSecond) ... lRet = GetWindowRect(dFirst%hWnd,Rect) lRet = SetWindowPos(dSecond%hWnd,0,Rect%Right,Rect%Top,0,0,SWP_NOZORDER.OR.SWP_NOSIZE)
HTH
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav,
The problem seems to be partly solved: When I add hwndParent=0 in my original code (not the simplified version at the Fortran Forum site), everything works OK.
I don't understand though why it doesn't work with the simplified version.
But never mind, my program is fixed so I can move on. Thanks !!!
Bruce
The problem seems to be partly solved: When I add hwndParent=0 in my original code (not the simplified version at the Fortran Forum site), everything works OK.
I don't understand though why it doesn't work with the simplified version.
But never mind, my program is fixed so I can move on. Thanks !!!
Bruce

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page