Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

580 lines
23 KiB

  1. #include "stdafx.h"
  2. #include "handlers.h"
  3. //-------------------------------------------------------------------------//
  4. // Declare registered message vars **here**
  5. //-------------------------------------------------------------------------//
  6. #define __NO_APPHACKS__
  7. //-------------------------------------------------------------------------//
  8. // Message Handlers
  9. //-------------------------------------------------------------------------//
  10. // Rules for message handlers [scotthan]:
  11. //
  12. // (1) Use DECL_ macros to declare message handler prototype and
  13. // table entries for message handlers below.
  14. // (2) A message handler implementation should NOT:
  15. // 1. call DefWindowProc or CallWindowProc directly,
  16. // but rather use DoMsgDefault().
  17. // 2. delete the incoming CThemeWnd* object,
  18. // (3) A message handler SHOULD:
  19. // 1. Honor the codepage value in the message block when
  20. // handling messages that carry string args.
  21. // If the codepage member is CP_WINUNICODE, the widechar
  22. // string processing should be assumed; otherwise, multibyte
  23. // string processing should be assumed.
  24. // 2. If a message should not be forwarded for default processing,
  25. // mark the message as handled using MsgHandled().
  26. // (4) Handlers should be listed in the BEGIN/ENDMSG() block
  27. // below in decreasing order of expected frequency.
  28. //---------------------//
  29. // WndProc overrides
  30. //---------------------//
  31. // msg handler decls:
  32. DECL_MSGHANDLER( OnOwpPostCreate );
  33. DECL_MSGHANDLER( OnOwpPreStyleChange );
  34. DECL_MSGHANDLER( OnOwpPreWindowPosChanging );
  35. DECL_MSGHANDLER( OnOwpPreWindowPosChanged );
  36. DECL_MSGHANDLER( OnOwpPostWindowPosChanged );
  37. DECL_MSGHANDLER( OnOwpPostSettingChange );
  38. DECL_MSGHANDLER( OnOwpPreMeasureItem );
  39. DECL_MSGHANDLER( OnOwpPreDrawItem );
  40. DECL_MSGHANDLER( OnOwpPreMenuChar );
  41. DECL_MSGHANDLER( OnOwpPostThemeChanged );
  42. DECL_MSGHANDLER( OnOwpPreNcPaint );
  43. DECL_MSGHANDLER( OnOwpPostNcPaint );
  44. // handler table:
  45. BEGIN_HANDLER_TABLE(_rgOwpHandlers)
  46. // frequent messages
  47. DECL_MSGENTRY( WM_NCPAINT, OnOwpPreNcPaint, OnOwpPostNcPaint )
  48. DECL_MSGENTRY( WM_WINDOWPOSCHANGING, OnOwpPreWindowPosChanging, NULL )
  49. DECL_MSGENTRY( WM_WINDOWPOSCHANGED, OnOwpPreWindowPosChanged, OnOwpPostWindowPosChanged )
  50. DECL_MSGENTRY( WM_SETTINGCHANGE, NULL, OnOwpPostSettingChange )
  51. DECL_MSGENTRY( WM_MEASUREITEM, OnOwpPreMeasureItem, NULL )
  52. DECL_MSGENTRY( WM_DRAWITEM, OnOwpPreDrawItem, NULL )
  53. DECL_MSGENTRY( WM_MDISETMENU, NULL, NULL )
  54. // rare messages:
  55. DECL_MSGENTRY( WM_MENUCHAR, OnOwpPreMenuChar, NULL )
  56. DECL_MSGENTRY( WM_STYLECHANGING, OnOwpPreStyleChange, NULL )
  57. DECL_MSGENTRY( WM_STYLECHANGED, OnOwpPreStyleChange, NULL )
  58. DECL_MSGENTRY( WM_NCCREATE, NULL, NULL )
  59. DECL_MSGENTRY( WM_CREATE, NULL, OnOwpPostCreate )
  60. DECL_MSGENTRY( WM_NCDESTROY, NULL, NULL )
  61. DECL_MSGENTRY( WM_THEMECHANGED, NULL, OnOwpPostThemeChanged ) // we handle in line in ThemePreWndProc()
  62. DECL_MSGENTRY( WM_THEMECHANGED_TRIGGER, NULL, NULL ) // we handle in line in ThemePreWndProc()
  63. END_HANDLER_TABLE()
  64. // Note: values of high owp message must be in sync w/ table.
  65. #define WNDPROC_MSG_LAST WM_THEMECHANGED_TRIGGER // 0x031B (alias for WM_UAHINIT)
  66. //------------------------//
  67. // DefDlgProc overrides
  68. //------------------------//
  69. // msg handler decls:
  70. DECL_MSGHANDLER( OnDdpPostCtlColor );
  71. DECL_MSGHANDLER( OnDdpCtlColor );
  72. DECL_MSGHANDLER( OnDdpPrint );
  73. DECL_MSGHANDLER( OnDdpPostInitDialog );
  74. // handler table:
  75. BEGIN_HANDLER_TABLE(_rgDdpHandlers)
  76. // frequent messages:
  77. DECL_MSGENTRY( WM_CTLCOLORDLG, NULL, OnDdpPostCtlColor )
  78. DECL_MSGENTRY( WM_CTLCOLORSTATIC, NULL, OnDdpCtlColor)
  79. DECL_MSGENTRY( WM_CTLCOLORBTN, NULL, OnDdpCtlColor)
  80. DECL_MSGENTRY( WM_CTLCOLORMSGBOX, NULL, OnDdpPostCtlColor )
  81. DECL_MSGENTRY( WM_PRINTCLIENT, NULL, OnDdpPrint )
  82. // rare messages:
  83. DECL_MSGENTRY( WM_INITDIALOG, NULL, OnDdpPostInitDialog )
  84. END_HANDLER_TABLE()
  85. // Note: values of high ddp message must be in sync w/ table.
  86. #define DEFDLGPROC_MSG_LAST WM_PRINTCLIENT // 0x0318
  87. //--------------------------//
  88. // DefWindowProc override
  89. //--------------------------//
  90. // msg handler decls:
  91. DECL_MSGHANDLER( OnDwpNcPaint );
  92. DECL_MSGHANDLER( OnDwpNcHitTest );
  93. DECL_MSGHANDLER( OnDwpNcActivate );
  94. DECL_MSGHANDLER( OnDwpNcLButtonDown );
  95. DECL_MSGHANDLER( OnDwpNcThemeDrawCaption );
  96. DECL_MSGHANDLER( OnDwpNcThemeDrawFrame );
  97. DECL_MSGHANDLER( OnDwpNcMouseMove );
  98. DECL_MSGHANDLER( OnDwpNcMouseLeave );
  99. DECL_MSGHANDLER( OnDwpWindowPosChanged );
  100. DECL_MSGHANDLER( OnDwpSysCommand );
  101. DECL_MSGHANDLER( OnDwpSetText );
  102. DECL_MSGHANDLER( OnDwpSetIcon );
  103. DECL_MSGHANDLER( OnDwpStyleChanged );
  104. DECL_MSGHANDLER( OnDwpPrint );
  105. DECL_MSGHANDLER( OnDwpPrintClient );
  106. DECL_MSGHANDLER( OnDwpContextMenu );
  107. // handler table:
  108. BEGIN_HANDLER_TABLE(_rgDwpHandlers)
  109. // frequent messages:
  110. DECL_MSGENTRY( WM_NCHITTEST, OnDwpNcHitTest, NULL )
  111. DECL_MSGENTRY( WM_NCPAINT, OnDwpNcPaint, NULL )
  112. DECL_MSGENTRY( WM_NCACTIVATE, OnDwpNcActivate, NULL )
  113. DECL_MSGENTRY( WM_NCMOUSEMOVE, OnDwpNcMouseMove, NULL )
  114. DECL_MSGENTRY( WM_NCMOUSELEAVE, OnDwpNcMouseLeave, NULL )
  115. DECL_MSGENTRY( WM_WINDOWPOSCHANGED, OnDwpWindowPosChanged, NULL )
  116. DECL_MSGENTRY( WM_SYSCOMMAND, OnDwpSysCommand, NULL )
  117. DECL_MSGENTRY( WM_NCLBUTTONDOWN, OnDwpNcLButtonDown, NULL )
  118. DECL_MSGENTRY( WM_NCUAHDRAWCAPTION, OnDwpNcThemeDrawCaption, NULL )
  119. DECL_MSGENTRY( WM_NCUAHDRAWFRAME, OnDwpNcThemeDrawFrame, NULL )
  120. DECL_MSGENTRY( WM_PRINT, OnDwpPrint, NULL )
  121. DECL_MSGENTRY( WM_PRINTCLIENT, OnDwpPrintClient, NULL )
  122. DECL_MSGENTRY( WM_CTLCOLORMSGBOX, OnDdpPostCtlColor, NULL) // Strange: Sent to DefWindowProc, but is a Dialog message
  123. DECL_MSGENTRY( WM_CTLCOLORSTATIC, OnDdpCtlColor, NULL)
  124. DECL_MSGENTRY( WM_CTLCOLORBTN, OnDdpCtlColor, NULL)
  125. // rare messages:
  126. DECL_MSGENTRY( WM_SETTEXT, OnDwpSetText, NULL )
  127. DECL_MSGENTRY( WM_SETICON, OnDwpSetIcon, NULL )
  128. DECL_MSGENTRY( WM_STYLECHANGED, OnDwpStyleChanged, NULL )
  129. DECL_MSGENTRY( WM_CONTEXTMENU, OnDwpContextMenu, NULL )
  130. DECL_MSGENTRY( WM_THEMECHANGED_TRIGGER, NULL, NULL )
  131. DECL_MSGENTRY( WM_NCDESTROY, NULL, NULL )
  132. END_HANDLER_TABLE()
  133. // Note: values of high dwp message must be in sync w/ handler table.
  134. #define DEFWNDPROC_MSG_LAST WM_THEMECHANGED_TRIGGER // 0x031B
  135. //---------------------------------------------------------------------------
  136. BOOL _FindMsgHandler( UINT, MSGENTRY [], int, IN HOOKEDMSGHANDLER*, IN HOOKEDMSGHANDLER* );
  137. BOOL _SetMsgHandler( UINT, MSGENTRY [], int, IN HOOKEDMSGHANDLER, BOOL );
  138. //---------------------------------------------------------------------------
  139. // Special case hook handling
  140. //---------------------------------------------------------------------------
  141. //---------------------------------------------------------------------------
  142. BOOL _IsExcludedSystemProcess( LPCWSTR pszProcess )
  143. {
  144. static const WCHAR* _rgszSystemProcessList[] =
  145. {
  146. L"lsass", // Local Security Authority sub-system
  147. L"services", // Service Control Manager
  148. L"svchost", // Service Host
  149. L"mstask", // Microsoft Task Scheduler
  150. L"dfssvc", // Distributed File System Service
  151. L"winmgmt", // Windows Management Instrumentation
  152. L"spoolsv", // Print Spool Service
  153. L"msdtc", // Microsoft Distributed Transaction Co-ordinator
  154. L"regsvc", // Remote Registry Service
  155. L"webclnt", // Web Client
  156. L"mspmspsv", // WMDM PMSP Service (what is this?)
  157. L"ntvdm" // NT virtual DOS machine
  158. };
  159. return AsciiScanStringList( pszProcess, _rgszSystemProcessList,
  160. ARRAYSIZE(_rgszSystemProcessList), TRUE );
  161. }
  162. //---------------------------------------------------------------------------
  163. BOOL _IsProcessOnInteractiveWindowStation() // check if we're on winsta0.
  164. {
  165. BOOL fRet = FALSE;
  166. HWINSTA hWinSta = GetProcessWindowStation();
  167. if( hWinSta != NULL )
  168. {
  169. DWORD cbLength = 0;
  170. WCHAR wszName[32];
  171. if (GetUserObjectInformationW(hWinSta, UOI_NAME, wszName, sizeof(wszName), &cbLength))
  172. {
  173. fRet = (0 == AsciiStrCmpI(wszName, L"winsta0"));
  174. }
  175. else
  176. {
  177. // Problem! It's either:
  178. // - our buffer was too small (in which case it can't be winsta0)
  179. // - or some other failure we cannot overcome anyhow
  180. }
  181. }
  182. return(fRet);
  183. }
  184. //---------------------------------------------------------------------------
  185. BOOL _IsWin16App() // check if this is a 16-bit process
  186. {
  187. GUITHREADINFO gti;
  188. gti.cbSize = sizeof(gti);
  189. gti.flags = GUI_16BITTASK;
  190. return GetGUIThreadInfo( GetCurrentThreadId(), &gti ) &&
  191. TESTFLAG(gti.flags, GUI_16BITTASK );
  192. }
  193. //---------------------------------------------------------------------------
  194. BOOL ApiHandlerInit( const LPCTSTR pszProcess, USERAPIHOOK* puahTheme, const USERAPIHOOK* puahReal )
  195. {
  196. // exclude known non-UI system processes
  197. if( _IsExcludedSystemProcess( pszProcess ) )
  198. return FALSE;
  199. // exclude any process not hosted on winsta0.
  200. if( !_IsProcessOnInteractiveWindowStation() )
  201. return FALSE;
  202. if( _IsWin16App() )
  203. return FALSE;
  204. // SHIMSHIM [scotthan]:
  205. #ifdef _DEBUG
  206. //---- temp patch against msvcmon ----
  207. if( 0 == AsciiStrCmpI(pszProcess, L"msvcmon") )
  208. {
  209. return FALSE;
  210. }
  211. //---- temp patch against msdev ----
  212. if( 0 == AsciiStrCmpI(pszProcess, L"msdev") )
  213. {
  214. return FALSE;
  215. }
  216. //---- Aid in debugging classic/themed differences: ---
  217. if( 0 == AsciiStrCmpI( pszProcess, L"mditest1" ) )
  218. {
  219. return FALSE;
  220. }
  221. #endif
  222. #ifndef __NO_APPHACKS__
  223. static const WCHAR* _rgszExcludeAppList[] =
  224. {
  225. #ifdef THEME_CALCSIZE
  226. // Invoking SetWindowPos from CThemeWnd::SetFrameTheme on our Post-WM_CREATE handler
  227. // causes emacs to divide by zero after receiving meaningless rects from two
  228. // successive calls to AdjustWindowRectEx from his WM_WINDOWPOSCHANGING handler.
  229. // I don't believe it is related to the fact that AdjustWindowRectEx has yet
  230. // to be implemented for themed windows (raid# 140989), but rather that the wndproc
  231. // is not ready for a WM_WINDOWPOSCHANGING message on the abrubtly on the
  232. // heels of a WM_CREATE handler.
  233. L"emacs",
  234. L"neoplanet", // 247283: We rush in to theme neoplanet's dialogs, which we almost
  235. L"np", // immediately revoke, but not before sizing the dialog to theme-compatible
  236. // client rect. When we withdraw, we leave it clipped. No good way to deal
  237. // with this for beta2.
  238. // HTML Editor++ v.8: 286676:
  239. // This guy recomputes his nonclient area, and then AVs dereferencing a
  240. // WM_WINDOWPOSCHANGING message under themes.
  241. L"coffee",
  242. #endif THEME_CALCSIZE
  243. L"refcntr", // 205059: Corel Reference Center; lower 10% of window is clipped.
  244. L"KeyFramerPro", // 336456: Regardless of whether themes are enabled, Boris KeyFramer Pro v.5
  245. // does two SetWindowRgn() calls for every WM_PAINT, the first with a region,
  246. // the next with NULL, Is the app trying to clip his painting?
  247. // If so, this is not what SetWindowRgn was intended for, and explains why this
  248. // app is so clunky at window resizing. Rather, SelectClipRgn is the
  249. // correct API.
  250. // When themes are enabled, we keep revoking and re-attatching with each
  251. // SetWindowRgn call, so we get substantial flicker.
  252. // The ISV should be notified of this bug.
  253. // Applications that do custom non-client painting and hence look broken when
  254. // themed. Our only recourse at the moment it to exclude them from non-client
  255. // themeing so that we don't stomp whatever they are trying to do.
  256. L"RealJBox", // 273370: Real JukeBox
  257. L"RealPlay", // 285368: Real AudioPlayer
  258. L"TeamMgr", // 286654: Microsoft Team Manager97
  259. L"TrpMaker", // 307107: Rand McNally TripMaker 2000
  260. L"StrFindr", // 307535: Rand McNally StreetFinder 2000
  261. L"Exceed", // 276244: Hummingbird Exceed 6.2/7.0
  262. L"VP30", // 328676: Intel Video Phone
  263. // 313407: Groove, build 760
  264. // Calls DefWindowProc for NCPAINT, then paints his own caption over it.
  265. // Note: this just might work correctly if we had a DrawFrameControl hook.
  266. L"groove", // filever 1.1.0.760, 1/22/2001 tested.
  267. // 303756: Exclude all Lotus SmartSuite apps to provide consistency among their
  268. // apps. All of them draw into the caption bar.
  269. L"WordPro", // 285065: Lotus WordPro, a particularly poorly implemented app.
  270. L"SmartCtr", // It's WordPerfect compat menu is the elephant man of modern software.
  271. L"123w",
  272. L"Approach",
  273. L"FastSite",
  274. L"F32Main",
  275. L"Org5",
  276. // 358337: Best Technology - GCC Developer Lite. Custom caption bar fights with Luna.
  277. L"GCCDevL", // install point: http://www.besttechnology.co.jp/download/GDL1_0_3_6.EXE
  278. // 360422: J Zenrin The Real Digital Map Z3(T1):Max/Min/Close buttons are overlapped on classic buttons in title bar.
  279. L"emZmain",
  280. // 364337: Encarta World English Dictionary: Luna system buttons are overlaid on top of app's custom ones when mousing over
  281. L"ewed.exe",
  282. // 343171: Reaktor Realtime Instrument: pressing the close button while themed causes this app to
  283. // spin in a tight loop running at realtime priority, effectively hanging the machine.
  284. // The message loop for this app is extremely timing sensitive, the additional overhead
  285. // introduced by theming alters the timing enough to break this app.
  286. L"Reaktor",
  287. };
  288. if( AsciiScanStringList( pszProcess, _rgszExcludeAppList,
  289. ARRAYSIZE(_rgszExcludeAppList), TRUE ) )
  290. {
  291. return FALSE;
  292. }
  293. #ifdef THEME_CALCSIZE
  294. // Winstone 99 needs modified NC_CALCSIZE behavior for Netscape or it will hang.
  295. if ( 0 == AsciiStrCmpI( pszProcess, L"Netscape" ))
  296. {
  297. if (FindWindowEx(NULL, NULL, L"ZDBench32Frame", NULL) != NULL)
  298. {
  299. _SetMsgHandler( WM_NCCALCSIZE, _rgDwpHandlers, ARRAYSIZE(_rgDwpHandlers),
  300. OnDwpNcCalcSize2, FALSE );
  301. return TRUE;
  302. }
  303. }
  304. #endif THEME_CALCSIZE
  305. //-------------------------
  306. // This AppHack was once fixed, but got broke again with
  307. // addition of logic for partial-screen maximized windows.
  308. //
  309. // Something in our answer to NCCALCSIZE causes quick time player
  310. // to continously flood its 'control' frame window's winproc with
  311. // WM_PAINTS by repeatedly calling InvalidateRgn + UpdateWindow. My
  312. // suspicion is that he looks at what DefWindowProc returns from
  313. // NCCALCSIZE to determine the area he needs to manage, and when
  314. // this doesn't hash with other SYSMET values and/or AdjustWindowRect,
  315. // he redundantly invalidates himself,
  316. //
  317. // This only repros if qtp is launched w/ .mov file, works fine if
  318. // launched without a file and then a file is loaded.
  319. #ifdef THEME_CALCSIZE
  320. if( 0 == AsciiStrCmpI( pszProcess, L"QuickTimePlayer" ))
  321. {
  322. _SetMsgHandler( WM_NCCALCSIZE, _rgDwpHandlers, ARRAYSIZE(_rgDwpHandlers),
  323. OnDwpNcCalcSize2, FALSE );
  324. return TRUE;
  325. }
  326. // SEANHI DID NOT RECEIVE THE S/W FROM APPLIB AND SO WAS UNABLE TO VERIFY THIS
  327. // NO LONGER REPROS W/ ELIMINATION OF THEMED SYSMETS
  328. //-------------------------
  329. // Paradox 9 appHack for nonclient button sizes:
  330. //
  331. // Paradox table schema view uses DrawFrameControl to render both
  332. // a classic toolframe (small) caption and buttons, but uses the
  333. // themed values of SM_CYSIZE instead of SM_CYSMSIZE to size the buttons.
  334. // This apphack redirects requests in this process for SM_CX/YSIZE to SM_CX/YSMSIZE.
  335. if( 0 == AsciiStrCmpI( pszProcess, L"pdxwin32" ) )
  336. {
  337. _SetGsmHandler( SM_CXSIZE, OnGsmCxSmBtnSize );
  338. _SetGsmHandler( SM_CYSIZE, OnGsmCySmBtnSize );
  339. return TRUE;
  340. }
  341. #endif THEME_CALCSIZE
  342. //-------------------------
  343. #else
  344. # pragma message("App hacks disabled")
  345. #endif __NO_APPHACKS__
  346. return TRUE;
  347. }
  348. //---------------------------------------------------------------------------
  349. // Handler table utility functions
  350. //---------------------------------------------------------------------------
  351. //---------------------------------------------------------------------------
  352. void HandlerTableInit() {}
  353. //---------------------------------------------------------------------------
  354. BOOL _InitMsgMask( LPBYTE prgMsgMask, DWORD dwMaskBytes, MSGENTRY* prgEntries, int cEntries,
  355. IN OUT BOOL& fInit )
  356. {
  357. if( !fInit )
  358. {
  359. for( int i = 0; i < cEntries; i++ )
  360. {
  361. if( -1 == prgEntries[i].nMsg )
  362. {
  363. ASSERT(prgEntries[i].pnRegMsg);
  364. // Initialize registered message entry
  365. prgEntries[i].nMsg = *prgEntries[i].pnRegMsg;
  366. Log(LOG_TMHANDLE, L"InitMsgMsg corrected registered msg: 0x%x", prgEntries[i].nMsg);
  367. }
  368. //---- ensure we set up limit on table correctly ----
  369. ASSERT((prgEntries[i].nMsg)/8 < dwMaskBytes);
  370. SET_MSGMASK( prgMsgMask, prgEntries[i].nMsg );
  371. }
  372. fInit = TRUE;
  373. }
  374. return fInit;
  375. }
  376. //---------------------------------------------------------------------------
  377. // Scan of MSG table as linear array:
  378. inline int _FindMsgHandler(
  379. UINT nMsg,
  380. MSGENTRY rgEntries[],
  381. int cEntries,
  382. OUT OPTIONAL HOOKEDMSGHANDLER* ppfnHandler,
  383. OUT OPTIONAL HOOKEDMSGHANDLER* ppfnHandler2 )
  384. {
  385. ASSERT( nMsg );
  386. ASSERT( nMsg != (UINT)-1 );
  387. if( ppfnHandler ) *ppfnHandler = NULL;
  388. if( ppfnHandler2 ) *ppfnHandler2 = NULL;
  389. for( int i = 0; i < cEntries; i++ )
  390. {
  391. if( rgEntries[i].nMsg == nMsg )
  392. {
  393. // If no handler requested, return success
  394. if( NULL == ppfnHandler && NULL == ppfnHandler2 )
  395. return i;
  396. // Assign outbound handler values
  397. if( ppfnHandler ) *ppfnHandler = rgEntries[i].pfnHandler;
  398. if( ppfnHandler2 ) *ppfnHandler2 = rgEntries[i].pfnHandler2;
  399. // return TRUE iif caller got what he asked for.
  400. return ((ppfnHandler && *ppfnHandler) || (ppfnHandler2 && *ppfnHandler2)) ? i : -1;
  401. }
  402. }
  403. return -1;
  404. }
  405. //---------------------------------------------------------------------------
  406. // Modify existing handler
  407. inline BOOL _SetMsgHandler(
  408. UINT nMsg,
  409. MSGENTRY rgEntries[],
  410. int cEntries,
  411. IN HOOKEDMSGHANDLER pfnHandler,
  412. BOOL fHandler2 )
  413. {
  414. int i = _FindMsgHandler( nMsg, rgEntries, cEntries, NULL, NULL );
  415. if( i >= 0 )
  416. {
  417. if( fHandler2 )
  418. rgEntries[i].pfnHandler2 = pfnHandler;
  419. else
  420. rgEntries[i].pfnHandler = pfnHandler;
  421. return TRUE;
  422. }
  423. return FALSE;
  424. }
  425. #define CBMSGMASK(msgHigh) (((msgHigh)+1)/8 + ((((msgHigh)+1) % 8) ? 1: 0))
  426. //---------------------------------------------------------------------------
  427. DWORD GetOwpMsgMask( LPBYTE* prgMsgMask )
  428. {
  429. static BOOL _fOwpMask = FALSE; // initialized?
  430. static BYTE _rgOwpMask[CBMSGMASK(WNDPROC_MSG_LAST)] = {0};
  431. if( _InitMsgMask( _rgOwpMask, ARRAYSIZE(_rgOwpMask), _rgOwpHandlers, ARRAYSIZE(_rgOwpHandlers), _fOwpMask ) )
  432. {
  433. *prgMsgMask = _rgOwpMask;
  434. return ARRAYSIZE(_rgOwpMask);
  435. }
  436. return 0;
  437. }
  438. //---------------------------------------------------------------------------
  439. DWORD GetDdpMsgMask( LPBYTE* prgMsgMask )
  440. {
  441. static BOOL _fDdpMask = FALSE; // initialized?
  442. static BYTE _rgDdpMask[CBMSGMASK(DEFDLGPROC_MSG_LAST)] = {0};
  443. if( _InitMsgMask( _rgDdpMask, ARRAYSIZE(_rgDdpMask), _rgDdpHandlers, ARRAYSIZE(_rgDdpHandlers), _fDdpMask ) )
  444. {
  445. *prgMsgMask = _rgDdpMask;
  446. return ARRAYSIZE(_rgDdpMask);
  447. }
  448. return 0;
  449. }
  450. //---------------------------------------------------------------------------
  451. DWORD GetDwpMsgMask( LPBYTE* prgMsgMask )
  452. {
  453. static BOOL _fDwpMask = FALSE; // initialized?
  454. static BYTE _rgDwpMask[CBMSGMASK(DEFWNDPROC_MSG_LAST)] = {0};
  455. if( _InitMsgMask( _rgDwpMask, ARRAYSIZE(_rgDwpMask), _rgDwpHandlers, ARRAYSIZE(_rgDwpHandlers), _fDwpMask ) )
  456. {
  457. *prgMsgMask = _rgDwpMask;
  458. return ARRAYSIZE(_rgDwpMask);
  459. }
  460. return 0;
  461. }
  462. //---------------------------------------------------------------------------
  463. BOOL FindOwpHandler(
  464. UINT nMsg, HOOKEDMSGHANDLER* ppfnPre, HOOKEDMSGHANDLER* ppfnPost )
  465. {
  466. return _FindMsgHandler( nMsg, _rgOwpHandlers, ARRAYSIZE(_rgOwpHandlers),
  467. ppfnPre, ppfnPost ) >= 0;
  468. }
  469. //---------------------------------------------------------------------------
  470. BOOL FindDdpHandler(
  471. UINT nMsg, HOOKEDMSGHANDLER* ppfnPre, HOOKEDMSGHANDLER* ppfnPost )
  472. {
  473. return _FindMsgHandler( nMsg, _rgDdpHandlers, ARRAYSIZE(_rgDdpHandlers),
  474. ppfnPre, ppfnPost ) >= 0;
  475. }
  476. //---------------------------------------------------------------------------
  477. BOOL FindDwpHandler( UINT nMsg, HOOKEDMSGHANDLER* ppfnPre )
  478. {
  479. HOOKEDMSGHANDLER pfnPost;
  480. return _FindMsgHandler( nMsg, _rgDwpHandlers, ARRAYSIZE(_rgDwpHandlers),
  481. ppfnPre, &pfnPost ) >= 0;
  482. }
  483. //---------------------------------------------------------------------------
  484. // Performs default message processing.
  485. LRESULT WINAPI DoMsgDefault( const THEME_MSG *ptm )
  486. {
  487. ASSERT( ptm );
  488. if( ptm->pfnDefProc )
  489. {
  490. MsgHandled( ptm );
  491. if( MSGTYPE_DEFWNDPROC == ptm->type )
  492. return ptm->pfnDefProc( ptm->hwnd, ptm->uMsg, ptm->wParam, ptm->lParam );
  493. else
  494. {
  495. ASSERT( NULL == ptm->pfnDefProc ); // bad initialization (_InitThemeMsg)
  496. }
  497. }
  498. return 0L;
  499. }