Code:
' F4 problem solved by using SetWindowPos to place the ' dialogs in the correct z-relationship - Thank you Colin Glenn! ' ' 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_user + 400 hMain = cb.wparam enablewindow hMain, %false case %wm_destroy enablewindow hMain, %true BringWindowToTop(hMain) setfocus (hMain) case %wm_ncactivate if cb.wparam = %false then exit select ' we are losing focus enablewindow hMain, %true setwindowpos(hMain, cb.hndl, 0, 0, 0, 0, %SWP_NOACTIVATE or %SWP_NOMOVE or %SWP_NOSIZE) 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_syscommand if IsWindow(hpopup) then msgbox "We are here" dialog end hpopup function=1 end if case %wm_command if cb.ctl = 1001 then if iswindow(hpopup) 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 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
Leave a comment: