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.

134 lines
2.6 KiB

  1. //
  2. // Microsoft Windows Media Technologies
  3. // Copyright (C) Microsoft Corporation, 1999 - 2001. All rights reserved.
  4. //
  5. //
  6. // This workspace contains two projects -
  7. // 1. ProgHelp which implements the Progress Interface
  8. // 2. The Sample application WmdmApp.
  9. //
  10. // ProgHelp.dll needs to be registered first for the SampleApp to run.
  11. // Includes
  12. //
  13. #include "appPCH.h"
  14. /////////////////////////////////////////////////////////////////////
  15. //
  16. // Function implementations
  17. //
  18. CStatus::CStatus (void )
  19. {
  20. m_hwndStatusBar = NULL;
  21. }
  22. CStatus::~CStatus (void )
  23. {
  24. m_hwndStatusBar = NULL;
  25. }
  26. HWND CStatus::GetHwnd( void )
  27. {
  28. return m_hwndStatusBar;
  29. }
  30. BOOL CStatus::Create( HWND hwndParent )
  31. {
  32. BOOL fRet = FALSE;
  33. // Create the statusbar window
  34. //
  35. m_hwndStatusBar = CreateWindow(
  36. STATUSCLASSNAME,
  37. "",
  38. WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
  39. 0, 0, 0, 0,
  40. hwndParent, NULL, g_hInst, NULL
  41. );
  42. ExitOnNull( m_hwndStatusBar );
  43. // Show the window
  44. //
  45. ShowWindow( m_hwndStatusBar, SW_SHOW );
  46. fRet = TRUE;
  47. lExit:
  48. return fRet;
  49. }
  50. VOID CStatus::OnSize( LPRECT prcMain )
  51. {
  52. INT anWidth[SB_NUM_PANES];
  53. DWORD dwW = prcMain->right - prcMain->left;
  54. RECT rcMain;
  55. RECT rcDevice;
  56. GetWindowRect( g_hwndMain, &rcMain );
  57. GetWindowRect( g_cDevices.GetHwnd(), &rcDevice );
  58. anWidth[0] = (INT) ( rcDevice.right - rcMain.left -7 );
  59. anWidth[1] = anWidth[0] + (INT) ( dwW - anWidth[0] ) / 3;
  60. anWidth[2] = anWidth[1] + (INT) ( dwW - anWidth[0] ) / 3;
  61. anWidth[3] = -1;
  62. SendMessage( m_hwndStatusBar, SB_SETPARTS, (WPARAM)SB_NUM_PANES, (LPARAM)anWidth );
  63. SendMessage( m_hwndStatusBar, WM_SIZE, (WPARAM)0, (LPARAM)0 );
  64. SetWindowPos( m_hwndStatusBar, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
  65. }
  66. VOID CStatus::SetTextSz( INT nPane, LPSTR lpsz )
  67. {
  68. WPARAM wParam = (WPARAM) (nPane | 0L);
  69. LPARAM lParam = (LPARAM) lpsz;
  70. if( m_hwndStatusBar )
  71. {
  72. SendMessage( m_hwndStatusBar, SB_SETTEXT, wParam, lParam );
  73. }
  74. }
  75. VOID CStatus::SetTextFormatted( INT nPane, UINT uStrID, INT nData, LPSTR pszData )
  76. {
  77. char szFormat[MAX_PATH];
  78. if( 0 == uStrID )
  79. {
  80. uStrID = IDS_STATUS_EMPTY; // use default
  81. }
  82. LoadString( g_hInst, uStrID, szFormat, sizeof(szFormat) );
  83. if( -1 == nData && NULL == pszData )
  84. {
  85. g_cStatus.SetTextSz( nPane, szFormat );
  86. }
  87. else
  88. {
  89. CHAR sz[MAX_PATH];
  90. HRESULT hr;
  91. if( -1 == nData )
  92. {
  93. hr = StringCbPrintf( sz, sizeof(sz), szFormat, pszData );
  94. }
  95. else
  96. {
  97. hr = StringCbPrintf( sz, sizeof(sz), szFormat, nData );
  98. }
  99. if (SUCCEEDED(hr))
  100. {
  101. g_cStatus.SetTextSz( nPane, sz );
  102. }
  103. }
  104. }