Issue with WebGadget Find dialog being modal

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

Issue with WebGadget Find dialog being modal

Post by firace »

After much testing I have found that the #PB_Web_BlockPopupMenu attribute causes the WebGadget Find dialog to become modal (ie steal focus from the Webgadget). As such it makes it impossible to scroll the web page while the Find dialog is open (while this works fine when #PB_Web_BlockPopupMenu is not used). Any ideas / workarounds to fix this please?

Code: Select all

WebObject.IWebBrowser2


#WebGadget = 0
#FindButton = 1

#OLECMDID_FIND = 32
#OLECMDEXECOPT_DODEFAULT = 0

#URL1 = "https://lite.cnn.io"

OpenWindow(0, 0, 0, 800, 620, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
WebGadget(#WebGadget, 10, 10, 780, 550, #URL1) 
ButtonGadget(#FindButton, 400, 564, 80, 32, "Find")

SetGadgetAttribute(GadgetNumber,#PB_Web_BlockPopupMenu,#True)   ;;;;   try commenting this line then test the Find dialog again

WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(0), #GWL_USERDATA)

Repeat
  e = WaitWindowEvent() 
  
  select e
    Case #PB_Event_Gadget
      GadgetNumber = EventGadget() 
      
      select GadgetNumber
        Case #FindButton
          WebObject\ExecWB(#OLECMDID_FIND, #OLECMDEXECOPT_DODEFAULT, 0, 0)
          
      EndSelect
  EndSelect
  
Until e = #PB_Event_CloseWindow 
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Issue with WebGadget Find dialog being modal

Post by RASHAD »

Hi firace
Using local hook (no problems)

Code: Select all

WebObject.IWebBrowser2

Global hhook

#WebGadget = 0
#FindButton = 1

#OLECMDID_FIND = 32
#OLECMDEXECOPT_DODEFAULT = 0

#URL1 = "https://lite.cnn.io"

Procedure MouseProc(nCode, wParam, lParam)
  If wParam = #WM_RBUTTONDOWN Or wParam = #WM_RBUTTONUP
    ProcedureReturn 1
  EndIf
  ProcedureReturn result
EndProcedure

OpenWindow(0, 0, 0, 800, 620, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(#WebGadget, 10, 10, 780, 550, #URL1)
ButtonGadget(#FindButton, 400, 564, 80, 32, "Find")

;SetGadgetAttribute(GadgetNumber,#PB_Web_BlockPopupMenu,#True)   ;;;;   try commenting this line then test the Find dialog again

WebObject.IWebBrowser2 = GetWindowLongPtr_(GadgetID(0), #GWL_USERDATA)
WebObject\put_Silent(#True)
lpdwProcessId = GetWindowThreadProcessId_(WindowID(0), 0)
hhook = SetWindowsHookEx_(#WH_MOUSE, @MouseProc(),GetModuleHandle_(0), lpdwProcessId)
Repeat
  e = WaitWindowEvent()
 
  Select e
    Case #PB_Event_CloseWindow
      UnhookWindowsHookEx_(hhook)
      Quit = 1
      
    Case #PB_Event_Gadget
      GadgetNumber = EventGadget()
;      
      Select GadgetNumber
        Case #FindButton
          WebObject\ExecWB(#OLECMDID_FIND, #OLECMDEXECOPT_DODEFAULT, 0, 0)
         
     EndSelect
  EndSelect
 
Until Quit = 1
UnhookWindowsHookEx_(hhook)
Egypt my love
firace
Addict
Addict
Posts: 903
Joined: Wed Nov 09, 2011 8:58 am

Re: Issue with WebGadget Find dialog being modal

Post by firace »

Clever! Thanks Rashad!
Post Reply