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.

255 lines
6.3 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. rstrprog.cpp
  5. Abstract:
  6. This file contains the implementation of the CRstrProgress class, which
  7. wraps Progress Bar control from the Common Control.
  8. Revision History:
  9. Seong Kook Khang (SKKhang) 10/08/99
  10. created
  11. ******************************************************************************/
  12. #include "stdwin.h"
  13. #include "stdatl.h"
  14. #include "resource.h"
  15. #include "rstrpriv.h"
  16. #include "srui_htm.h"
  17. #include "rstrprog.h"
  18. #ifndef WS_EX_LAYOUTRTL
  19. #define WS_EX_NOINHERITLAYOUT 0x00100000L // Disable inheritence of mirroring by children
  20. #define WS_EX_LAYOUTRTL 0x00400000L // Right to left mirroring
  21. #endif /* WS_EX_LAYOUTRTL */
  22. /////////////////////////////////////////////////////////////////////////////
  23. //
  24. // CRstrProgress
  25. //
  26. /////////////////////////////////////////////////////////////////////////////
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CRstrProgress message handlers
  29. LRESULT
  30. CRstrProgress::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  31. {
  32. TraceFunctEnter("CRstrProgress::OnSetFocus");
  33. LRESULT lRes = CComControl<CRstrProgress>::OnSetFocus(uMsg, wParam, lParam, bHandled);
  34. if (m_bInPlaceActive)
  35. {
  36. DoVerbUIActivate(&m_rcPos, NULL);
  37. if(!IsChild(::GetFocus()))
  38. m_cCtrl.SetFocus();
  39. }
  40. TraceFunctLeave();
  41. return lRes;
  42. }
  43. LRESULT
  44. CRstrProgress::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  45. {
  46. TraceFunctEnter("CRstrProgress::OnCreate");
  47. RECT rc;
  48. WORD wLangId ;
  49. GetWindowRect(&rc);
  50. rc.right -= rc.left;
  51. rc.bottom -= rc.top;
  52. rc.top = rc.left = 0;
  53. //
  54. // Based on language change method of creating the progress bar
  55. //
  56. wLangId = GetDefaultUILang();
  57. if ( PRIMARYLANGID(wLangId) == LANG_ARABIC ||
  58. PRIMARYLANGID(wLangId) == LANG_HEBREW )
  59. {
  60. m_cCtrl.Create(m_hWnd, rc, NULL,
  61. WS_BORDER | WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
  62. WS_EX_LAYOUTRTL, IDC_PROGRESS);
  63. }
  64. else
  65. {
  66. m_cCtrl.Create(m_hWnd, rc, NULL,
  67. WS_BORDER | WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
  68. 0, IDC_PROGRESS);
  69. };
  70. Fire_OnCreate();
  71. TraceFunctLeave();
  72. return 0;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CRstrProgress - IOleInPlaceObject methods
  76. STDMETHODIMP
  77. CRstrProgress::SetObjectRects( LPCRECT prcPos, LPCRECT prcClip )
  78. {
  79. TraceFunctEnter("CRstrProgress::SetObjectRects");
  80. IOleInPlaceObjectWindowlessImpl<CRstrProgress>::SetObjectRects(prcPos, prcClip);
  81. int cx, cy;
  82. cx = prcPos->right - prcPos->left;
  83. cy = prcPos->bottom - prcPos->top;
  84. ::SetWindowPos(m_cCtrl.m_hWnd, NULL, 0,
  85. 0, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE);
  86. TraceFunctLeave();
  87. return S_OK;
  88. }
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CRstrProgress - IRstrProgress properties
  91. STDMETHODIMP
  92. CRstrProgress::get_hWnd( OLE_HANDLE *phWnd )
  93. {
  94. TraceFunctEnter("CRstrProgress::get_hWnd");
  95. HRESULT hr = S_OK;
  96. VALIDATE_INPUT_ARGUMENT(phWnd);
  97. *phWnd = (OLE_HANDLE)m_cCtrl.m_hWnd;
  98. Exit:
  99. TraceFunctLeave();
  100. return( hr );
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. STDMETHODIMP
  104. CRstrProgress::put_Max( long lMax )
  105. {
  106. TraceFunctEnter("CRstrProgress::put_Max");
  107. long lMin = m_cCtrl.SendMessage( PBM_GETRANGE, TRUE, NULL );
  108. m_cCtrl.SendMessage( PBM_SETRANGE32, lMin, lMax );
  109. TraceFunctLeave();
  110. return( S_OK );
  111. }
  112. STDMETHODIMP
  113. CRstrProgress::get_Max( long *plMax )
  114. {
  115. TraceFunctEnter("CRstrProgress::get_Max");
  116. HRESULT hr = S_OK;
  117. VALIDATE_INPUT_ARGUMENT(plMax);
  118. *plMax = m_cCtrl.SendMessage( PBM_GETRANGE, FALSE, NULL );
  119. Exit:
  120. TraceFunctLeave();
  121. return( hr );
  122. }
  123. /////////////////////////////////////////////////////////////////////////////
  124. STDMETHODIMP
  125. CRstrProgress::put_Min( long lMin )
  126. {
  127. TraceFunctEnter("CRstrProgress::put_Min");
  128. long lMax = m_cCtrl.SendMessage( PBM_GETRANGE, FALSE, NULL );
  129. m_cCtrl.SendMessage( PBM_SETRANGE32, lMin, lMax );
  130. TraceFunctLeave();
  131. return( S_OK );
  132. }
  133. STDMETHODIMP
  134. CRstrProgress::get_Min( long *plMin )
  135. {
  136. TraceFunctEnter("CRstrProgress::get_Min");
  137. HRESULT hr = S_OK;
  138. VALIDATE_INPUT_ARGUMENT(plMin);
  139. *plMin = m_cCtrl.SendMessage( PBM_GETRANGE, TRUE, NULL );
  140. Exit:
  141. TraceFunctLeave();
  142. return( hr );
  143. }
  144. /////////////////////////////////////////////////////////////////////////////
  145. STDMETHODIMP
  146. CRstrProgress::put_Value( long lValue )
  147. {
  148. TraceFunctEnter("CRstrProgress::put_Value");
  149. m_cCtrl.SendMessage( PBM_SETPOS, lValue, 0 );
  150. TraceFunctLeave();
  151. return( S_OK );
  152. }
  153. STDMETHODIMP
  154. CRstrProgress::get_Value( long *plValue )
  155. {
  156. TraceFunctEnter("CRstrProgress::get_Value");
  157. HRESULT hr = S_OK;
  158. VALIDATE_INPUT_ARGUMENT(plValue);
  159. *plValue = m_cCtrl.SendMessage( PBM_GETPOS, 0, 0 );
  160. Exit:
  161. TraceFunctLeave();
  162. return( hr );
  163. }
  164. /////////////////////////////////////////////////////////////////////////////
  165. // CRstrProgress - IRstrProgress methods
  166. /////////////////////////////////////////////////////////////////////////////
  167. // CRstrProgress - DRstrProgressEvents firing methods
  168. STDMETHODIMP
  169. CRstrProgress::Fire_OnCreate()
  170. {
  171. TraceFunctEnter("CRstrProgress::Fire_OnCreate");
  172. HRESULT hr = S_OK ;
  173. CComPtr<IDispatch> pDispatch;
  174. DISPPARAMS dpArgs = { NULL, NULL, 0, 0 };
  175. Lock();
  176. IUnknown **ppUnk = m_vec.begin();
  177. while ( ppUnk < m_vec.end() )
  178. {
  179. if ( *ppUnk != NULL )
  180. {
  181. pDispatch = reinterpret_cast<IDispatch*>(*ppUnk);
  182. hr = pDispatch->Invoke( 1, // DISPID_DRSTRCALENDAREVENTS_ONCREATE
  183. IID_NULL,
  184. LOCALE_USER_DEFAULT,
  185. DISPATCH_METHOD,
  186. &dpArgs,
  187. NULL,
  188. NULL,
  189. NULL );
  190. DebugTrace(TRACE_ID, "Invoke returned %d", hr);
  191. }
  192. ppUnk++;
  193. }
  194. Unlock();
  195. TraceFunctLeave();
  196. return( hr );
  197. }
  198. // end of file