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.

139 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. BaanIV.cpp
  5. Abstract:
  6. Ignore WM_STYLECHANGED on the app's subclassed listbox. This is needed
  7. because the app subclasses the listbox and Win2k changed a bit the
  8. behavior of the listbox window proc with regards to handling
  9. WM_STYLECHANGED.
  10. Notes:
  11. This is an app specific shim.
  12. History:
  13. 02/16/2000 clupu Created
  14. --*/
  15. #include "precomp.h"
  16. #include <commdlg.h>
  17. IMPLEMENT_SHIM_BEGIN(BaanIV)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(SetWindowLongA)
  21. APIHOOK_ENUM_ENTRY(CallWindowProcA)
  22. APIHOOK_ENUM_END
  23. WNDPROC gpfnOrgListBoxWndProc;
  24. WNDPROC gpfnAppListBoxWndProc;
  25. /*++
  26. Ignore WM_STYLECHANGED.
  27. --*/
  28. LRESULT
  29. Modified_ListBoxWndProcA(
  30. HWND hwnd,
  31. UINT message,
  32. WPARAM wParam,
  33. LPARAM lParam
  34. )
  35. {
  36. if (message == WM_STYLECHANGED) {
  37. return 0;
  38. }
  39. return (*gpfnAppListBoxWndProc)(hwnd, message, wParam, lParam);
  40. }
  41. /*++
  42. When the app calls CallWindowProc passing our modified listbox
  43. proc call the original window proc instead
  44. --*/
  45. LRESULT
  46. APIHOOK(CallWindowProcA)(
  47. WNDPROC pfn,
  48. HWND hwnd,
  49. UINT message,
  50. WPARAM wParam,
  51. LPARAM lParam)
  52. {
  53. if (pfn == Modified_ListBoxWndProcA) {
  54. pfn = gpfnOrgListBoxWndProc;
  55. }
  56. return ORIGINAL_API(CallWindowProcA)(pfn, hwnd, message, wParam, lParam);
  57. }
  58. /*++
  59. When the app subclasses the listbox of a combobox grab the original listbox
  60. proc, grab the pointer that the app is trying to set, set the new pointer to
  61. be our modified version of the listbox proc and return to the app our pointer.
  62. --*/
  63. ULONG_PTR
  64. APIHOOK(SetWindowLongA)(
  65. HWND hwnd,
  66. int nIndex,
  67. ULONG_PTR newLong
  68. )
  69. {
  70. if (nIndex == GWLP_WNDPROC) {
  71. WNDCLASSA wndClass;
  72. WNDPROC pfnOrg;
  73. GetClassInfoA((HINSTANCE)GetWindowLong(hwnd, GWLP_HINSTANCE),
  74. "ComboLBox",
  75. &wndClass);
  76. pfnOrg = (WNDPROC)GetWindowLong(hwnd, GWLP_WNDPROC);
  77. if (pfnOrg == wndClass.lpfnWndProc) {
  78. gpfnOrgListBoxWndProc = pfnOrg;
  79. DPFN( eDbgLevelInfo, "Fix up subclassing of ComboLBox");
  80. gpfnAppListBoxWndProc = (WNDPROC)newLong;
  81. newLong = (ULONG_PTR)Modified_ListBoxWndProcA;
  82. ORIGINAL_API(SetWindowLongA)(hwnd, nIndex, newLong);
  83. return newLong;
  84. }
  85. }
  86. // Call the Initial function
  87. return ORIGINAL_API(SetWindowLongA)(hwnd, nIndex, newLong);
  88. }
  89. /*++
  90. Register hooked functions
  91. --*/
  92. HOOK_BEGIN
  93. APIHOOK_ENTRY(USER32.DLL, SetWindowLongA)
  94. APIHOOK_ENTRY(USER32.DLL, CallWindowProcA)
  95. HOOK_END
  96. IMPLEMENT_SHIM_END