Attempting to preserve the z-relationship between two dialogs, so that the popup one always appears to overlay the other.
Although this arrangement works, pressing F4 after task-switching closes the wrong dialog - ie, not the top one!
Would someone care to spot my mistake?
Although this arrangement works, pressing F4 after task-switching closes the wrong dialog - ie, not the top one!
Would someone care to spot my mistake?
Code:
' F4 problem ' in this example, after task-switching away from ' then back to the "popup" dialog, F4 appears to close the "wrong" ' dialog - i.e., not the top one. ' Possibly a consequence of using BringWindowtoTop, ' which is used to preserve the z-relationship between ' the "main" and "popup" dialogs, but how to correct it? ' ' Chris Holbrook 21st Jan 2009 ' #compile exe #dim all #include "win32api.inc" '------------------------------------------------------------------ callback function CBPopup static hMain as dword local n as long select case as long cb.msg case %wm_initdialog 'BringWindowToTop(hMain) case %wm_user + 400 hMain = cb.wparam enablewindow hMain, %false case %wm_destroy enablewindow hMain, %true BringWindowToTop(hMain) setfocus (hMain) case %wm_syscommand 'n = cb.wparam and &HFFF0 'dialog set text cb.hndl, "sys " + hex$(n) 'sleep 500 case %wm_ncactivate 'dialog set text cb.hndl, "NCA " + hex$(cb.wparam) 'sleep 500 if cb.wparam = %false then exit select ' we are losing focus enablewindow hMain, %true BringWindowToTop(hMain) enablewindow hMain, %false setfocus (cb.hndl) end select end function '------------------------------------------------------------------ callback function CB1 static hpopup, hDmain as dword local lresult, W, H as long select case as long cb.msg case %wm_command if cb.ctl = 1001 then if hpopup <> 0 then exit select ' child window already exists dialog new 0, "popup", 110, 110, 80, 80, _ %ws_popup or %ws_caption, %ws_ex_topmost to hpopup dialog show modeless hpopup call CBpopup to lresult dialog send hpopup, %wm_user + 400, cb.hndl, 0 do dialog doevents dialog get size hpopup to H, W loop while H hPopup = 0 end if end select end function '------------------------------------------------------------------ function pbmain () as long local lresult as long local hdlg as long dialog new 0, "main", 100, 100, 100, 100, _ %ws_visible or %ws_popup or %ws_caption, to hDlg control add label, hDlg, 1001, "click here for popup dialog", 5, 90, 90, 15, %ss_notify control set color hDlg, 1001, %white, %gray dialog show modal hDlg call CB1 to lresult end function
Comment