View the DQSD CVS repository here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/

Update of /cvsroot/dqsd/dqsd/src/DQSDTools
In directory usw-pr-cvs1:/tmp/cvs-serv23233/src/DQSDTools

Modified Files:
        DQSDTools.cpp DQSDTools.rc KeyboardHook.cpp KeyboardHook.h 
        Launcher.cpp Launcher.h Utilities.cpp 
Log Message:
Fixed keyboard hook code to remove hook when relevant DQSDTools object is deleted.  
Prevents double hooking causing recusive crash on Win9x after a reload.

Index: DQSDTools.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/DQSDTools.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** DQSDTools.cpp       19 Jun 2002 14:58:55 -0000      1.7
--- DQSDTools.cpp       18 Jul 2002 20:09:05 -0000      1.8
***************
*** 6,12 ****
  
  #include "DQSDTools_i.c"
  #include "Launcher.h"
  #include "MenuBuilder.h"
- #include "KeyboardHook.h"
  
  #ifdef _MERGE_PROXYSTUB
--- 6,12 ----
  
  #include "DQSDTools_i.c"
+ #include "KeyboardHook.h"
  #include "Launcher.h"
  #include "MenuBuilder.h"
  
  #ifdef _MERGE_PROXYSTUB

Index: DQSDTools.rc
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/DQSDTools.rc,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** DQSDTools.rc        8 Jul 2002 10:32:04 -0000       1.21
--- DQSDTools.rc        18 Jul 2002 20:09:05 -0000      1.22
***************
*** 55,60 ****
  
  VS_VERSION_INFO VERSIONINFO
!  FILEVERSION 3,0,0,18
!  PRODUCTVERSION 3,0,0,18
   FILEFLAGSMASK 0x3fL
  #ifdef _DEBUG
--- 55,60 ----
  
  VS_VERSION_INFO VERSIONINFO
!  FILEVERSION 3,0,0,21
!  PRODUCTVERSION 3,0,0,21
   FILEFLAGSMASK 0x3fL
  #ifdef _DEBUG
***************
*** 75,79 ****
              VALUE "ContributingAuthors", "Koen Mannaerts (WhirlyWiryWeb.com), David 
Bau (notesbydave.com), Glenn Carr (glenncarr.com), Will Dean (indcomp.co.uk)\0"
              VALUE "FileDescription", "ActiveX Tools for Dave's Quick Search Bar \0"
!             VALUE "FileVersion", "3, 0, 0, 18\0"
              VALUE "InternalName", "DQSDTools\0"
              VALUE "LegalCopyright", "Copyright (c) 2002 David Bau. GNU Public 
License Version 2 applies.\0"
--- 75,79 ----
              VALUE "ContributingAuthors", "Koen Mannaerts (WhirlyWiryWeb.com), David 
Bau (notesbydave.com), Glenn Carr (glenncarr.com), Will Dean (indcomp.co.uk)\0"
              VALUE "FileDescription", "ActiveX Tools for Dave's Quick Search Bar \0"
!             VALUE "FileVersion", "3, 0, 0, 21\0"
              VALUE "InternalName", "DQSDTools\0"
              VALUE "LegalCopyright", "Copyright (c) 2002 David Bau. GNU Public 
License Version 2 applies.\0"
***************
*** 83,87 ****
              VALUE "PrivateBuild", "\0"
              VALUE "ProductName", "DQSDTools ActiveX Components\0"
!             VALUE "ProductVersion", "3, 0, 0, 18\0"
              VALUE "SpecialBuild", "\0"
          END
--- 83,87 ----
              VALUE "PrivateBuild", "\0"
              VALUE "ProductName", "DQSDTools ActiveX Components\0"
!             VALUE "ProductVersion", "3, 0, 0, 21\0"
              VALUE "SpecialBuild", "\0"
          END

Index: KeyboardHook.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/KeyboardHook.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** KeyboardHook.cpp    8 Jul 2002 10:32:04 -0000       1.15
--- KeyboardHook.cpp    18 Jul 2002 20:09:05 -0000      1.16
***************
*** 245,252 ****
  //
  //
! HRESULT KeyboardHookInstall(HWND hBarWnd)
  {
- //    HWND hBarWnd = UtilitiesFindDQSDWindow();
- 
        // Did we find the window?
        if(hBarWnd == NULL)
--- 245,250 ----
  //
  //
! HRESULT KeyboardHookInstall(HWND hBarWnd, HHOOK& hInstalledHook)
  {
        // Did we find the window?
        if(hBarWnd == NULL)
***************
*** 255,269 ****
        }
        
- 
        // Get a handle to the thread which owns the message queue for this window
        DWORD threadId = GetWindowThreadProcessId(hBarWnd, NULL);
  
!       _RPT1(_CRT_WARN, "Thread ID 0x%x\n", threadId);
  
        hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, 
_Module.GetModuleInstance(), threadId);
  
!       _RPT1(_CRT_WARN, "hHook 0x%x\n", hHook);
  
        return S_OK;
  }
  
--- 253,283 ----
        }
        
        // Get a handle to the thread which owns the message queue for this window
        DWORD threadId = GetWindowThreadProcessId(hBarWnd, NULL);
  
!       ATLTRACE("Thread ID 0x%x\n", threadId);
! 
!       if(hHook != NULL)
!       {
!               ATLTRACE("DQSD: Keyboard Hook already installed\n");
!               return CLauncher::Error(IDS_ERR_CANT_INSTALL_KEYBOARD_HOOK, 
IID_ILauncher);
!       }
  
        hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, 
_Module.GetModuleInstance(), threadId);
+       hInstalledHook = hHook;
  
!       ATLTRACE("hHook 0x%x\n", hHook);
  
        return S_OK;
+ }
+ 
+ void
+ KeyboardHookRemove(HHOOK hInstalledHook)
+ {
+       if(hInstalledHook != NULL)
+       {
+               UnhookWindowsHookEx(hInstalledHook);
+               hHook = NULL;
+       }
  }
  

Index: KeyboardHook.h
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/KeyboardHook.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** KeyboardHook.h      8 Jul 2002 10:32:04 -0000       1.6
--- KeyboardHook.h      18 Jul 2002 20:09:05 -0000      1.7
***************
*** 6,10 ****
  #define KEYBOARDHOOK_H
  
! HRESULT KeyboardHookInstall(HWND hWnd);
  
  //
--- 6,12 ----
  #define KEYBOARDHOOK_H
  
! HRESULT KeyboardHookInstall(HWND hWnd, HHOOK& hInstalledHook);
! void KeyboardHookRemove(HHOOK hInstalledHook);
! 
  
  //

Index: Launcher.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/Launcher.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** Launcher.cpp        11 Jul 2002 20:28:30 -0000      1.29
--- Launcher.cpp        18 Jul 2002 20:09:06 -0000      1.30
***************
*** 2,7 ****
  #include "stdafx.h"
  #include "DQSDTools.h"
- #include "Launcher.h"
  #include "KeyboardHook.h"
  #include "Utilities.h"
  
--- 2,7 ----
  #include "stdafx.h"
  #include "DQSDTools.h"
  #include "KeyboardHook.h"
+ #include "Launcher.h"
  #include "Utilities.h"
  
***************
*** 385,389 ****
  STDMETHODIMP CLauncher::InstallKeyboardHook(LPDISPATCH pDispDocument)
  {
!       return KeyboardHookInstall(UtilitiesFindDQSDWindow(pDispDocument));
  }
  
--- 385,389 ----
  STDMETHODIMP CLauncher::InstallKeyboardHook(LPDISPATCH pDispDocument)
  {
!       return KeyboardHookInstall(UtilitiesFindDQSDWindow(pDispDocument), 
m_hKeyboardHook);
  }
  

Index: Launcher.h
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/Launcher.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Launcher.h  8 Jul 2002 10:32:04 -0000       1.16
--- Launcher.h  18 Jul 2002 20:09:06 -0000      1.17
***************
*** 37,40 ****
--- 37,41 ----
  //            m_hBaseTooltipWnd = NULL;
                m_hHotkeyNotificationWindow = NULL;
+               m_hKeyboardHook = NULL;
        }
  
***************
*** 48,51 ****
--- 49,54 ----
                        DestroyWindow(m_hHotkeyNotificationWindow);
                }
+ 
+               KeyboardHookRemove(m_hKeyboardHook);
        }
  
***************
*** 89,92 ****
--- 92,96 ----
        static LPCTSTR DQSD_SEC_KEY;
        bool    m_bDebug;
+       HHOOK   m_hKeyboardHook;
  
  //    HWND    m_hBaseTooltipWnd;

Index: Utilities.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/Utilities.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Utilities.cpp       8 Jul 2002 10:32:04 -0000       1.5
--- Utilities.cpp       18 Jul 2002 20:09:06 -0000      1.6
***************
*** 118,137 ****
        IOleWindowPtr pOleWindow;
  
!       HRESULT hResult = pDispDocument->QueryInterface(IID_IOleWindow, 
(LPVOID*)&pOleWindow);
!       if(SUCCEEDED(hResult))
        {
!               HWND hWnd;
! 
!               hResult = pOleWindow->GetWindow(&hWnd);
!               ATLTRACE("UtilitiesFindDQSDWindow: hResult 0x%x, hWnd 0x%x\n", 
hResult, hWnd);
                if(SUCCEEDED(hResult))
                {
!                       g_hDQSDWindow = hWnd;
!                       return hWnd;
                }
        }
!       else
        {
!               ATLTRACE("UtilitiesFindDQSDWindow: GetSiteFailed hResult 0x%x\n", 
hResult);
        }
        return NULL;
--- 118,151 ----
        IOleWindowPtr pOleWindow;
  
!       try
        {
!               HRESULT hResult = pDispDocument->QueryInterface(IID_IOleWindow, 
(LPVOID*)&pOleWindow);
                if(SUCCEEDED(hResult))
                {
!                       HWND hWnd;
! 
!                       hResult = pOleWindow->GetWindow(&hWnd);
!                       ATLTRACE("UtilitiesFindDQSDWindow: hResult 0x%x, hWnd 0x%x\n", 
hResult, hWnd);
!                       if(SUCCEEDED(hResult))
!                       {
!                               g_hDQSDWindow = hWnd;
!                               return hWnd;
!                       }
                }
+               else
+               {
+                       ATLTRACE("UtilitiesFindDQSDWindow: GetSiteFailed hResult 
+0x%x\n", hResult);
+               }
+ 
        }
!       catch(_com_error& e)
        {
!               ATLTRACE("UtilitiesFindDQSDWindow: COM exception: Desc %s, Message 
%d\n", 
!                       (LPCTSTR)e.Description(), 
!                       (LPCTSTR)e.ErrorMessage());
!       }
!       catch(...)
!       {
!               ATLTRACE("UtilitiesFindDQSDWindow: Unknown Exception Caught\n");
        }
        return NULL;




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-CVS mailing list
https://lists.sourceforge.net/lists/listinfo/dqsd-cvs
DQSD CVS repository:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/

Reply via email to