Source code of Windows XP (NT5)
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.

78 lines
2.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000
  6. //
  7. // File: findview.h
  8. //
  9. //--------------------------------------------------------------------------
  10. /*+-------------------------------------------------------------------------*
  11. *
  12. * FindMMCView
  13. *
  14. * PURPOSE: Locates the amcview window that is an ancestor of the specified window.
  15. *
  16. * PARAMETERS:
  17. * HWND hwnd : [in] The window whose ancestor amcview needs to be located
  18. *
  19. * RETURNS:
  20. * inline HWND : The ancestor AmcView window, or NULL if not found
  21. *
  22. *+-------------------------------------------------------------------------*/
  23. inline HWND FindMMCView(HWND hwnd)
  24. {
  25. // Get the childframe handle.
  26. do
  27. {
  28. TCHAR buffer[MAX_PATH];
  29. if (::GetClassName (hwnd, buffer, MAX_PATH))
  30. {
  31. if (!_tcscmp (buffer, g_szChildFrameClassName))
  32. break;
  33. }
  34. } while (hwnd = ::GetParent (hwnd));
  35. // Get the AMCView handle from Childframe handle.
  36. if (hwnd)
  37. hwnd = ::GetDlgItem(hwnd, 0xE900 /*AFX_IDW_PANE_FIRST*/);
  38. return hwnd;
  39. }
  40. /*+-------------------------------------------------------------------------*
  41. *
  42. * FindMMCView
  43. *
  44. * PURPOSE: Same as above, but allows a takes a CComControlBase reference as the input parameters
  45. *
  46. * PARAMETERS:
  47. * CComControlBase& rCtrl :
  48. *
  49. * RETURNS:
  50. * HWND WINAPI
  51. *
  52. *+-------------------------------------------------------------------------*/
  53. HWND inline FindMMCView(CComControlBase& rCtrl)
  54. {
  55. HWND hwnd = NULL;
  56. // Try to get client window from client site or in-place site interfaces
  57. if (rCtrl.m_spInPlaceSite)
  58. {
  59. rCtrl.m_spInPlaceSite->GetWindow(&hwnd);
  60. }
  61. else if (rCtrl.m_spClientSite)
  62. {
  63. CComPtr<IOleWindow> spWindow;
  64. if ( SUCCEEDED(rCtrl.m_spClientSite->QueryInterface(IID_IOleWindow, (void **)&spWindow)) )
  65. {
  66. spWindow->GetWindow(&hwnd);
  67. }
  68. }
  69. return FindMMCView(hwnd);
  70. }