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.

260 lines
6.2 KiB

  1. /* File: D:\WACKER\tdll\toolbar.c (Created: 02-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 6 $
  7. * $Date: 6/11/01 4:42p $
  8. */
  9. #define OEMRESOURCE // Need for OBM bitmaps...
  10. #include <windows.h>
  11. #include <commctrl.h>
  12. #include "assert.h"
  13. #include "stdtyp.h"
  14. #include "globals.h"
  15. #include "session.h"
  16. #include <term\res.h>
  17. #define BTN_CNT 7
  18. struct stToolbarStuff
  19. {
  20. int nSpacer; /* Number of spaces to insert before button */
  21. int nBmpNum; /* Index of the bitmap for this button */
  22. int nCmd; /* Command to associate with the button */
  23. int nStrRes; /* String resource ID number */
  24. };
  25. static struct stToolbarStuff stTS[] = {
  26. {1, 0, IDM_NEW, IDS_TTT_NEW}, /* New button */
  27. {0, 1, IDM_OPEN, IDS_TTT_OPEN}, /* Open button */
  28. {1, 2, IDM_ACTIONS_DIAL, IDS_TTT_DIAL}, /* Dial button */
  29. {0, 3, IDM_ACTIONS_HANGUP, IDS_TTT_HANGUP}, /* Hangup button */
  30. {1, 4, IDM_ACTIONS_SEND, IDS_TTT_SEND}, /* Send button */
  31. {0, 5, IDM_ACTIONS_RCV, IDS_TTT_RECEIVE}, /* Receive button */
  32. {1, 6, IDM_PROPERTIES, IDS_TTT_PROPERTY}, /* Properties button */
  33. //{1, 7, IDM_HELPTOPICS, IDS_TTT_HELP} /* Help button */
  34. };
  35. static void AddMinitelButtons(const HWND hwnd);
  36. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  37. * FUNCTION:
  38. * CreateSessionToolbar
  39. *
  40. * DESCRIPTION:
  41. * Creates a toolbar intended for use with the a session
  42. *
  43. * ARGUMENTS:
  44. * hwndSession - session window handle
  45. *
  46. * RETURNS:
  47. * Window handle to toolbar or zero on error.
  48. *
  49. */
  50. /* ARGSUSED */
  51. HWND CreateSessionToolbar(const HSESSION hSession, const HWND hwndSession)
  52. {
  53. HWND hWnd = 0;
  54. int iLoop = 0;
  55. DWORD lTBStyle = TBSTYLE_TOOLTIPS | WS_CHILD | WS_VISIBLE;
  56. TBBUTTON lButton;
  57. //
  58. // Changed to use Flat style in version 4.0 - mpt 06-10-98
  59. //
  60. #if defined( INCL_COOL_TOOLBARS )
  61. lTBStyle |= TBSTYLE_FLAT;
  62. #endif
  63. //
  64. // Create a toolbar with no buttons.
  65. //
  66. hWnd = CreateToolbarEx( hwndSession,
  67. lTBStyle,
  68. IDC_TOOLBAR_WIN,
  69. BTN_CNT,
  70. glblQueryDllHinst(),
  71. IDB_BUTTONS_SMALL,
  72. NULL, // Array of buttons
  73. 0, // Number of buttons in array
  74. 16, 16, // button size
  75. 16, 16, // bitmap size
  76. sizeof( TBBUTTON ) );
  77. assert( hWnd );
  78. if ( IsWindow( hWnd ) )
  79. {
  80. //
  81. // Add some buttons.
  82. //
  83. for ( iLoop = 0; iLoop < BTN_CNT; iLoop++ )
  84. {
  85. int iIndex;
  86. for ( iIndex = 0; iIndex < stTS[ iLoop ].nSpacer; iIndex++ )
  87. {
  88. //
  89. // Don't add seperator at beginning of toolbar.
  90. //
  91. if ( iLoop != 0 )
  92. {
  93. //
  94. // Just insert space between two buttons.
  95. //
  96. lButton.iBitmap = 0;
  97. lButton.idCommand = 0;
  98. lButton.fsState = TBSTATE_ENABLED;
  99. lButton.fsStyle = TBSTYLE_SEP;
  100. lButton.dwData = 0;
  101. lButton.iString = 0;
  102. SendMessage( hWnd, TB_ADDBUTTONS, 1, (LPARAM)&lButton );
  103. }
  104. }
  105. lButton.iBitmap = stTS[ iLoop ].nBmpNum;
  106. lButton.idCommand = stTS[ iLoop ].nCmd;
  107. lButton.fsState = TBSTATE_ENABLED;
  108. lButton.fsStyle = TBSTYLE_BUTTON;
  109. lButton.dwData = 0;
  110. lButton.iString = 0;
  111. SendMessage( hWnd, TB_ADDBUTTONS, 1, (LPARAM)&lButton );
  112. }
  113. }
  114. ToolbarEnableButton(hWnd, IDM_ACTIONS_DIAL, TRUE);
  115. ToolbarEnableButton(hWnd, IDM_ACTIONS_HANGUP, FALSE);
  116. return hWnd;
  117. }
  118. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  119. * FUNCTION:
  120. * ToolbarNotification
  121. *
  122. * DESCRIPTION:
  123. * This function is called when the toolbar sends a notification message to
  124. * the session window.
  125. *
  126. * ARGUMENTS:
  127. * hwnd -- the window handle of the session window
  128. * nId -- the control ID (the tool bar in this case)
  129. * nNotify -- the notification code
  130. * hwndCtrl -- the window handle of the tool bar
  131. *
  132. * RETURNS:
  133. * Whatever the notification requires. See individual code below.
  134. *
  135. */
  136. /* ARGSUSED */
  137. LRESULT ToolbarNotification(const HWND hwnd,
  138. const int nId,
  139. const int nNotify,
  140. const HWND hwndCtrl)
  141. {
  142. //lint -e648 TBN constants overflow
  143. LRESULT lRet = 0;
  144. static int nCount;
  145. switch ((UINT)nNotify)
  146. {
  147. case TBN_BEGINADJUST:
  148. /*
  149. * No return value.
  150. */
  151. nCount = 1;
  152. break;
  153. case TBN_QUERYDELETE:
  154. /*
  155. * Return TRUE to delete the button or FALSE to prevent the button
  156. * from being deleted.
  157. */
  158. lRet = FALSE;
  159. break;
  160. case TBN_QUERYINSERT:
  161. /*
  162. * Return TRUE to insert the new button in front of the given
  163. * button, or FALSE to prevent the button from being inserted.
  164. */
  165. if (nCount > 0)
  166. {
  167. nCount -= 1;
  168. lRet = TRUE;
  169. }
  170. break;
  171. default:
  172. break;
  173. }
  174. return lRet;
  175. //lint +e648
  176. }
  177. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  178. * FUNCTION:
  179. * ToolbarNeedsText
  180. *
  181. * DESCRIPTION:
  182. * This function is called when the toolbar sends a notification message to
  183. * the session window saying that it needs text for the ToolTips window.
  184. *
  185. * ARGUMENTS:
  186. * hwnd -- the window handle of the session window
  187. * lPar -- the lPar that the session window got
  188. *
  189. * RETURNS:
  190. *
  191. */
  192. /* ARGSUSED */
  193. void ToolbarNeedsText(HSESSION hSession, LPARAM lPar)
  194. {
  195. unsigned int nLoop;
  196. LPTOOLTIPTEXT pText = (LPTOOLTIPTEXT)lPar;
  197. for (nLoop = 0 ; nLoop < DIM(stTS) ; nLoop += 1)
  198. {
  199. if ((int)pText->hdr.idFrom == stTS[nLoop].nCmd)
  200. {
  201. LoadString(glblQueryDllHinst(), (UINT)stTS[nLoop].nStrRes,
  202. pText->szText,
  203. sizeof(pText->szText) / sizeof(TCHAR));
  204. return;
  205. }
  206. }
  207. }
  208. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  209. * FUNCTION:
  210. * ToolbarEnableButton
  211. *
  212. * DESCRIPTION:
  213. * Enables or disables a button based on the state.
  214. *
  215. * ARGUMENTS:
  216. * hwndToolbar - Window handle to toolbar
  217. * fEnable - bool to determine wether to enable or disable the button
  218. *
  219. */
  220. void ToolbarEnableButton(const HWND hwndToolbar, const int uID, BOOL fEnable)
  221. {
  222. assert( hwndToolbar );
  223. if ( IsWindow( hwndToolbar ) )
  224. {
  225. PostMessage( hwndToolbar, TB_ENABLEBUTTON, uID, fEnable );
  226. }
  227. }