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.

155 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. toolbar.cpp
  5. Abstract:
  6. This module implements the toolbar functions for the fax queue viewer
  7. Environment:
  8. WIN32 User Mode
  9. Author:
  10. Andrew Ritz (andrewr) 14-jan-1998
  11. Steven Kehrli (steveke) 30-oct-1998 - major rewrite
  12. --*/
  13. #ifdef TOOLBAR_ENABLED
  14. #include "faxqueue.h"
  15. #define NUMIMAGES 5
  16. #define IMAGEWIDTH 22
  17. #define IMAGEHEIGHT 24
  18. #define BUTTONWIDTH 22
  19. #define BUTTONHEIGHT 24
  20. TBBUTTON ToolBarButton[] =
  21. {
  22. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  23. // {0, IDM_FAX_PAUSE_FAXING, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  24. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  25. // {0, IDM_FAX_CANCEL_ALL_FAXES, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  26. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  27. {1, IDM_DOCUMENT_PAUSE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  28. {2, IDM_DOCUMENT_RESUME, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  29. // {0, IDM_DOCUMENT_RESTART, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  30. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  31. {0, IDM_DOCUMENT_CANCEL, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  32. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  33. // {0, IDM_DOCUMENT_PROPERTIES, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  34. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  35. {4, IDM_VIEW_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
  36. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0},
  37. {3, IDM_HELP_TOPICS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0}
  38. // {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, 0}
  39. };
  40. TOOLBAR_MENU_STATE ToolbarMenuState[] =
  41. {
  42. {IDM_FAX_PAUSE_FAXING, FALSE, FALSE},
  43. {IDM_FAX_CANCEL_ALL_FAXES, FALSE, FALSE},
  44. {IDM_DOCUMENT_PAUSE, FALSE, TRUE},
  45. {IDM_DOCUMENT_RESUME, FALSE, TRUE},
  46. {IDM_DOCUMENT_RESTART, FALSE, FALSE},
  47. {IDM_DOCUMENT_CANCEL, FALSE, TRUE},
  48. {IDM_DOCUMENT_PROPERTIES, FALSE, FALSE},
  49. {IDM_VIEW_REFRESH, FALSE, TRUE},
  50. {IDM_HELP_TOPICS, FALSE, TRUE},
  51. };
  52. VOID
  53. EnableToolbarMenuState(
  54. HWND hWndToolbar,
  55. DWORD CommandId,
  56. BOOL Enabled
  57. )
  58. {
  59. DWORD dwIndex;
  60. dwIndex = CommandId - IDM_FAX_PAUSE_FAXING;
  61. // Set the toolbar menu state
  62. ToolbarMenuState[dwIndex].Enabled = Enabled;
  63. if ((hWndToolbar) && (ToolbarMenuState[dwIndex].Toolbar)) {
  64. if (CommandId == IDM_FAX_PAUSE_FAXING) {
  65. // Toolbar menu item is for pause faxing, so change the toolbar menu item bitmap
  66. SendMessage(hWndToolbar, TB_CHANGEBITMAP, CommandId, Enabled ? 0 : 1);
  67. }
  68. else {
  69. // Enable the toolbar menu item
  70. SendMessage(hWndToolbar, TB_ENABLEBUTTON, CommandId, Enabled);
  71. }
  72. }
  73. }
  74. HWND
  75. CreateToolbar(
  76. HWND hWnd
  77. )
  78. {
  79. // hWndToolbar is the handle to the toolbar
  80. HWND hWndToolbar;
  81. // Create the toolbar
  82. hWndToolbar = CreateToolbarEx(
  83. hWnd,
  84. WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
  85. IDM_TOOLBAR,
  86. NUMIMAGES,
  87. g_hInstance,
  88. IDB_TOOLBAR,
  89. ToolBarButton,
  90. sizeof(ToolBarButton) / sizeof(TBBUTTON),
  91. BUTTONWIDTH,
  92. BUTTONHEIGHT,
  93. IMAGEWIDTH,
  94. IMAGEHEIGHT,
  95. sizeof(TBBUTTON)
  96. );
  97. if (hWndToolbar) {
  98. SendMessage(hWndToolbar, TB_AUTOSIZE, 0, 0);
  99. }
  100. return hWndToolbar;
  101. }
  102. HWND
  103. CreateToolTips(
  104. HWND hWnd
  105. )
  106. {
  107. // hWndToolTips is the handle to the tooltips window
  108. HWND hWndToolTips;
  109. // Create the tooltips window
  110. hWndToolTips = CreateWindowEx(
  111. WS_EX_TOOLWINDOW,
  112. TOOLTIPS_CLASS,
  113. NULL,
  114. WS_CHILD,
  115. 0,
  116. 0,
  117. 0,
  118. 0,
  119. hWnd,
  120. (HMENU) IDM_TOOLTIP,
  121. g_hInstance,
  122. NULL
  123. );
  124. return hWndToolTips;
  125. }
  126. #endif // TOOLBAR_ENABLED