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.

151 lines
3.8 KiB

  1. /******************************************************************************
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Toolbar.cpp
  5. Abstract:
  6. This file contains the ActiveX control that makes Win32 ProgressBars available to HTML.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 03/04/2001
  9. created
  10. ******************************************************************************/
  11. #include "stdafx.h"
  12. #include <comctrlp.h>
  13. ////////////////////////////////////////////////////////////////////////////////
  14. CPCHProgressBar::CPCHProgressBar()
  15. {
  16. m_bWindowOnly = TRUE; // Inherited from CComControlBase
  17. m_hwndPB = NULL; // HWND m_hwndPB;
  18. //
  19. m_lLowLimit = 0; // long m_lLowLimit;
  20. m_lHighLimit = 100; // long m_lHighLimit;
  21. m_lPos = 0; // long m_lPos;
  22. }
  23. /////////////////////////////////////////////////////////////////////////////
  24. BOOL CPCHProgressBar::ProcessWindowMessage( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID )
  25. {
  26. lResult = 0;
  27. switch(uMsg)
  28. {
  29. case WM_CREATE:
  30. {
  31. CComPtr<IServiceProvider> sp;
  32. CComPtr<IHTMLDocument3> doc3;
  33. CComBSTR bstrDir;
  34. DWORD dwStyleEx = 0;
  35. if(SUCCEEDED(m_spAmbientDispatch->QueryInterface( IID_IServiceProvider , (void**)&sp )) &&
  36. SUCCEEDED(sp->QueryService ( SID_SContainerDispatch, IID_IHTMLDocument3, (void**)&doc3 )) &&
  37. SUCCEEDED(doc3->get_dir ( &bstrDir )) )
  38. {
  39. if(MPC::StrICmp( bstrDir, L"RTL" ) == 0)
  40. {
  41. dwStyleEx = WS_EX_LAYOUTRTL;
  42. }
  43. }
  44. m_hwndPB = ::CreateWindowExW( dwStyleEx, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, m_hWnd, NULL, NULL, NULL );
  45. if(m_hwndPB)
  46. {
  47. // Set the range and increment of the progress bar.
  48. ::SendMessage( m_hwndPB, PBM_SETRANGE32, m_lLowLimit, m_lHighLimit );
  49. ::SendMessage( m_hwndPB, PBM_SETPOS , m_lPos , 0 );
  50. }
  51. }
  52. return TRUE;
  53. case WM_SIZE:
  54. if(m_hwndPB)
  55. {
  56. int nWidth = LOWORD(lParam); // width of client area
  57. int nHeight = HIWORD(lParam); // height of client area
  58. ::SetWindowPos( m_hwndPB, NULL, 0, 0, nWidth, nHeight, SWP_NOZORDER|SWP_NOACTIVATE );
  59. }
  60. return TRUE;
  61. case WM_DESTROY:
  62. m_hwndPB = NULL;
  63. return TRUE;
  64. }
  65. return CComControl<CPCHProgressBar>::ProcessWindowMessage( hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID );
  66. }
  67. ////////////////////////////////////////////////////////////////////////////////
  68. ////////////////////////////////////////////////////////////////////////////////
  69. STDMETHODIMP CPCHProgressBar::get_LowLimit( /*[out, retval]*/ long *pVal )
  70. {
  71. if(pVal) *pVal = m_lLowLimit;
  72. return S_OK;
  73. }
  74. STDMETHODIMP CPCHProgressBar::put_LowLimit( /*[in]*/ long newVal )
  75. {
  76. m_lLowLimit = newVal;
  77. if(m_hwndPB)
  78. {
  79. ::SendMessage( m_hwndPB, PBM_SETRANGE32, m_lLowLimit, m_lHighLimit );
  80. }
  81. return S_OK;
  82. }
  83. STDMETHODIMP CPCHProgressBar::get_HighLimit( /*[out, retval]*/ long *pVal )
  84. {
  85. if(pVal) *pVal = m_lHighLimit;
  86. return S_OK;
  87. }
  88. STDMETHODIMP CPCHProgressBar::put_HighLimit( /*[in]*/ long newVal )
  89. {
  90. m_lHighLimit = newVal;
  91. if(m_hwndPB)
  92. {
  93. ::SendMessage( m_hwndPB, PBM_SETRANGE32, m_lLowLimit, m_lHighLimit );
  94. }
  95. return S_OK;
  96. }
  97. STDMETHODIMP CPCHProgressBar::get_Pos( /*[out, retval]*/ long *pVal )
  98. {
  99. if(pVal) *pVal = m_lPos;
  100. return S_OK;
  101. }
  102. STDMETHODIMP CPCHProgressBar::put_Pos( /*[in]*/ long newVal )
  103. {
  104. m_lPos = newVal;
  105. if(m_hwndPB)
  106. {
  107. ::SendMessage( m_hwndPB, PBM_SETPOS, m_lPos, 0 );
  108. }
  109. return S_OK;
  110. }