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.

184 lines
4.2 KiB

  1. #include "sol.h"
  2. VSZASSERT
  3. #define dyStatMarg 1
  4. #define dxStatMarg 4
  5. static TCHAR szStatClass[] = TEXT("Stat"); // class name
  6. HWND hwndStat = NULL; // window to status area
  7. static INT dyStat; // height of status window
  8. BOOL FRegisterStat(BOOL fFirstInst)
  9. {
  10. WNDCLASS cls;
  11. LRESULT APIENTRY StatWndProc(HWND, UINT, WPARAM, LPARAM );
  12. /* ?? can I use static class? */
  13. if(fFirstInst)
  14. {
  15. cls.style = 0,
  16. cls.lpfnWndProc = StatWndProc;
  17. cls.cbClsExtra = cls.cbWndExtra = 0;
  18. cls.hInstance = hinstApp;
  19. cls.hIcon = NULL;
  20. cls.hCursor = LoadCursor(NULL, IDC_ARROW);
  21. cls.hbrBackground = GetStockObject(WHITE_BRUSH);
  22. cls.lpszMenuName = NULL;
  23. cls.lpszClassName = (LPTSTR)szStatClass;
  24. if (!RegisterClass((LPWNDCLASS)&cls))
  25. return(fFalse);
  26. }
  27. return fTrue;
  28. }
  29. BOOL FCreateStat()
  30. {
  31. RC rc;
  32. dyStat = dyChar+2*dyStatMarg;
  33. GetClientRect(hwndApp, (LPRECT) &rc);
  34. hwndStat = CreateWindow((LPTSTR) szStatClass, TEXT(""),
  35. WS_BORDER|WS_CHILD|CS_HREDRAW|CS_VREDRAW,
  36. rc.xLeft-1, rc.yBot-dyStat+1, rc.xRight-rc.xLeft+2, dyStat, hwndApp,
  37. NULL, hinstApp, NULL);
  38. ShowWindow(hwndStat, SW_SHOWNOACTIVATE);
  39. UpdateWindow(hwndStat);
  40. return fTrue;
  41. }
  42. BOOL FDestroyStat()
  43. {
  44. if(hwndStat)
  45. {
  46. DestroyWindow(hwndStat);
  47. hwndStat = NULL;
  48. }
  49. return fTrue;
  50. }
  51. LRESULT APIENTRY StatWndProc(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  52. {
  53. PAINTSTRUCT paint;
  54. HDC hdc;
  55. VOID StatRender();
  56. switch(wm)
  57. {
  58. case WM_PAINT:
  59. BeginPaint(hwnd, (LPPAINTSTRUCT) &paint);
  60. hdc = HdcSet(paint.hdc, 0, 0);
  61. StatRender();
  62. HdcSet(hdc, 0, 0);
  63. EndPaint(hwnd, (LPPAINTSTRUCT) &paint);
  64. return(0L);
  65. }
  66. return(DefWindowProc(hwnd, wm, wParam, lParam));
  67. }
  68. VOID StatRender()
  69. {
  70. RC rc;
  71. if(pgmCur != NULL && hwndStat != NULL)
  72. {
  73. GetClientRect(hwndStat, (LPRECT) &rc);
  74. rc.xRight -= dxStatMarg;
  75. SendGmMsg(pgmCur, msggDrawStatus, (INT_PTR) &rc, 0);
  76. }
  77. }
  78. VOID StatUpdate()
  79. {
  80. HDC hdc;
  81. HDC hdcSav;
  82. if(hwndStat == NULL)
  83. return;
  84. if((hdc = GetDC(hwndStat)) != NULL)
  85. {
  86. hdcSav = HdcSet(hdc, 0, 0);
  87. StatRender();
  88. HdcSet(hdcSav, 0, 0);
  89. ReleaseDC(hwndStat, hdc);
  90. }
  91. }
  92. VOID StatMove()
  93. {
  94. RC rc;
  95. if(hwndStat != NULL)
  96. {
  97. GetClientRect(hwndApp, (LPRECT) &rc);
  98. MoveWindow(hwndStat, rc.xLeft-1, rc.yBot-dyStat+1, rc.xRight-rc.xLeft+2, dyStat, fTrue);
  99. InvalidateRect(hwndStat, NULL, fTrue);
  100. }
  101. }
  102. VOID StatStringSz(TCHAR *sz)
  103. {
  104. HDC hdc, hdcSav;
  105. RC rc;
  106. HFONT hFontOld = NULL;
  107. HFONT hStatusFont = NULL;
  108. if(hwndStat == NULL)
  109. return;
  110. hdc = GetDC(hwndStat);
  111. if(hdc == NULL)
  112. return;
  113. // store the old font and replace the status font by MS Shell Dlg
  114. // as it supports FE characters as well as euro characters.
  115. hStatusFont = CreateFont(-MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, 0, 0, FW_BOLD, 0, 0, 0,
  116. DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  117. DEFAULT_PITCH, TEXT("MS Shell Dlg"));
  118. if (hStatusFont)
  119. hFontOld = SelectObject(hdc, hStatusFont);
  120. hdcSav = HdcSet(hdc, 0, 0);
  121. GetClientRect(hwndStat, (LPRECT) &rc);
  122. PatBlt(hdcCur, rc.xLeft, rc.yTop, rc.xRight-rc.xLeft, rc.yBot-rc.yTop, PATCOPY);
  123. TextOut(hdcCur, dxStatMarg, 0, sz, lstrlen(sz));
  124. StatRender();
  125. // restore the font
  126. if (hFontOld)
  127. SelectObject(hdcCur, hFontOld);
  128. // close the created font handle
  129. if (hStatusFont)
  130. DeleteObject(hStatusFont);
  131. HdcSet(hdcSav, 0, 0);
  132. ReleaseDC(hwndStat, hdc);
  133. }
  134. VOID StatString(INT ids)
  135. {
  136. TCHAR sz[60];
  137. if(ids != idsNil)
  138. CchString(sz, ids, ARRAYSIZE(sz));
  139. else
  140. sz[0] = TEXT('\000');
  141. StatStringSz(sz);
  142. }