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.

142 lines
3.6 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Behav_CONTEXT.cpp
  5. Abstract:
  6. This file contains the implementation of the CPCHBehavior_CONTEXT class,
  7. that dictates how hyperlinks work in the help center.
  8. Revision History:
  9. Davide Massarenti (dmassare) 06/06/2000
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. #include <ShellApi.h>
  14. ////////////////////////////////////////////////////////////////////////////////
  15. STDMETHODIMP CPCHBehavior_CONTEXT::Init( /*[in]*/ IElementBehaviorSite* pBehaviorSite )
  16. {
  17. __HCP_FUNC_ENTRY( "CPCHBehavior_CONTEXT::Init" );
  18. HRESULT hr;
  19. CComBSTR bstrCtxName;
  20. CComVariant vCtxInfo;
  21. CComVariant vCtxURL;
  22. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHBehavior::Init( pBehaviorSite ));
  23. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::COMUtil::GetPropertyByName( m_elem, L"contextName", bstrCtxName ));
  24. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::COMUtil::GetPropertyByName( m_elem, L"contextInfo", vCtxInfo ));
  25. if(bstrCtxName.Length())
  26. {
  27. __MPC_EXIT_IF_METHOD_FAILS(hr, changeContext( bstrCtxName, vCtxInfo, vCtxURL ));
  28. }
  29. hr = S_OK;
  30. __HCP_FUNC_CLEANUP;
  31. __HCP_FUNC_EXIT(hr);
  32. }
  33. ////////////////////////////////////////////////////////////////////////////////
  34. STDMETHODIMP CPCHBehavior_CONTEXT::get_minimized( /*[out, retval]*/ VARIANT_BOOL *pVal )
  35. {
  36. IMarsWindowOM* win = m_parent->Shell();
  37. return win ? win->get_minimized( pVal ) : E_FAIL;
  38. }
  39. STDMETHODIMP CPCHBehavior_CONTEXT::put_minimized( /*[in]*/ VARIANT_BOOL newVal )
  40. {
  41. IMarsWindowOM* win = m_parent->Shell();
  42. return win ? win->put_minimized( newVal ) : E_FAIL;
  43. }
  44. STDMETHODIMP CPCHBehavior_CONTEXT::get_maximized( /*[out, retval]*/ VARIANT_BOOL *pVal )
  45. {
  46. IMarsWindowOM* win = m_parent->Shell();
  47. return win ? win->get_maximized( pVal ) : E_FAIL;
  48. }
  49. STDMETHODIMP CPCHBehavior_CONTEXT::put_maximized( /*[in]*/ VARIANT_BOOL newVal )
  50. {
  51. IMarsWindowOM* win = m_parent->Shell();
  52. return win ? win->put_maximized( newVal ) : E_FAIL;
  53. }
  54. ////////////////////
  55. STDMETHODIMP CPCHBehavior_CONTEXT::get_x( /*[out, retval]*/ long *pVal )
  56. {
  57. IMarsWindowOM* win = m_parent->Shell();
  58. return win ? win->get_x( pVal ) : E_FAIL;
  59. }
  60. STDMETHODIMP CPCHBehavior_CONTEXT::get_y( /*[out, retval]*/ long *pVal )
  61. {
  62. IMarsWindowOM* win = m_parent->Shell();
  63. return win ? win->get_y( pVal ) : E_FAIL;
  64. }
  65. STDMETHODIMP CPCHBehavior_CONTEXT::get_width( /*[out, retval]*/ long *pVal )
  66. {
  67. IMarsWindowOM* win = m_parent->Shell();
  68. return win ? win->get_width( pVal ) : E_FAIL;
  69. }
  70. STDMETHODIMP CPCHBehavior_CONTEXT::get_height( /*[out, retval]*/ long *pVal )
  71. {
  72. IMarsWindowOM* win = m_parent->Shell();
  73. return win ? win->get_height( pVal ) : E_FAIL;
  74. }
  75. ////////////////////
  76. STDMETHODIMP CPCHBehavior_CONTEXT::changeContext( /*[in]*/ BSTR bstrName, /*[in]*/ VARIANT vInfo, /*[in]*/ VARIANT vURL )
  77. {
  78. CPCHHelpSession* hs = m_parent->HelpSession();
  79. return hs ? hs->ChangeContext( bstrName, vInfo, vURL ) : E_FAIL;
  80. }
  81. STDMETHODIMP CPCHBehavior_CONTEXT::setWindowDimensions( /*[in]*/ long lX, /*[in]*/ long lY, /*[in]*/ long lW, /*[in]*/ long lH )
  82. {
  83. IMarsWindowOM* win = m_parent->Shell();
  84. VARIANT_BOOL fMax = VARIANT_FALSE;
  85. if(win == NULL) return E_FAIL;
  86. win->get_maximized( &fMax );
  87. if(fMax != VARIANT_FALSE)
  88. {
  89. win->put_maximized( VARIANT_FALSE );
  90. }
  91. return win->setWindowDimensions( lX, lY, lW, lH );
  92. }
  93. STDMETHODIMP CPCHBehavior_CONTEXT::bringToForeground()
  94. {
  95. ::SetForegroundWindow( m_parent->Window() );
  96. return S_OK;
  97. }