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.

494 lines
14 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. Dlgedit.c
  5. Abstract:
  6. This file contains the intrfaces necessary to use the ColumnListBox
  7. (clb.dll) custom control with the Dialog Editor (dlgedit.exe).
  8. Author:
  9. David J. Gilman (davegi) 05-Feb-1993
  10. Environment:
  11. User Mode
  12. --*/
  13. #include "clb.h"
  14. #include "dialogs.h"
  15. #include <custcntl.h>
  16. #include <strsafe.h>
  17. typedef struct _ID_STYLE_MAP
  18. {
  19. UINT Id;
  20. UINT Style;
  21. }
  22. ID_STYLE_MAP, *LPID_STYLE_MAP;
  23. //
  24. // Module handle for Clb.dll.
  25. //
  26. extern
  27. HINSTANCE _hModule;
  28. //
  29. // Default values.
  30. //
  31. #define CLB_DESCRIPTION L"ColumnListBox"
  32. #define CLB_DEFAULT_TEXT L"Column1;Column2;Column3"
  33. #define CLB_DEFAULT_WIDTH ( 96 )
  34. #define CLB_DEFAULT_HEIGHT ( 80 )
  35. //
  36. // Macro to initialize CCSTYLEFLAGW structure.
  37. //
  38. #define MakeStyle( s, m ) \
  39. {( s ), ( m ), L#s }
  40. //
  41. // Table of supported styles.
  42. //
  43. CCSTYLEFLAGW
  44. Styles[ ] = {
  45. MakeStyle( CLBS_NOTIFY, 0 ),
  46. MakeStyle( CLBS_SORT, 0 ),
  47. MakeStyle( CLBS_DISABLENOSCROLL, 0 ),
  48. MakeStyle( CLBS_VSCROLL, 0 ),
  49. MakeStyle( CLBS_BORDER, 0 ),
  50. MakeStyle( CLBS_POPOUT_HEADINGS, 0 ),
  51. MakeStyle( CLBS_SPRINGY_COLUMNS, 0 ),
  52. MakeStyle( LBS_OWNERDRAWFIXED, 0 )
  53. };
  54. //
  55. // Table of check box ids and their represented styles.
  56. //
  57. ID_STYLE_MAP
  58. StyleCheckBox[ ] = {
  59. IDC_CHECK_NOTIFY, CLBS_NOTIFY,
  60. IDC_CHECK_SORT, CLBS_SORT,
  61. IDC_CHECK_DISABLENOSCROLL, CLBS_DISABLENOSCROLL,
  62. IDC_CHECK_VSCROLL, CLBS_VSCROLL,
  63. IDC_CHECK_BORDER, CLBS_BORDER,
  64. IDC_CHECK_POPOUT_HEADINGS, CLBS_POPOUT_HEADINGS,
  65. IDC_CHECK_SPRINGY_COLUMNS, CLBS_SPRINGY_COLUMNS,
  66. IDC_CHECK_VISIBLE, WS_VISIBLE,
  67. IDC_CHECK_DISABLED, WS_DISABLED,
  68. IDC_CHECK_GROUP, WS_GROUP,
  69. IDC_CHECK_TABSTOP, WS_TABSTOP
  70. };
  71. //
  72. // Table of check box ids and their represented standard styles.
  73. //
  74. ID_STYLE_MAP
  75. StandardStyleCheckBox[ ] = {
  76. IDC_CHECK_NOTIFY, CLBS_NOTIFY,
  77. IDC_CHECK_SORT, CLBS_SORT,
  78. IDC_CHECK_VSCROLL, CLBS_VSCROLL,
  79. IDC_CHECK_BORDER, CLBS_BORDER
  80. };
  81. BOOL
  82. ClbStyleW(
  83. IN HWND hwndParent,
  84. IN LPCCSTYLEW pccs
  85. );
  86. INT_PTR
  87. ClbStylesDlgProc(
  88. IN HWND hWnd,
  89. IN UINT message,
  90. IN WPARAM wParam,
  91. IN LPARAM lParam
  92. )
  93. /*++
  94. Routine Description:
  95. ClbStylesDlgProc is the dialog procedure for the styles dialog. It lets
  96. a user select what styles should be applied to the Clb when it is created.
  97. Arguments:
  98. Standard dialog procedure parameters.
  99. Return Value:
  100. BOOL - dependent on the supplied message.
  101. --*/
  102. {
  103. BOOL Success;
  104. static
  105. LPCCSTYLEW pccs;
  106. switch ( message ) {
  107. case WM_INITDIALOG:
  108. {
  109. DWORD i;
  110. //
  111. // Save the pointer to the Custom Control Style structure.
  112. //
  113. pccs = ( LPCCSTYLEW ) lParam;
  114. //
  115. // For each style bit, if the style bit is set, check
  116. // the associated button.
  117. //
  118. for ( i = 0; i < NumberOfEntries( StyleCheckBox ); i++ ) {
  119. if ( pccs->flStyle & StyleCheckBox[ i ].Style ) {
  120. Success = CheckDlgButton( hWnd, StyleCheckBox[ i ].Id, ( UINT ) ~0 );
  121. DbgAssert( Success );
  122. }
  123. }
  124. //
  125. // If all of the styles making up the standard are checked, check
  126. // the standard button as well.
  127. //
  128. Success = CheckDlgButton(
  129. hWnd,
  130. IDC_CHECK_STANDARD,
  131. IsDlgButtonChecked( hWnd, IDC_CHECK_NOTIFY )
  132. & IsDlgButtonChecked( hWnd, IDC_CHECK_SORT )
  133. & IsDlgButtonChecked( hWnd, IDC_CHECK_VSCROLL )
  134. & IsDlgButtonChecked( hWnd, IDC_CHECK_BORDER )
  135. );
  136. DbgAssert( Success );
  137. return TRUE;
  138. }
  139. case WM_COMMAND:
  140. switch ( LOWORD( wParam )) {
  141. //
  142. // Update standard style checkboxes as soon as the standard style check
  143. // box is clicked.
  144. //
  145. case IDC_CHECK_STANDARD:
  146. {
  147. switch ( HIWORD( wParam )) {
  148. case BN_CLICKED:
  149. {
  150. UINT Check;
  151. DWORD i;
  152. //
  153. // If the standard style check box is checked, check all
  154. // of the standard styles checkboxes, otherwise clear
  155. // (uncheck) them.
  156. //
  157. Check = ( IsDlgButtonChecked( hWnd, LOWORD(wParam )))
  158. ? ( UINT ) ~0
  159. : ( UINT ) 0;
  160. for ( i = 0; i < NumberOfEntries( StandardStyleCheckBox ); i++ ) {
  161. Success = CheckDlgButton(
  162. hWnd,
  163. StandardStyleCheckBox[ i ].Id,
  164. Check
  165. );
  166. DbgAssert( Success );
  167. }
  168. return TRUE;
  169. }
  170. }
  171. break;
  172. }
  173. break;
  174. case IDC_CHECK_NOTIFY:
  175. case IDC_CHECK_SORT:
  176. case IDC_CHECK_VSCROLL:
  177. case IDC_CHECK_BORDER:
  178. {
  179. switch ( HIWORD( wParam )) {
  180. case BN_CLICKED:
  181. {
  182. //
  183. // If all of the styles making up the standard are checked, check
  184. // the standard button as well.
  185. //
  186. Success = CheckDlgButton(
  187. hWnd,
  188. IDC_CHECK_STANDARD,
  189. IsDlgButtonChecked( hWnd, IDC_CHECK_NOTIFY )
  190. & IsDlgButtonChecked( hWnd, IDC_CHECK_SORT )
  191. & IsDlgButtonChecked( hWnd, IDC_CHECK_VSCROLL )
  192. & IsDlgButtonChecked( hWnd, IDC_CHECK_BORDER )
  193. );
  194. DbgAssert( Success );
  195. return TRUE;
  196. }
  197. }
  198. break;
  199. }
  200. break;
  201. case IDOK:
  202. {
  203. DWORD i;
  204. //
  205. // For each possible style, if the user checked the button, set
  206. // the associated style bit.
  207. //
  208. for ( i = 0; i < NumberOfEntries( StyleCheckBox ); i++ ) {
  209. switch ( IsDlgButtonChecked( hWnd, StyleCheckBox[ i ].Id )) {
  210. case 0:
  211. //
  212. // Button was unchecked, disable the style.
  213. //
  214. pccs->flStyle &= ~StyleCheckBox[ i ].Style;
  215. break;
  216. case 1:
  217. //
  218. // Button was checked, enable the style.
  219. //
  220. pccs->flStyle |= StyleCheckBox[ i ].Style;
  221. break;
  222. default:
  223. DbgAssert( FALSE );
  224. break;
  225. }
  226. }
  227. //
  228. // Return TRUE via EndDialog which will cause Dlgedit
  229. // to apply the style changes.
  230. //
  231. return EndDialog( hWnd, ( int ) TRUE );
  232. }
  233. case IDCANCEL:
  234. //
  235. // Return FALSE via EndDialog which will cause Dlgedit
  236. // to ignore the style changes.
  237. //
  238. return EndDialog( hWnd, ( int ) FALSE );
  239. }
  240. break;
  241. }
  242. return FALSE;
  243. }
  244. UINT
  245. CustomControlInfoW(
  246. IN LPCCINFOW CcInfo OPTIONAL
  247. )
  248. /*++
  249. Routine Description:
  250. CustomControlInfoW is called by Dlgedit to query (a) the number of
  251. custom controls supported by this Dll and (b) characteristics about each of
  252. those controls.
  253. Arguments:
  254. CcInfo - Supplies an optional pointer to an array of CCINFOW structures.
  255. If the pointer is NULL CustomControlInfoW returns the number of
  256. controls supported by this Dll. Otherwise each member of the
  257. array is initialized.
  258. Return Value:
  259. BOOL - Returns TRUE if the file names were succesfully added.
  260. --*/
  261. {
  262. if ( CcInfo != NULL ) {
  263. //
  264. // Clb's class name.
  265. //
  266. StringCchCopyW(CcInfo->szClass, ARRAYSIZE(CcInfo->szClass), CLB_CLASS_NAME);
  267. //
  268. // No options (i.e. text is allowed).
  269. //
  270. CcInfo->flOptions = 0;
  271. //
  272. // Quick and dirty description of Clb.
  273. //
  274. StringCchCopyW(CcInfo->szDesc, ARRAYSIZE(CcInfo->szDesc), CLB_DESCRIPTION);
  275. //
  276. // Clb's default width.
  277. //
  278. CcInfo->cxDefault = CLB_DEFAULT_WIDTH;
  279. //
  280. // Clb's default height.
  281. //
  282. CcInfo->cyDefault = CLB_DEFAULT_HEIGHT;
  283. //
  284. // Clb's default styles. LBS_OWNERDRAWFIXED is needed in order to make
  285. // certain messages work properly (e.g. LB_FINDSTRING).
  286. //
  287. CcInfo->flStyleDefault = CLBS_STANDARD
  288. | LBS_OWNERDRAWFIXED
  289. | WS_VISIBLE
  290. | WS_TABSTOP
  291. | WS_CHILD;
  292. //
  293. // No extended styles.
  294. //
  295. CcInfo->flExtStyleDefault = 0;
  296. //
  297. // No control specific styles.
  298. //
  299. CcInfo->flCtrlTypeMask = 0;
  300. //
  301. // Clb's default text (column headings).
  302. //
  303. StringCchCopyW(CcInfo->szTextDefault, ARRAYSIZE(CcInfo->szTextDefault), CLB_DEFAULT_TEXT);
  304. //
  305. // Number of styles supported by Clb.
  306. //
  307. CcInfo->cStyleFlags = NumberOfEntries( Styles );
  308. //
  309. // Clb's array of styles (CCSTYLEGLAGW)
  310. //
  311. CcInfo->aStyleFlags = Styles;
  312. //
  313. // Clb's styles dialog function.
  314. //
  315. CcInfo->lpfnStyle = ClbStyleW;
  316. //
  317. // No SizeToText function.
  318. //
  319. CcInfo->lpfnSizeToText = NULL;
  320. //
  321. // Reserved, must be zero.
  322. //
  323. CcInfo->dwReserved1 = 0;
  324. CcInfo->dwReserved2 = 0;
  325. }
  326. //
  327. // Tell Dlgedit that clb.dll only supports 1 control.
  328. //
  329. return 1;
  330. }
  331. BOOL
  332. ClbStyleW(
  333. IN HWND hWndParent,
  334. IN LPCCSTYLEW pccs
  335. )
  336. /*++
  337. Routine Description:
  338. ClbStyleW is the function that is exported to, and used by, Dlgedit so that
  339. Clb's styles can be editted.
  340. Arguments:
  341. hWndParent - Supplies ahandle to the dialog's parent (i.e. Dlgedit).
  342. pccs - Supplies a pointer to the Custom Control Style structure.
  343. Return Value:
  344. BOOL - Returns the results of the styles dialog.
  345. --*/
  346. {
  347. return ( BOOL ) DialogBoxParam(
  348. _hModule,
  349. MAKEINTRESOURCE( IDD_CLB ),
  350. hWndParent,
  351. ClbStylesDlgProc,
  352. ( LPARAM ) pccs
  353. );
  354. }