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.

74 lines
1.9 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: apimfc.cpp
  7. //
  8. // Contents:
  9. //
  10. // APIs: MFC specific API in core
  11. //
  12. //____________________________________________________________________________
  13. //
  14. #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
  15. #include <afxwin.h> // MFC core and standard components
  16. #include "..\inc\mmc.h"
  17. LPFNPSPCALLBACK _MMCHookPropertyPage;
  18. HHOOK _MMCmsgHook;
  19. LRESULT CALLBACK _MMCHookCBTProc(int nCode, WPARAM wParam, LPARAM lParam)
  20. {
  21. ASSERT(_MMCmsgHook != 0);
  22. if (nCode < 0)
  23. return CallNextHookEx(_MMCmsgHook, nCode, wParam, lParam);
  24. if (nCode == HCBT_CREATEWND)
  25. {
  26. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  27. CallNextHookEx(_MMCmsgHook, nCode, wParam, lParam);
  28. UnhookWindowsHookEx(_MMCmsgHook);
  29. }
  30. return 0; // Allow the window to be created
  31. }
  32. UINT CALLBACK _MMCHookPropSheetPageProc(HWND hwnd,UINT uMsg,LPPROPSHEETPAGE ppsp)
  33. {
  34. UINT i = _MMCHookPropertyPage(hwnd, uMsg, ppsp);
  35. switch (uMsg)
  36. {
  37. case PSPCB_CREATE:
  38. _MMCmsgHook = SetWindowsHookEx (WH_CBT, _MMCHookCBTProc,
  39. GetModuleHandle(NULL),
  40. GetCurrentThreadId());
  41. break;
  42. }
  43. return i;
  44. }
  45. HRESULT STDAPICALLTYPE MMCPropPageCallback(void* vpsp)
  46. {
  47. if (vpsp == NULL)
  48. return E_POINTER;
  49. LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)vpsp;
  50. if ((void*)psp->pfnCallback == (void*)_MMCHookPropSheetPageProc)
  51. return E_UNEXPECTED;
  52. _MMCHookPropertyPage = psp->pfnCallback;
  53. psp->pfnCallback = _MMCHookPropSheetPageProc;
  54. return S_OK;
  55. }