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.

499 lines
13 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 <wchar.h>
  17. typedef
  18. struct
  19. _ID_STYLE_MAP {
  20. UINT Id;
  21. UINT Style;
  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(
  121. hWnd,
  122. StyleCheckBox[ i ].Id,
  123. ( UINT ) ~0
  124. );
  125. DbgAssert( Success );
  126. }
  127. }
  128. //
  129. // If all of the styles making up the standard are checked, check
  130. // the standard button as well.
  131. //
  132. Success = CheckDlgButton(
  133. hWnd,
  134. IDC_CHECK_STANDARD,
  135. IsDlgButtonChecked( hWnd, IDC_CHECK_NOTIFY )
  136. & IsDlgButtonChecked( hWnd, IDC_CHECK_SORT )
  137. & IsDlgButtonChecked( hWnd, IDC_CHECK_VSCROLL )
  138. & IsDlgButtonChecked( hWnd, IDC_CHECK_BORDER )
  139. );
  140. DbgAssert( Success );
  141. return TRUE;
  142. }
  143. case WM_COMMAND:
  144. switch ( LOWORD( wParam )) {
  145. //
  146. // Update standard style checkboxes as soon as the standard style check
  147. // box is clicked.
  148. //
  149. case IDC_CHECK_STANDARD:
  150. {
  151. switch ( HIWORD( wParam )) {
  152. case BN_CLICKED:
  153. {
  154. UINT Check;
  155. DWORD i;
  156. //
  157. // If the standard style check box is checked, check all
  158. // of the standard styles checkboxes, otherwise clear
  159. // (uncheck) them.
  160. //
  161. Check = ( IsDlgButtonChecked( hWnd, LOWORD(wParam )))
  162. ? ( UINT ) ~0
  163. : ( UINT ) 0;
  164. for ( i = 0; i < NumberOfEntries( StandardStyleCheckBox ); i++ ) {
  165. Success = CheckDlgButton(
  166. hWnd,
  167. StandardStyleCheckBox[ i ].Id,
  168. Check
  169. );
  170. DbgAssert( Success );
  171. }
  172. return TRUE;
  173. }
  174. }
  175. break;
  176. }
  177. break;
  178. case IDC_CHECK_NOTIFY:
  179. case IDC_CHECK_SORT:
  180. case IDC_CHECK_VSCROLL:
  181. case IDC_CHECK_BORDER:
  182. {
  183. switch ( HIWORD( wParam )) {
  184. case BN_CLICKED:
  185. {
  186. //
  187. // If all of the styles making up the standard are checked, check
  188. // the standard button as well.
  189. //
  190. Success = CheckDlgButton(
  191. hWnd,
  192. IDC_CHECK_STANDARD,
  193. IsDlgButtonChecked( hWnd, IDC_CHECK_NOTIFY )
  194. & IsDlgButtonChecked( hWnd, IDC_CHECK_SORT )
  195. & IsDlgButtonChecked( hWnd, IDC_CHECK_VSCROLL )
  196. & IsDlgButtonChecked( hWnd, IDC_CHECK_BORDER )
  197. );
  198. DbgAssert( Success );
  199. return TRUE;
  200. }
  201. }
  202. break;
  203. }
  204. break;
  205. case IDOK:
  206. {
  207. DWORD i;
  208. //
  209. // For each possible style, if the user checked the button, set
  210. // the associated style bit.
  211. //
  212. for ( i = 0; i < NumberOfEntries( StyleCheckBox ); i++ ) {
  213. switch ( IsDlgButtonChecked( hWnd, StyleCheckBox[ i ].Id )) {
  214. case 0:
  215. //
  216. // Button was unchecked, disable the style.
  217. //
  218. pccs->flStyle &= ~StyleCheckBox[ i ].Style;
  219. break;
  220. case 1:
  221. //
  222. // Button was checked, enable the style.
  223. //
  224. pccs->flStyle |= StyleCheckBox[ i ].Style;
  225. break;
  226. default:
  227. DbgAssert( FALSE );
  228. break;
  229. }
  230. }
  231. //
  232. // Return TRUE via EndDialog which will cause Dlgedit
  233. // to apply the style changes.
  234. //
  235. return EndDialog( hWnd, ( int ) TRUE );
  236. }
  237. case IDCANCEL:
  238. //
  239. // Return FALSE via EndDialog which will cause Dlgedit
  240. // to ignore the style changes.
  241. //
  242. return EndDialog( hWnd, ( int ) FALSE );
  243. }
  244. break;
  245. }
  246. return FALSE;
  247. }
  248. UINT
  249. CustomControlInfoW(
  250. IN LPCCINFOW CcInfo OPTIONAL
  251. )
  252. /*++
  253. Routine Description:
  254. CustomControlInfoW is called by Dlgedit to query (a) the number of
  255. custom controls supported by this Dll and (b) characteristics about each of
  256. those controls.
  257. Arguments:
  258. CcInfo - Supplies an optional pointer to an array of CCINFOW structures.
  259. If the pointer is NULL CustomControlInfoW returns the number of
  260. controls supported by this Dll. Otherwise each member of the
  261. array is initialized.
  262. Return Value:
  263. BOOL - Returns TRUE if the file names were succesfully added.
  264. --*/
  265. {
  266. if ( CcInfo != NULL ) {
  267. //
  268. // Clb's class name.
  269. //
  270. wcscpy( CcInfo->szClass, CLB_CLASS_NAME );
  271. //
  272. // No options (i.e. text is allowed).
  273. //
  274. CcInfo->flOptions = 0;
  275. //
  276. // Quick and dirty description of Clb.
  277. //
  278. wcscpy( CcInfo->szDesc, CLB_DESCRIPTION );
  279. //
  280. // Clb's default width.
  281. //
  282. CcInfo->cxDefault = CLB_DEFAULT_WIDTH;
  283. //
  284. // Clb's default height.
  285. //
  286. CcInfo->cyDefault = CLB_DEFAULT_HEIGHT;
  287. //
  288. // Clb's default styles. LBS_OWNERDRAWFIXED is needed in order to make
  289. // certain messages work properly (e.g. LB_FINDSTRING).
  290. //
  291. CcInfo->flStyleDefault = CLBS_STANDARD
  292. | LBS_OWNERDRAWFIXED
  293. | WS_VISIBLE
  294. | WS_TABSTOP
  295. | WS_CHILD;
  296. //
  297. // No extended styles.
  298. //
  299. CcInfo->flExtStyleDefault = 0;
  300. //
  301. // No control specific styles.
  302. //
  303. CcInfo->flCtrlTypeMask = 0;
  304. //
  305. // Clb's default text (column headings).
  306. //
  307. wcscpy( CcInfo->szTextDefault, CLB_DEFAULT_TEXT );
  308. //
  309. // Number of styles supported by Clb.
  310. //
  311. CcInfo->cStyleFlags = NumberOfEntries( Styles );
  312. //
  313. // Clb's array of styles (CCSTYLEGLAGW)
  314. //
  315. CcInfo->aStyleFlags = Styles;
  316. //
  317. // Clb's styles dialog function.
  318. //
  319. CcInfo->lpfnStyle = ClbStyleW;
  320. //
  321. // No SizeToText function.
  322. //
  323. CcInfo->lpfnSizeToText = NULL;
  324. //
  325. // Reserved, must be zero.
  326. //
  327. CcInfo->dwReserved1 = 0;
  328. CcInfo->dwReserved2 = 0;
  329. }
  330. //
  331. // Tell Dlgedit that clb.dll only supports 1 control.
  332. //
  333. return 1;
  334. }
  335. BOOL
  336. ClbStyleW(
  337. IN HWND hWndParent,
  338. IN LPCCSTYLEW pccs
  339. )
  340. /*++
  341. Routine Description:
  342. ClbStyleW is the function that is exported to, and used by, Dlgedit so that
  343. Clb's styles can be editted.
  344. Arguments:
  345. hWndParent - Supplies ahandle to the dialog's parent (i.e. Dlgedit).
  346. pccs - Supplies a pointer to the Custom Control Style structure.
  347. Return Value:
  348. BOOL - Returns the results of the styles dialog.
  349. --*/
  350. {
  351. return ( BOOL ) DialogBoxParam(
  352. _hModule,
  353. MAKEINTRESOURCE( IDD_CLB ),
  354. hWndParent,
  355. ClbStylesDlgProc,
  356. ( LPARAM ) pccs
  357. );
  358. }