Can I make this dialog non-modal?

Just starting out? Need help? Post your questions and find answers here.
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Can I make this dialog non-modal?

Post by firace »

To the API wizards :)

In the below example, the Properties dialog (that pops up when the Show properties button is clicked) is modal. How could I make it non-modal?

Code: Select all

OpenWindow(0, 100, 100, 440, 380, "", #PB_Window_SizeGadget |#PB_Window_SystemMenu)


ButtonGadget(1,60,60,200,30,"Show properties...")
TextGadget(12, 20, 20, 200, 20, "TEST")
WebGadget(3,40, 120, 300, 200, "https://www.bing.com/")

webBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(3), #GWL_USERDATA)

Repeat
  Select WaitWindowEvent()
      
      
    Case #PB_Event_Gadget
      if EventGadget() = 1 : 
        WebBrowser\ExecWB(  10, 1, 0, 0) 
        
      endif 
      
    Case #PB_Event_SizeWindow : beep_(4242,232) : 
      ResizeGadget(12,WindowWidth(0) - 100, 50, 200,20)
      ResizeGadget(3, 40, 120, WindowWidth(0) - 60, 200)
      
    Case #PB_Event_CloseWindow : End
  EndSelect
ForEver

firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Can I make this dialog non-modal?

Post by firace »

Still struggling with this one. Any ideas welcome :)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Can I make this dialog non-modal?

Post by RASHAD »

Hi firace
Semi modal :)
The rest is yours
Maybe you can use MDIGadget() to have the whale objects in one plan or use Windows Callback

Code: Select all

Procedure IsMouseOver(hWnd)
  GetWindowRect_(hWnd,r.RECT)
  GetCursorPos_(p.POINT)
  Result = PtInRect_(r,p\y << 32 + p\x)
  ProcedureReturn Result
EndProcedure

OpenWindow(0, 0, 0, 400, 400, "", #PB_Window_ScreenCentered |#PB_Window_SystemMenu)
ButtonGadget(1,10,350,100,30,"Show properties...")
OpenWindow(1, WindowX(0)+400, WindowY(0)+50, 340, 280, "", #PB_Window_BorderLess | #WS_SIZEBOX,WindowID(0))
TextGadget(12, 10, 20, 200, 20, "TEST")
WebGadget(3,10, 45, 300, 200, "https://www.bing.com/")
webBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(3), #GWL_USERDATA)
webBrowser\put_Silent(1)

Repeat
  Select WaitWindowEvent()     
     
    Case #PB_Event_Gadget
      If EventGadget() = 1
        WebBrowser\ExecWB(  10, 1, 0, 0)       
      EndIf
     
    Case #PB_Event_SizeWindow : Beep_(4242,232) :
      ResizeGadget(12,#PB_Ignore,#PB_Ignore, 200,20)
      ResizeGadget(3, #PB_Ignore,#PB_Ignore, WindowWidth(1) - 20, WindowHeight(1) - 50)
     
    Case #WM_LBUTTONDOWN
      If IsMouseOver(WindowID(1))
        SetCursor_(LoadCursor_(0, #IDC_HAND))
        SendMessage_(WindowID(1), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
      EndIf
     
    Case #PB_Event_CloseWindow : End
  EndSelect
ForEver
Egypt my love
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Can I make this dialog non-modal?

Post by firace »

Thanks Rashad, will give it a try :)
Post Reply