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.

144 lines
4.0 KiB

  1. #include "stdafx.h"
  2. #include "common.h"
  3. #include "iisobj.h"
  4. #include "toolbar.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. enum
  11. {
  12. IDM_INVALID, /* invalid command ID */
  13. IDM_CONNECT,
  14. IDM_DISCOVER,
  15. IDM_START,
  16. IDM_STOP,
  17. IDM_PAUSE,
  18. /**/
  19. IDM_TOOLBAR /* Toolbar commands start here */
  20. };
  21. //
  22. // Toolbar Definition. String IDs for menu and tooltip
  23. // text will be resolved at initialization. The InetmgrGlobalSnapinButtons
  24. // button text and tooltips text will be loaded from the InetmgrGlobalSnapinButtons
  25. // below, and should be kept in sync
  26. //
  27. MMCBUTTON InetmgrGlobalSnapinButtons[] =
  28. {
  29. { IDM_CONNECT - 1, IDM_CONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON, NULL, NULL },
  30. // { IDM_DISCOVER - 1, IDM_DISCOVER, TBSTATE_ENABLED, TBSTYLE_BUTTON, NULL, NULL },
  31. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, _T(" "), _T("") },
  32. { IDM_START - 1, IDM_START, TBSTATE_ENABLED, TBSTYLE_BUTTON, NULL, NULL },
  33. { IDM_STOP - 1, IDM_STOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, NULL, NULL },
  34. { IDM_PAUSE - 1, IDM_PAUSE, TBSTATE_ENABLED, TBSTYLE_BUTTON, NULL, NULL },
  35. // { IDM_RECYCLE - 1, IDM_RECYCLE, TBSTATE_ENABLED, TBSTYLE_BUTTON, NULL, NULL },
  36. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, _T(" "), _T("") },
  37. //
  38. // Add-on tools come here
  39. //
  40. };
  41. UINT InetmgrGlobalSnapinButtonIDs[] =
  42. {
  43. /* IDM_CONNECT */ IDS_MENU_CONNECT, IDS_MENU_TT_CONNECT,
  44. // /* IDM_DISCOVER */ IDS_MENU_DISCOVER, IDS_MENU_TT_CONNECT,
  45. /* IDM_START */ IDS_MENU_START, IDS_MENU_TT_START,
  46. /* IDM_STOP */ IDS_MENU_STOP, IDS_MENU_TT_STOP,
  47. /* IDM_PAUSE */ IDS_MENU_PAUSE, IDS_MENU_TT_PAUSE,
  48. // /* IDM_RECYCLE */ IDS_MENU_RECYCLE, IDS_MENU_TT_RECYCLE
  49. };
  50. #define ARRAYLEN(x) (sizeof(x) / sizeof((x)[0]))
  51. #define NUM_BUTTONS2 (ARRAYLEN(InetmgrGlobalSnapinButtons))
  52. #define NUM_BITMAPS (5)
  53. #define TB_COLORMASK RGB(192,192,192) // Lt. Gray
  54. void ToolBar_Init(void)
  55. {
  56. CComBSTR bstr;
  57. CString str;
  58. int j = 0;
  59. for (int i = 0; i < NUM_BUTTONS2; ++i)
  60. {
  61. if (InetmgrGlobalSnapinButtons[i].idCommand != 0)
  62. {
  63. VERIFY(bstr.LoadString(InetmgrGlobalSnapinButtonIDs[j++]));
  64. VERIFY(bstr.LoadString(InetmgrGlobalSnapinButtonIDs[j++]));
  65. InetmgrGlobalSnapinButtons[i].lpButtonText = AllocString(bstr);
  66. InetmgrGlobalSnapinButtons[i].lpTooltipText = AllocString(bstr);
  67. }
  68. }
  69. return;
  70. }
  71. void ToolBar_Destroy(void)
  72. {
  73. for (int i = 0; i < NUM_BUTTONS2; ++i)
  74. {
  75. if (InetmgrGlobalSnapinButtons[i].idCommand != 0)
  76. {
  77. SAFE_FREEMEM(InetmgrGlobalSnapinButtons[i].lpButtonText);
  78. SAFE_FREEMEM(InetmgrGlobalSnapinButtons[i].lpTooltipText);
  79. }
  80. }
  81. }
  82. HRESULT ToolBar_Create(LPCONTROLBAR lpControlBar,LPEXTENDCONTROLBAR lpExtendControlBar,IToolbar ** lpToolBar)
  83. {
  84. //
  85. // Cache the control bar
  86. //
  87. HRESULT hr = S_OK;
  88. if (lpControlBar)
  89. {
  90. do
  91. {
  92. //
  93. // Create our toolbar
  94. //
  95. hr = lpControlBar->Create(TOOLBAR, lpExtendControlBar, (LPUNKNOWN *) lpToolBar);
  96. if (FAILED(hr))
  97. {
  98. break;
  99. }
  100. //
  101. // Add 16x16 bitmaps
  102. //
  103. HBITMAP hToolBar = ::LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_TOOLBAR));
  104. if (NULL != hToolBar)
  105. {
  106. hr = (*lpToolBar)->AddBitmap(NUM_BITMAPS, hToolBar, 16, 16, TB_COLORMASK);
  107. DeleteObject(hToolBar);
  108. if (FAILED(hr))
  109. {
  110. break;
  111. }
  112. }
  113. else
  114. {
  115. hr = E_UNEXPECTED;
  116. break;
  117. }
  118. //
  119. // Add the buttons to the toolbar
  120. //
  121. hr = (*lpToolBar)->AddButtons(NUM_BUTTONS2, InetmgrGlobalSnapinButtons);
  122. }
  123. while(FALSE);
  124. }
  125. return hr;
  126. }