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.

177 lines
5.8 KiB

  1. //��������������������������������������������������������������������������Ŀ
  2. //� Includes �
  3. //����������������������������������������������������������������������������
  4. #include "perfmon.h"
  5. #include <commctrl.h>
  6. #include "toolbar.h"
  7. #include "status.h" // for StatusLine & StatusLineReady
  8. #ifdef ADVANCED_PERFMON
  9. TBBUTTON tbButtons[] = {
  10. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  11. { 0, IDM_VIEWCHART, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0 },
  12. { 1, IDM_VIEWALERT, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0 },
  13. { 2, IDM_VIEWLOG, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0 },
  14. { 3, IDM_VIEWREPORT, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0 },
  15. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  16. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  17. { 4, IDM_TOOLBARADD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  18. { 5, IDM_TOOLBARMODIFY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  19. { 6, IDM_TOOLBARDELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  20. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  21. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  22. { 7, IDM_TOOLBARREFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  23. { 8, IDM_OPTIONSBOOKMARK, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  24. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  25. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  26. { 9, IDM_TOOLBAROPTIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  27. } ;
  28. #else
  29. TBBUTTON tbButtons[] = {
  30. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  31. { 4, IDM_TOOLBARADD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  32. { 5, IDM_TOOLBARMODIFY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  33. { 6, IDM_TOOLBARDELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  34. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  35. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  36. { 7, IDM_TOOLBARREFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  37. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  38. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
  39. { 9, IDM_TOOLBAROPTIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
  40. } ;
  41. #endif
  42. #define TB_ENTRIES sizeof(tbButtons)/sizeof(tbButtons[0])
  43. BOOL CreateToolbarWnd (HWND hWnd)
  44. {
  45. hWndToolbar = CreateToolbarEx (hWnd,
  46. WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS,
  47. IDM_TOOLBARID,
  48. 10, // number of tools inside the bitmap
  49. hInstance,
  50. idBitmapToolbar, // bitmap resource ID (can't use MAKEINTRESOURCE)
  51. tbButtons,
  52. TB_ENTRIES,0,0,0,0,sizeof(TBBUTTON)) ;
  53. return (hWndToolbar ? TRUE : FALSE) ;
  54. } // ToolbarInitializeApplication
  55. void ToolbarEnableButton (HWND hWndTB, int iButtonNum, BOOL bEnable)
  56. {
  57. SendMessage (hWndTB, TB_ENABLEBUTTON, iButtonNum, (LONG)bEnable) ;
  58. } // ToolbarEnableButton
  59. void ToolbarDepressButton (HWND hWndTB, int iButtonNum, BOOL bDepress)
  60. {
  61. if (iButtonNum >= IDM_TOOLBARADD && iButtonNum <= IDM_TOOLBARBOOKMARK)
  62. {
  63. // these buttons are push button and will not stay down after
  64. // each hit
  65. SendMessage (hWndTB, TB_PRESSBUTTON, iButtonNum, (LONG)bDepress) ;
  66. }
  67. else
  68. {
  69. // for the four view buttons, have to use CHECKBUTTON so they
  70. // will stay down after selected.
  71. SendMessage (hWndTB, TB_CHECKBUTTON, iButtonNum, (LONG)bDepress) ;
  72. }
  73. } // ToolbarDepressButton
  74. void OnToolbarHit (WPARAM wParam, LPARAM lParam)
  75. {
  76. WORD ToolbarHit ;
  77. if (HIWORD(wParam) == TBN_ENDDRAG)
  78. {
  79. StatusLineReady (hWndStatus) ;
  80. }
  81. else if (HIWORD(wParam) == TBN_BEGINDRAG)
  82. {
  83. ToolbarHit = LOWORD (lParam) ;
  84. if (ToolbarHit >= IDM_TOOLBARADD &&
  85. ToolbarHit <= IDM_TOOLBARDELETE)
  86. {
  87. ToolbarHit -= IDM_TOOLBARADD ;
  88. switch (iPerfmonView)
  89. {
  90. case IDM_VIEWALERT:
  91. ToolbarHit += IDM_EDITADDALERT ;
  92. break ;
  93. case IDM_VIEWLOG:
  94. ToolbarHit += IDM_EDITADDLOG ;
  95. break ;
  96. case IDM_VIEWREPORT:
  97. ToolbarHit += IDM_EDITADDREPORT ;
  98. break ;
  99. case IDM_VIEWCHART:
  100. default:
  101. ToolbarHit += IDM_EDITADDCHART ;
  102. break ;
  103. }
  104. }
  105. else if (ToolbarHit == IDM_TOOLBARBOOKMARK)
  106. {
  107. ToolbarHit = IDM_OPTIONSBOOKMARK ;
  108. }
  109. else if (ToolbarHit == IDM_TOOLBARREFRESH)
  110. {
  111. switch (iPerfmonView)
  112. {
  113. case IDM_VIEWALERT:
  114. ToolbarHit = IDM_OPTIONSREFRESHNOWALERT ;
  115. break ;
  116. case IDM_VIEWLOG:
  117. ToolbarHit = IDM_OPTIONSREFRESHNOWLOG ;
  118. break ;
  119. case IDM_VIEWREPORT:
  120. ToolbarHit = IDM_OPTIONSREFRESHNOWREPORT ;
  121. break ;
  122. case IDM_VIEWCHART:
  123. default:
  124. ToolbarHit = IDM_OPTIONSREFRESHNOWCHART ;
  125. break ;
  126. }
  127. }
  128. else if (ToolbarHit == IDM_TOOLBAROPTIONS)
  129. {
  130. switch (iPerfmonView)
  131. {
  132. case IDM_VIEWALERT:
  133. ToolbarHit = IDM_OPTIONSALERT ;
  134. break ;
  135. case IDM_VIEWLOG:
  136. ToolbarHit = IDM_OPTIONSLOG ;
  137. break ;
  138. case IDM_VIEWREPORT:
  139. ToolbarHit = IDM_OPTIONSREPORT ;
  140. break ;
  141. case IDM_VIEWCHART:
  142. default:
  143. ToolbarHit = IDM_OPTIONSCHART ;
  144. break ;
  145. }
  146. }
  147. StatusLine (hWndStatus, ToolbarHit) ;
  148. }
  149. } // OnToolBarHit
  150. 
  151.