Changeset 10284 for trunk/src


Ignore:
Timestamp:
Oct 22, 2003, 2:43:14 PM (22 years ago)
Author:
sandervl
Message:

Use WC_FRAME for the Odin frame window and subclass it; Updates for new keyboard hook

Location:
trunk/src/user32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/inituser32.cpp

    r10277 r10284  
    1 /* $Id: inituser32.cpp,v 1.15 2003-10-20 17:18:30 sandervl Exp $ */
     1/* $Id: inituser32.cpp,v 1.16 2003-10-22 12:43:13 sandervl Exp $ */
    22/*
    33 * USER32 DLL entry point
     
    4242#include <spy.h>
    4343#include <monitor.h>
     44#include <kbdhook.h>
    4445#include "pmwindow.h"
    4546#include "win32wdesktop.h"
     
    7071extern INT __cdecl wsnprintfA(LPSTR,UINT,LPCSTR,...);
    7172
    72 /**************************************************************/
    73 /* Try to load the Presentation Manager Keyboard Hook module. */
    74 /* If this fails, some hotkeys may not arrive properly at the */
    75 /* targetted window, but no more harmful things will happen.  */
    76 /**************************************************************/
    77 static char PMKBDHK_MODULE[16] = "PMKBDHK";
    78 #define PMKBDHK_HOOK_INIT "hookInit"
    79 #define PMKBDHK_HOOK_TERM "hookKill"
     73static char PMKBDHK_MODULE[16] = STD_PMKBDHK_MODULE;
    8074
    8175static BOOL pmkbdhk_installed = FALSE;
    8276static HMODULE hmodPMKBDHK;
    8377
    84 static PVOID (*APIENTRY pfnHookInit)(HAB);
    85 static BOOL  (*APIENTRY pfnHookTerm)(void);
     78static PFN_HOOKINIT pfnHookInit = NULL;
     79static PFN_HOOKTERM pfnHookTerm = NULL;
    8680
    8781// defined initialized in pmwindow.cpp: InitPM()
     
    9488   strcpy(PMKBDHK_MODULE, pszKbdDllName);
    9589}
    96 
     90//******************************************************************************
     91//******************************************************************************
     92void pmkbdhk_initialize(HAB _hab)
     93{
     94  APIRET rc;
     95
     96  if ((pmkbdhk_installed == FALSE) && PMKBDHK_MODULE[0])
     97  {
     98    CHAR szBuf[260];
     99
     100    // load the DLL
     101    rc = DosLoadModule(szBuf,
     102                       sizeof(szBuf),
     103                       PMKBDHK_MODULE,
     104                       &hmodPMKBDHK);
     105    if (NO_ERROR != rc)
     106    {
     107      dprintf(("USER32: pmkbdhk_initalize(%08xh) failed rc=%d\n",
     108               _hab,
     109               rc));
     110
     111      return;
     112    }
     113
     114    // get the entry points
     115    rc = DosQueryProcAddr(hmodPMKBDHK,
     116                          0,
     117                          PMKBDHK_HOOK_INIT,
     118                          (PFN*)&pfnHookInit);
     119    if (NO_ERROR == rc)
     120      rc = DosQueryProcAddr(hmodPMKBDHK,
     121                            0,
     122                            PMKBDHK_HOOK_TERM,
     123                            (PFN*)&pfnHookTerm);
     124
     125    if (NO_ERROR != rc)
     126    {
     127      dprintf(("USER32: pmkbdhk_initalize(%08xh) failed importing functions, rc=%d\n",
     128               _hab,
     129               rc));
     130
     131      // free the DLL again
     132      DosFreeModule(hmodPMKBDHK);
     133      hmodPMKBDHK = NULLHANDLE;
     134
     135      return;
     136    }
     137
     138    // now finally call the initializer function
     139    if(pfnHookInit(_hab, WIN32_STDCLASS) == FALSE) DebugInt3();
     140
     141    // OK, hook is armed
     142    pmkbdhk_installed = TRUE;
     143  }
     144}
     145//******************************************************************************
     146//******************************************************************************
     147void pmkbdhk_terminate(void)
     148{
     149  if (pmkbdhk_installed == TRUE)
     150  {
     151    // call the terminator function
     152    pfnHookTerm();
     153
     154    // OK, hook is disarmed
     155    pmkbdhk_installed = FALSE;
     156  }
     157
     158  // unload the dll
     159  if (NULLHANDLE != hmodPMKBDHK)
     160  {
     161    APIRET rc = DosFreeModule(hmodPMKBDHK);
     162    if (NO_ERROR != rc)
     163    {
     164      dprintf(("USER32: pmkbdhk_terminate() failed rc=%d\n",
     165               rc));
     166
     167      hmodPMKBDHK = NULLHANDLE;
     168    }
     169  }
     170}
     171//******************************************************************************
    97172#define FONTSDIRECTORY "Fonts"
    98173#define REGPATH "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"
    99 
    100 //******************************************************************************
    101174//******************************************************************************
    102175void MigrateWindowsFonts()
     
    145218  }
    146219}
    147 
    148 //******************************************************************************
    149 //******************************************************************************
    150 void pmkbdhk_initialize(HAB _hab)
    151 {
    152   APIRET rc;
    153 
    154   if ((pmkbdhk_installed == FALSE) && PMKBDHK_MODULE[0])
    155   {
    156     CHAR szBuf[260];
    157 
    158     // load the DLL
    159     rc = DosLoadModule(szBuf,
    160                        sizeof(szBuf),
    161                        PMKBDHK_MODULE,
    162                        &hmodPMKBDHK);
    163     if (NO_ERROR != rc)
    164     {
    165       dprintf(("USER32: pmkbdhk_initalize(%08xh) failed rc=%d\n",
    166                _hab,
    167                rc));
    168 
    169       return;
    170     }
    171 
    172     // get the entry points
    173     rc = DosQueryProcAddr(hmodPMKBDHK,
    174                           0,
    175                           PMKBDHK_HOOK_INIT,
    176                           (PFN*)&pfnHookInit);
    177     if (NO_ERROR == rc)
    178       rc = DosQueryProcAddr(hmodPMKBDHK,
    179                             0,
    180                             PMKBDHK_HOOK_TERM,
    181                             (PFN*)&pfnHookTerm);
    182 
    183     if (NO_ERROR != rc)
    184     {
    185       dprintf(("USER32: pmkbdhk_initalize(%08xh) failed importing functions, rc=%d\n",
    186                _hab,
    187                rc));
    188 
    189       // free the DLL again
    190       DosFreeModule(hmodPMKBDHK);
    191       hmodPMKBDHK = NULLHANDLE;
    192 
    193       return;
    194     }
    195 
    196     // now finally call the initializer function
    197     pfnHookInit(_hab);
    198 
    199     // OK, hook is armed
    200     pmkbdhk_installed = TRUE;
    201   }
    202 }
    203 //******************************************************************************
    204 //******************************************************************************
    205 void pmkbdhk_terminate(void)
    206 {
    207   if (pmkbdhk_installed == TRUE)
    208   {
    209     // call the terminator function
    210     pfnHookTerm();
    211 
    212     // OK, hook is disarmed
    213     pmkbdhk_installed = FALSE;
    214   }
    215 
    216   // unload the dll
    217   if (NULLHANDLE != hmodPMKBDHK)
    218   {
    219     APIRET rc = DosFreeModule(hmodPMKBDHK);
    220     if (NO_ERROR != rc)
    221     {
    222       dprintf(("USER32: pmkbdhk_terminate() failed rc=%d\n",
    223                rc));
    224 
    225       hmodPMKBDHK = NULLHANDLE;
    226     }
    227   }
    228 }
    229220/****************************************************************************/
    230221/* _DLL_InitTerm is the function that gets called by the operating system   */
  • trunk/src/user32/oslibwin.cpp

    r10275 r10284  
    1 /* $Id: oslibwin.cpp,v 1.144 2003-10-20 17:17:22 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.145 2003-10-22 12:43:13 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    66 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
    77 * Copyright 1999 Daniela Engert (dani@ngrt.de)
    8  *
     8 * Copyright 2002-2003 Innotek Systemberatung GmbH
    99 *
    1010 * Project Odin Software License can be found in LICENSE.TXT
     
    3737#define WS_TOPMOST                 0x00200000L
    3838
     39//pmwindow.cpp
     40MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     41
    3942//******************************************************************************
    4043//******************************************************************************
     
    6467                          DWORD classStyle, HWND *hwndFrame)
    6568{
    66  HWND  hwndClient;
    67  ULONG dwFrameStyle = 0;
     69    HWND  hwndClient;
     70    ULONG dwFrameStyle = 0;
    6871
    6972    if(pszName && *pszName == 0) {
     
    98101    //    a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border
    99102    *hwndFrame = WinCreateWindow(hwndParent,
    100                            WIN32_STDFRAMECLASS,
     103                           WC_FRAME,
    101104                           pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0,
    102105                           Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
    103106                           id, (PVOID)&FCData, NULL);
    104107
     108    //We no longer register our own frame window class as there is code in PM
     109    //that makes assumptions about frame window class names.
     110    //Instead we subclass the frame window right after creating it.
     111    if(*hwndFrame) {
     112        WinSubclassWindow(*hwndFrame, Win32FrameWindowProc);
     113    }
    105114    if(fOS2Look && *hwndFrame) {
    106115        FCData.flCreateFlags = dwOSFrameStyle;
     
    118127    if (hwndParent == HWND_DESKTOP && *hwndFrame)
    119128       OSLibWinCreateInvisibleScroller(*hwndFrame, SBS_VERT);
    120 
    121129
    122130    if(hwndClient == 0) {
  • trunk/src/user32/pmwindow.cpp

    r10276 r10284  
    1 /* $Id: pmwindow.cpp,v 1.221 2003-10-20 17:18:14 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.222 2003-10-22 12:43:14 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    8181BOOL    fDragDropDisabled = FALSE;
    8282
    83 char WIN32_CDCLASS[255]       = "Win32CDWindowClass";
    84 char WIN32_STDCLASS[255]      = "Win32WindowClass";
    85 char WIN32_STDFRAMECLASS[255] = "Win32FrameClass";
     83const char WIN32_CDCLASS[]       = "Win32CDWindowClass";
     84      char WIN32_STDCLASS[255]   = "Win32WindowClass";
    8685
    8786#define PMMENU_MINBUTTON           0
     
    106105HBITMAP hBmpCloseButtonDown   = 0;
    107106
    108 static PFNWP pfnFrameWndProc = NULL;
     107      PFNWP pfnFrameWndProc = NULL;
    109108static HWND  hwndFocusChange = 0;
    110109       HWND  hwndCD = 0;
     
    215214    }
    216215
     216    //We no longer register our own frame window class as there is code in PM
     217    //that makes assumptions about frame window class names.
     218    //Instead we subclass the frame window right after creating it.
    217219    CLASSINFO FrameClassInfo;
    218220    if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
     
    223225
    224226    dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
    225 
    226     // this is our OS/2 window class for frame windows
    227     if(!WinRegisterClass(                 /* Register window class        */
    228         hab,                               /* Anchor block handle          */
    229         (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
    230         (PFNWP)Win32FrameWindowProc,       /* Address of window procedure  */
    231         CS_FRAME,
    232         FrameClassInfo.cbWindowData))
    233     {
    234         dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
    235         return(FALSE);
    236     }
    237227
    238228    // get the screen dimensions and store them
     
    506496 POSTMSG_PACKET  *postmsg;
    507497 OSLIBPOINT       point, ClientPoint;
    508 
     498 EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
     499
     500    ODIN_SetExceptionHandler(&exceptRegRec);
    509501    // restore our FS selector
    510502    SetWin32TIB();
     
    583575        RELEASE_WNDOBJ(win32wnd);
    584576        RestoreOS2TIB();
     577        ODIN_UnsetExceptionHandler(&exceptRegRec);
    585578
    586579#ifdef DEBUG
     
    11551148    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    11561149    RestoreOS2TIB();
     1150    ODIN_UnsetExceptionHandler(&exceptRegRec);
    11571151
    11581152#ifdef DEBUG
     
    11661160
    11671161    RestoreOS2TIB();
     1162    ODIN_UnsetExceptionHandler(&exceptRegRec);
    11681163
    11691164#ifdef DEBUG
     
    11821177 MRESULT          rc = 0;
    11831178 MSG              winMsg, *pWinMsg;
     1179 EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
    11841180
    11851181#ifdef DEBUG
     
    11871183#endif
    11881184
     1185    ODIN_SetExceptionHandler(&exceptRegRec);
    11891186    //Restore our FS selector
    11901187    SetWin32TIB();
     
    21722169    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    21732170    RestoreOS2TIB();
     2171    ODIN_UnsetExceptionHandler(&exceptRegRec);
    21742172
    21752173#ifdef DEBUG
     
    21822180    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    21832181    RestoreOS2TIB();
     2182    ODIN_UnsetExceptionHandler(&exceptRegRec);
    21842183
    21852184#ifdef DEBUG
     
    21922191    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    21932192    RestoreOS2TIB();
     2193    ODIN_UnsetExceptionHandler(&exceptRegRec);
    21942194
    21952195    //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
     
    22292229    rc = pfnOldWindowProc(hwnd, msg, mp1, mp2);
    22302230
     2231    ODIN_SetExceptionHandler(&exceptRegRec);
    22312232    SetWin32TIB();
    22322233    switch(msg) {
     
    22502251    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    22512252    RestoreOS2TIB();
     2253    ODIN_UnsetExceptionHandler(&exceptRegRec);
    22522254    return rc;
    22532255
     
    24642466}
    24652467
    2466 // @@PF Three funcs to override std class names we use in Odin
    2467 //******************************************************************************
    2468 //******************************************************************************
    2469 void WIN32API SetCustomCDClassName(LPSTR pszCDClassName)
    2470 {
    2471    strcpy(WIN32_CDCLASS, pszCDClassName);
    2472 }
    2473 //******************************************************************************
     2468//******************************************************************************
     2469// Override std class names we use in Odin (necessary for keyboard hook)
    24742470//******************************************************************************
    24752471void WIN32API SetCustomStdClassName(LPSTR pszStdClassName)
    24762472{
    24772473   strcpy(WIN32_STDCLASS, pszStdClassName);
    2478 }
    2479 //******************************************************************************
    2480 //******************************************************************************
    2481 void WIN32API SetCustomStdFrameClassName(LPSTR pszStdFrameClassName)
    2482 {
    2483    strcpy(WIN32_STDFRAMECLASS, pszStdFrameClassName);
    24842474}
    24852475//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.