WebGadget without native IE Shortcuts like CTRL+N, CTRL+O...

Just starting out? Need help? Post your questions and find answers here.
User avatar
cabaptista
User
User
Posts: 86
Joined: Sun Nov 30, 2003 11:42 pm
Location: Lisboa, Portugal

WebGadget without native IE Shortcuts like CTRL+N, CTRL+O...

Post by cabaptista »

Hi everyone,

I have a little problem which i need your help.
The problem is: When i use a webgadget in a window and press the CTRL+N for example the purebasic application opens a new IE window browser behind.
How can i disable that? My version of Purebasic is 5.60 (x86 and x64, i tested both) and windows 10.

Here is a sample code for you to test

Code: Select all

If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")
    RemoveKeyboardShortcut(0, #PB_Shortcut_All)
    
    ; Note: if you want to use a local file, change last parameter to "file://" + path + filename
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Thanks in Advance,
César
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by JHPJHP »

Hi cabaptista,

Here are a couple solutions, each one with its own drawback.
- JavaScript: works for most keys, but not CTRL+O
- API Hook: Windows Only, but could be adapted for all OS

JavaScript:
- currently set for all CTRL key combinations and F5

Code: Select all

Enumeration
  #MainWindow
  #WebGadget
EndEnumeration

HTML.s = "<html>" + #LF$ +
         #TAB$ + "<head>" + #LF$ +
         #TAB$ + #TAB$ + "<script language='JavaScript'>" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + "function init() {" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + "if (document.addEventListener) {" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + "document.addEventListener('keydown', keydown, false);" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + "}" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + "}" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + "function keydown(e) {" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + "switch (true) {" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + "case (e.ctrlKey || e.keyCode == 116):" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + "e.preventDefault();" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + "e.stopPropagation();" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + "break;" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + #TAB$ + "}" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + "}" + #LF$ +
         #TAB$ + #TAB$ + "</script>" + #LF$ +
         #TAB$ + "</head>" + #LF$ +
         #TAB$ + "<body>" + #LF$ +
         #TAB$ + #TAB$ + "<h1>JHPJHP</h1>" + #LF$ +
         #TAB$ + #TAB$ + "<script language='JavaScript'>" + #LF$ +
         #TAB$ + #TAB$ + #TAB$ + "init();" + #LF$ +
         #TAB$ + #TAB$ + "</script>" + #LF$ +
         #TAB$ + "</body>" + #LF$ +
         "</html>"
lpValueName.s = GetFilePart(ProgramFilename()) : lpData = 11001

If RegCreateKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #Null, #REG_OPTION_VOLATILE, #KEY_ALL_ACCESS, #Null, @phkResult, @lpdwDisposition) = #ERROR_SUCCESS
  RegSetValueEx_(phkResult, lpValueName, 0, #REG_DWORD, @lpData, SizeOf(LONG))
  RegCloseKey_(phkResult)

  If OpenWindow(#MainWindow, 0, 0, 600, 400, "WebGadget: Animated GIF", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    WebGadget(#WebGadget, 0, 0, 600, 400, #Null$)
    SetGadgetAttribute(#WebGadget, #PB_Web_BlockPopupMenu, #True)
    SetGadgetAttribute(#WebGadget, #PB_Web_BlockPopups, #True)
    WebBrowser2.IWebBrowser2 = GetWindowLongPtr_(GadgetID(#WebGadget), #GWL_USERDATA)
    WebBrowser2\put_Silent(#True)
    SetGadgetItemText(#WebGadget, #PB_Web_HtmlCode, HTML)
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

  If RegOpenKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #KEY_SET_VALUE, @phkResult) = #ERROR_SUCCESS
    RegDeleteValue_(phkResult, lpValueName)
    RegCloseKey_(phkResult)
  EndIf
Else
  MessageRequester("Embed JS: AS3 - Webcam", "Registry update failed." + #LF$ + #LF$ + "Operation cancelled.", #MB_ICONERROR)
EndIf
API Hook:
- currently set for all CTRL key combinations and F5

Code: Select all

Enumeration
  #MainWindow
  #WebGadget
EndEnumeration

Procedure KeyboardHook(nCode, wParam, *kc.KBDLLHOOKSTRUCT)
  Shared HHOOK

  If nCode = #HC_ACTION
    KeyCode = *kc\vkCode

    Select KeyCode
      Case #VK_LCONTROL, #VK_RCONTROL, #VK_F5
        Select wParam
          Case #WM_KEYDOWN
            Select GetActiveGadget()
              Case #WebGadget : ProcedureReturn 1
            EndSelect
        EndSelect
    EndSelect
  EndIf
  ProcedureReturn CallNextHookEx_(HHOOK, nCode, wParam, *kc)
EndProcedure

If OpenWindow(#MainWindow, 0, 0, 600, 400, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  HHOOK = SetWindowsHookEx_(#WH_KEYBOARD_LL, @KeyboardHook(), #Null, 0)
  WebGadget(#WebGadget, 0, 0, 600, 400, "http://www.purebasic.com")
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  UnhookWindowsHookEx_(HHOOK)
EndIf
User avatar
cabaptista
User
User
Posts: 86
Joined: Sun Nov 30, 2003 11:42 pm
Location: Lisboa, Portugal

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by cabaptista »

JHPJHP,

The API Hook worked. That was i'm looking for. :D

Thanks.
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by firace »

JHPJHP wrote:API Hook:
- currently set for all CTRL key combinations and F5

Code: Select all

Enumeration
  #MainWindow
  #WebGadget
EndEnumeration

Procedure KeyboardHook(nCode, wParam, *kc.KBDLLHOOKSTRUCT)
  Shared HHOOK

  If nCode = #HC_ACTION
    KeyCode = *kc\vkCode

    Select KeyCode
      Case #VK_LCONTROL, #VK_RCONTROL, #VK_F5
        Select wParam
          Case #WM_KEYDOWN
            Select GetActiveGadget()
              Case #WebGadget : ProcedureReturn 1
            EndSelect
        EndSelect
    EndSelect
  EndIf
  ProcedureReturn CallNextHookEx_(HHOOK, nCode, wParam, *kc)
EndProcedure

If OpenWindow(#MainWindow, 0, 0, 600, 400, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  HHOOK = SetWindowsHookEx_(#WH_KEYBOARD_LL, @KeyboardHook(), #Null, 0)
  WebGadget(#WebGadget, 0, 0, 600, 400, "http://www.purebasic.com")
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  UnhookWindowsHookEx_(HHOOK)
EndIf
For the API hook method, is there any way to disable CTRL+O but not CTRL+C ?
breeze4me
Enthusiast
Enthusiast
Posts: 511
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by breeze4me »

Another way.

http://forums.purebasic.com/english/vie ... 12&t=42444

Code: Select all

Structure _IDocHostUIHandler
  *vTable
  ref.i
  iDocHostUiHandler.iDocHostUiHandler
EndStructure

;/////////////////////////////////////////////////////////////////////////////////
;Return a HRESULT value (#S_OK if successful).
Procedure.i SetCustomDocHostUIHandler(id, vTableAddress)
  Protected result=#E_FAIL, hWnd, iBrowser.IWebBrowser2, iDispatch.IDispatch, iDocument.IHTMLDocument2, iOLE.IOleObject, iDocHostUIHandler.IDocHostUIHandler
  Protected iCustomDoc.ICustomDoc, iOLEClientSite.IOleClientSite, *this._IDocHostUIHandler
  hWnd = GadgetID(id)
  If hWnd
    iBrowser = GetWindowLong_(hWnd, #GWL_USERDATA)
    If iBrowser
      If iBrowser\get_Document(@iDispatch) = #S_OK
        If iDispatch\QueryInterface(?IID_IHTMLDocument2, @iDocument) = #S_OK
          If iDocument\QueryInterface(?IID_IOleObject, @iOLE) = #S_OK
            If iOLE\GetClientSite(@iOLEClientSite) = #S_OK
              If iOLEClientSite\QueryInterface(?IID_IDocHostUIHandler, @iDocHostUIHandler) = #S_OK
                If iDocument\QueryInterface(?IID_ICustomDoc, @iCustomDoc) = #S_OK
                  *this = AllocateMemory(SizeOf(_IDocHostUIHandler))
                  If *this
                    *this\vTable = vTableAddress
                    *this\iDocHostUiHandler = iDocHostUIHandler
                    iCustomDoc\SetUIHandler(*this)
                    result = #S_OK
                  Else
                    iDocHostUIHandler\Release() 
                  EndIf            
                  iCustomDoc\Release()
                Else
                  iDocHostUIHandler\Release()
                EndIf
              EndIf
              IOleClientSite\Release()
            EndIf
            iOLE\Release()
          EndIf
          iDocument\Release()
        EndIf
        iDispatch\Release()
      EndIf
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////


;-TEST CODE.

;/////////////////////////////////////////////////////////////////////////////////
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")
  
  SetCustomDocHostUIHandler(0, ?IDocHostUIHandlerFunctionTable)
  
  Repeat 
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        Break
    EndSelect
  ForEver
EndIf

End
;/////////////////////////////////////////////////////////////////////////////////


;-CUSTOM iDocHostUIHandler IMPLEMENTATION.
;/////////////////////////////////////////////////////////////////////////////////
;iUnknown.
Procedure.i IDocHostUIHandler_QueryInterface(*this._IDocHostUIHandler, riid, *ppObj.INTEGER)
  Protected hResult = #E_NOINTERFACE, iunk.iUnknown
  If *ppObj And riid 
    *ppObj\i = 0
    If CompareMemory(riid, ?IID_IUnknown, SizeOf(IID)) Or CompareMemory(riid, ?IID_IDocHostUIHandler, SizeOf(IID))
      *ppObj\i = *this
      *this\ref+1
      hResult = #S_OK
    EndIf 
  EndIf
  ProcedureReturn hResult
EndProcedure

;iUnknown.
Procedure.i IDocHostUIHandler_AddRef(*this._IDocHostUIHandler)
  *this\ref = *this\ref + 1
  ProcedureReturn *this\ref
EndProcedure

;iUnknown.
Procedure.i IDocHostUIHandler_Release(*this._IDocHostUIHandler)
  Protected refCount
  *this\ref = *this\ref - 1
  refCount = *this\ref
  If *this\ref = 0
    *this\iDocHostUiHandler\Release()
    FreeMemory(*this) 
  EndIf
  ProcedureReturn refCount
EndProcedure

Procedure.i IDocHostUIHandler_ShowContextMenu(*this._IDocHostUIHandler, dwID, ppt, pcmdTarget, pdispReserved)
  ProcedureReturn *this\iDocHostUiHandler\ShowContextMenu(dwID, ppt, pcmdTarget, pdispReserved)
EndProcedure

Procedure.i IDocHostUIHandler_GetHostInfo(*this._IDocHostUIHandler, *pInfo)
  ProcedureReturn *this\iDocHostUiHandler\GetHostInfo(*pInfo)
EndProcedure

Procedure.i IDocHostUIHandler_ShowUI(*this._IDocHostUIHandler, dwID, pActiveObject, pCommandTarget, pFrame, pDoc)
  ProcedureReturn *this\iDocHostUiHandler\ShowUI(dwID, pActiveObject, pCommandTarget, pFrame, pDoc)
EndProcedure

Procedure.i IDocHostUIHandler_HideUI(*this._IDocHostUIHandler)
  ProcedureReturn *this\iDocHostUiHandler\HideUI()
EndProcedure

Procedure.i IDocHostUIHandler_UpdateUI(*this._IDocHostUIHandler)
  ProcedureReturn *this\iDocHostUiHandler\UpdateUI()
EndProcedure

Procedure.i IDocHostUIHandler_EnableModeless(*this._IDocHostUIHandler, fEnable)
  ProcedureReturn *this\iDocHostUiHandler\EnableModeless(fEnable)
EndProcedure

Procedure.i IDocHostUIHandler_OnDocWindowActivate(*this._IDocHostUIHandler, fActivate)
  ProcedureReturn *this\iDocHostUiHandler\OnDocWindowActivate(fActivate)
EndProcedure

Procedure.i IDocHostUIHandler_OnFrameWindowActivate(*this._IDocHostUIHandler, fActivate)
  ProcedureReturn *this\iDocHostUiHandler\OnFrameWindowActivate(fActivate)
EndProcedure

Procedure.i IDocHostUIHandler_ResizeBorder(*this._IDocHostUIHandler, prcBorder, pUIWindow, fFrameWindow)
  ProcedureReturn *this\iDocHostUiHandler\ResizeBorder(prcBorder, pUIWindow, fFrameWindow)
EndProcedure

Procedure.i IDocHostUIHandler_TranslateAccelerator(*this._IDocHostUIHandler, *lpMsg.MSG, pguidCmdGroup, nCmdID)
  
  If *lpMsg And *lpMsg\message = #WM_KEYDOWN
    
;     If GetKeyState_(#VK_CONTROL) & $8000   ;block all Control key combinations except for Ctrl+C
;       Select  *lpMsg\wParam
;         Case #VK_C
;           
;         Default
;           ProcedureReturn #S_OK
;       EndSelect
;       
;     EndIf
    
    If GetKeyState_(#VK_CONTROL) & $8000
      Select  *lpMsg\wParam
        Case #VK_N
          Debug "Ctrl + N"
          ProcedureReturn #S_OK
          
        Case #VK_O
          Debug "Ctrl + O"
          ProcedureReturn #S_OK
          
      EndSelect
      
    EndIf
  EndIf
  
  ProcedureReturn *this\iDocHostUiHandler\TranslateAccelerator(*lpMsg, pguidCmdGroup, nCmdID)
EndProcedure

Procedure.i IDocHostUIHandler_GetOptionKeyPath(*this._IDocHostUIHandler, pchKey, DW)
  ProcedureReturn *this\iDocHostUiHandler\GetOptionKeyPath(pchKey, DW)
EndProcedure

Procedure.i IDocHostUIHandler_GetDropTarget(*this._IDocHostUIHandler, pDropTarget, ppDropTarget)
  ProcedureReturn *this\iDocHostUiHandler\GetDropTarget(pDropTarget, ppDropTarget)
EndProcedure

Procedure.i IDocHostUIHandler_GetExternal(*this._IDocHostUIHandler, ppDispatch.i)
   ProcedureReturn *this\iDocHostUiHandler\GetExternal(ppDispatch.i)
EndProcedure

Procedure.i IDocHostUIHandler_TranslateUrl(*this._IDocHostUIHandler, dwTranslate, pchURLIn, ppchURLOut)
  ProcedureReturn *this\iDocHostUiHandler\TranslateUrl(dwTranslate, pchURLIn, ppchURLOut)
EndProcedure

Procedure.i IDocHostUIHandler_FilterDataObject(*this._IDocHostUIHandler, pDO, ppDORet)
   ProcedureReturn *this\iDocHostUiHandler\FilterDataObject(pDO, ppDORet)
EndProcedure

DataSection

IID_IUnknown: ; 00000000-0000-0000-C000-000000000046
  Data.l $00000000
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46

IID_IHTMLDocument2: ; 332C4425-26CB-11D0-B483-00C04FD90119
  Data.l $332C4425
  Data.w $26CB, $11D0
  Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19

IID_IOleObject: ; 00000112-0000-0000-C000-000000000046
  Data.l $00000112
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46

IID_IDocHostUIHandler: ; BD3F23C0-D43E-11CF-893B-00AA00BDCE1A
  Data.l $BD3F23C0
  Data.w $D43E, $11CF
  Data.b $89, $3B, $00, $AA, $00, $BD, $CE, $1A

IID_ICustomDoc: ; 3050F3F0-98B5-11CF-BB82-00AA00BDCE0B
  Data.l $3050F3F0
  Data.w $98B5, $11CF
  Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B

IDocHostUIHandlerFunctionTable:
  Data.i @IDocHostUIHandler_QueryInterface()
  Data.i @IDocHostUIHandler_AddRef()
  Data.i @IDocHostUIHandler_Release()
  Data.i @IDocHostUIHandler_ShowContextMenu()
  Data.i @IDocHostUIHandler_GetHostInfo()
  Data.i @IDocHostUIHandler_ShowUI()
  Data.i @IDocHostUIHandler_HideUI()
  Data.i @IDocHostUIHandler_UpdateUI()
  Data.i @IDocHostUIHandler_EnableModeless()
  Data.i @IDocHostUIHandler_OnDocWindowActivate()
  Data.i @IDocHostUIHandler_OnFrameWindowActivate()
  Data.i @IDocHostUIHandler_ResizeBorder()
  Data.i @IDocHostUIHandler_TranslateAccelerator()
  Data.i @IDocHostUIHandler_GetOptionKeyPath()
  Data.i @IDocHostUIHandler_GetDropTarget()
  Data.i @IDocHostUIHandler_GetExternal()
  Data.i @IDocHostUIHandler_TranslateUrl()
  Data.i @IDocHostUIHandler_FilterDataObject()
EndDataSection
;/////////////////////////////////////////////////////////////////////////////////
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by firace »

@breeze4me: Thanks, nice one!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by RASHAD »

Hi firace
Just a few lines of code but very flexible
And using a Local Hook will not affect the outside world

Code: Select all

Global Keyhook

Procedure HookProc(nCode,wParam,lParam)
  Select wParam
      Case #VK_N,#VK_O
        If GetActiveGadget() = 1 
          ProcedureReturn 1
        Else
          ProcedureReturn 0
        EndIf
   EndSelect
   ProcedureReturn CallNextHookEx_(0,nCode,wParam,lParam)   
EndProcedure

If OpenWindow(0, 0, 0, 600, 600, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
   WebGadget(1, 0, 0, 600, 295, "http://www.purebasic.com")
   WebGadget(2, 0, 305, 600, 295, "http://www.purebasic.com")
Repeat
    Select WaitWindowEvent()
            Case #PB_Event_CloseWindow 
                  Quit = 1                 
                
            Case #PB_Event_Gadget
                  Select EventGadget()
                         Case 1
                              Keyhook = SetWindowsHookEx_(#WH_KEYBOARD,@HookProc(),0, GetCurrentThreadId_())
                                  
                         Case 2
                              UnhookWindowsHookEx_(Keyhook)
                  EndSelect
    EndSelect
 Until Quit = 1
EndIf
UnhookWindowsHookEx_(Keyhook)

Egypt my love
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by JHPJHP »

Hi RASHAD,

Your solution being so close to mine will suffer the same problem of not just disabling "CTRL+O", but blocking anything "O".

One fix would be to trap for #WM_KEYDOWN / #WM_KEYUP to distinguish when "O" is pressed while "CTRL" is down... see my first post for an example.
- I agree that a local keyboard hook is more appropriate in this case

Cheers!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by RASHAD »

Hi JHPJHP
Glad to see you active again :)
Happy new year mate

Code: Select all

Global Keyhook

Procedure HookProc(nCode,wParam,lParam)
  Select nCode
      Case #HC_ACTION
        bcontrol = GetAsyncKeyState_(#VK_CONTROL)
        Select wparam
          Case #VK_O,#VK_N
            If bcontrol
              Debug "NO"
              ProcedureReturn 1
            Else
              Debug wparam
              ProcedureReturn 0
            EndIf
          EndSelect
       EndSelect

   ProcedureReturn CallNextHookEx_(0,nCode,wParam,lParam)   
EndProcedure

If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
   WebGadget(1, 0, 0, 600, 295, "http://www.purebasic.com")
Repeat
    Select WaitWindowEvent()
            Case #PB_Event_CloseWindow
                  Quit = 1                 
               
            Case #PB_Event_Gadget
                  Select EventGadget()
                         Case 1
                              Keyhook = SetWindowsHookEx_(#WH_KEYBOARD,@HookProc(),0, GetCurrentThreadId_())
                               
 
                  EndSelect
    EndSelect
 Until Quit = 1
EndIf
UnhookWindowsHookEx_(Keyhook)
Egypt my love
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by JHPJHP »

Hi RASHAD,
RASHAD wrote:Glad to see you active again
Happy new year mate
Thank you, it's good to stretch out the programming muscles once in awhile.

Happy Holidays to you and yours!

NB*:GetAsyncKeyState was a much better solution then trapping for #WM_KEYDOWN / #WM_KEYUP.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: WebGadget without native IE Shortcuts like CTRL+N, CTRL+

Post by kenmo »

Good tips here!

I borrowed Rashad's method to enable/disable the keyboard hook.

But instead of checking EventGadget() for the WebGadget, I had to check GetActiveGadget().
Because sometimes: an event would occur for a different gadget AFTER the WebGadget gets focus (such as a StringGadget posting LostFocus) which would DISABLE the keyboard hook when you need it!
Post Reply