|
|
1.1 root 1:
2: /******************************************************************************\
3: * This is a part of the Microsoft Source Code Samples.
4: * Copyright (C) 1993 Microsoft Corporation.
5: * All rights reserved.
6: * This source code is only intended as a supplement to
7: * Microsoft Development Tools and/or WinHelp documentation.
8: * See these sources for detailed information regarding the
9: * Microsoft samples programs.
10: \******************************************************************************/
11:
12: /****************************** Module Header *******************************
13: * Module Name: dialogs.c
14: *
15: * Contains many of the dialogs and supporting routines used by the
16: * dialog box editor.
17: *
18: * Functions:
19: *
20: * DlgBox()
21: * EnteringDialog()
22: * CreateTestDialog()
23: * DestroyTestDialog()
24: * SelectDialogDialog()
25: * ArrangeSettingsDialog()
26: * AboutDlgProc()
27: * SelectDialogDlgProc()
28: * SelectDialogInit()
29: * SelectDialogFillLangList()
30: * SelectDialogOK()
31: * TestDlgProc()
32: * TestInitDlg()
33: * ArrangeSettingsDlgProc()
34: *
35: * Comments:
36: *
37: ****************************************************************************/
38:
39: #include "dlgedit.h"
40: #include "dlgfuncs.h"
41: #include "dlgextrn.h"
42: #include "dialogs.h"
43: #include "dlghelp.h"
44:
45:
46: /*
47: * Maximum number of characters in the Arrange Settings fields.
48: */
49: #define CCHARRSETMAX 2
50:
51: DIALOGPROC SelectDialogDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
52: STATICFN VOID SelectDialogInit(HWND hwnd);
53: STATICFN VOID SelectDialogFillLangList(HWND hwnd);
54: STATICFN BOOL SelectDialogOK(HWND hwnd);
55: DIALOGPROC TestDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
56: STATICFN VOID TestInitDlg(HWND hwnd);
57: DIALOGPROC ArrangeSettingsDlgProc(HWND hwnd, UINT msg, WPARAM wParam,
58: LPARAM lParam);
59:
60:
61:
62: /************************************************************************
63: * DlgBox
64: *
65: * This function basically does a DialogBox, but it does it safely
66: * for the dialog editor, saving some states.
67: *
68: * Arguments:
69: * INT idDlg = Ordinal name of the dialog.
70: * WNDPROC lpfnDlg = Dialog procedure to use (this function will
71: * call Make/FreeProcInstance).
72: *
73: * Returns:
74: * What DialogBox returned.
75: *
76: ************************************************************************/
77:
78: INT DlgBox(
79: INT idDlg,
80: WNDPROC lpfnDlg)
81: {
82: INT nResult;
83: INT idPrevDlg;
84:
85: EnteringDialog(idDlg, &idPrevDlg, TRUE);
86: nResult = DialogBox(ghInst, MAKEINTRESOURCE(idDlg), ghwndMain, (DLGPROC)lpfnDlg);
87: EnteringDialog(idPrevDlg, NULL, FALSE);
88:
89: return nResult;
90: }
91:
92:
93:
94: /************************************************************************
95: * EnteringDialog
96: *
97: * This function enables or disables things based on whether we are
98: * going to show one of the editor's dialogs. It must be called
99: * before and after showing a dialog box.
100: *
101: * Arguments:
102: * INT idDlg - Ordinal name of the dialog.
103: * PINT pidPrevDlg - Points to where to save the id of the previous
104: * (current) dialog. If fEntering is FALSE, this
105: * is not used and should be NULL.
106: * BOOL fEntering - TRUE if about ready to show the dialog. FALSE if
107: * the dialog was just dismissed. For the FALSE case,
108: * the idDlg should be zero, or the id of the previous
109: * dialog.
110: *
111: ************************************************************************/
112:
113: VOID EnteringDialog(
114: INT idDlg,
115: PINT pidPrevDlg,
116: BOOL fEntering)
117: {
118: /*
119: * If we are entering a new dialog, save the previous dialog
120: * in the place specified.
121: */
122: if (fEntering)
123: *pidPrevDlg = gidCurrentDlg;
124:
125: gfDisabled = fEntering;
126: gidCurrentDlg = idDlg;
127: StatusSetEnable();
128:
129: if (ghwndToolbox)
130: EnableWindow(ghwndToolbox, !fEntering);
131: }
132:
133:
134:
135: /************************************************************************
136: * SelectDialogDialog
137: *
138: * This function saves the current dialog box in the resource in
139: * memory, then it puts up a dialog box with a list of dialog
140: * boxes in the resource. Finally it puts up the selected dialog.
141: *
142: ************************************************************************/
143:
144: VOID SelectDialogDialog(VOID)
145: {
146: if (!SynchDialogResource())
147: return;
148:
149: DlgBox(DID_SELECTDIALOG, (WNDPROC)SelectDialogDlgProc);
150: }
151:
152:
153:
154: /************************************************************************
155: * SelectDialogDlgProc
156: *
157: * This is the View Dialog dialog procedure.
158: *
159: * Arguments:
160: * HWND - handle to the dialog
161: * UINT - window message
162: * WPARAM - message parameter
163: * LPARAM - message parameter
164: *
165: * Returns:
166: * Default dialog return.
167: *
168: ************************************************************************/
169:
170: DIALOGPROC SelectDialogDlgProc(
171: HWND hwnd,
172: UINT msg,
173: WPARAM wParam,
174: LPARAM lParam)
175: {
176: switch (msg) {
177: case WM_INITDIALOG:
178: SelectDialogInit(hwnd);
179: return TRUE;
180:
181: case WM_COMMAND:
182: switch (LOWORD(wParam)) {
183: case DID_SELECTDIALOGNAMELIST:
184: switch (HIWORD(wParam)) {
185: case LBN_SELCHANGE:
186: SelectDialogFillLangList(hwnd);
187: break;
188:
189: case LBN_DBLCLK:
190: if (SelectDialogOK(hwnd))
191: EndDialog(hwnd, IDOK);
192:
193: break;
194: }
195:
196: break;
197:
198: case DID_SELECTDIALOGLANGLIST:
199: switch (HIWORD(wParam)) {
200: case LBN_DBLCLK:
201: if (SelectDialogOK(hwnd))
202: EndDialog(hwnd, IDOK);
203:
204: break;
205: }
206:
207: break;
208:
209: case IDOK:
210: if (SelectDialogOK(hwnd))
211: EndDialog(hwnd, IDOK);
212:
213: break;
214:
215: case IDCANCEL:
216: EndDialog(hwnd, IDCANCEL);
217: break;
218:
219: case IDHELP:
220: WinHelp(ghwndMain, gszHelpFile, HELP_CONTEXT,
221: HELPID_SELECTDIALOG);
222: break;
223: }
224:
225: return TRUE;
226:
227: default:
228: return FALSE;
229: }
230: }
231:
232:
233:
234: /************************************************************************
235: * SelectDialogInit
236: *
237: * Processes the WM_INITDIALOG message for the Select Dialog dialog
238: * procedure.
239: *
240: * This function fills the select dialog listbox with the names or
241: * numbers of all the dialogs in the resource list. If the dialog has
242: * a name, that is used. If it just has an ordinal, then the decimal
243: * ascii string for the ordinal number is used.
244: *
245: * Arguments:
246: * HWND - handle to the dialog
247: *
248: ************************************************************************/
249:
250: STATICFN VOID SelectDialogInit(
251: HWND hwnd)
252: {
253: HWND hwndNameLB;
254: TCHAR szName[CCHTEXTMAX];
255: INT i;
256: INT cDlgsAdded;
257: INT iSelect;
258: PRESLINK prl;
259: PRESLINK prl2;
260: LPTSTR pszName;
261: NPLABEL npLabel;
262:
263: hwndNameLB = GetDlgItem(hwnd, DID_SELECTDIALOGNAMELIST);
264: cDlgsAdded = 0;
265:
266: /*
267: * Insert each dialog found in the resource.
268: */
269: for (prl = gprlHead; prl; prl = prl->prlNext) {
270: if (prl->fDlgResource) {
271: /*
272: * Check to be sure we have not added a dialog with this
273: * name already (but perhaps a different language).
274: */
275: for (prl2 = gprlHead; prl2 != prl; prl2 = prl2->prlNext) {
276: if (prl2->fDlgResource) {
277: if (NameOrdCmp(prl2->pszName, prl->pszName) == 0)
278: break;
279: }
280: }
281:
282: if (prl2 == prl) {
283: /*
284: * If the name is an ordinal, display a number. If there
285: * happens to be a define for this number, display that
286: * instead, however.
287: *
288: * Note that we do not ever show it in hex, because
289: * rc.exe does not parse hex ordinals for dialogs, so
290: * we never show it in that format.
291: */
292: if (IsOrd(prl->pszName)) {
293: if (npLabel = FindID(OrdID(prl->pszName), plInclude))
294: pszName = npLabel->pszLabel;
295: else
296: pszName = itoaw(OrdID(prl->pszName), szName, 10);
297: }
298: else {
299: pszName = prl->pszName;
300: }
301:
302: i = (INT)SendMessage(hwndNameLB, LB_ADDSTRING, 0, (DWORD)pszName);
303: SendMessage(hwndNameLB, LB_SETITEMDATA, i, (DWORD)prl);
304: cDlgsAdded++;
305: }
306: }
307: }
308:
309: /*
310: * If there is a current dialog, search for it and
311: * make it the default selected item.
312: */
313: iSelect = 0;
314: if (gcd.prl) {
315: for (i = 0; i < cDlgsAdded; i++) {
316: prl = (PRESLINK)SendMessage(hwndNameLB, LB_GETITEMDATA, i, 0L);
317: if (NameOrdCmp(prl->pszName, gcd.prl->pszName) == 0) {
318: iSelect = i;
319: break;
320: }
321: }
322: }
323:
324: SendMessage(hwndNameLB, LB_SETCURSEL, iSelect, 0L);
325:
326: SelectDialogFillLangList(hwnd);
327:
328: CenterWindow(hwnd);
329: }
330:
331:
332:
333: /************************************************************************
334: * SelectDialogFillLangList
335: *
336: * Fills the listbox with the list of dialogs matching the specified name
337: *
338: * Arguments:
339: * HWND - handle to the dialog editor window
340: *
341: ************************************************************************/
342:
343: STATICFN VOID SelectDialogFillLangList(
344: HWND hwnd)
345: {
346: TCHAR szLang[CCHTEXTMAX];
347: HWND hwndNameLB;
348: HWND hwndLangLB;
349: PRESLINK prl;
350: INT i;
351: INT iSelect;
352: WORD wPrimary;
353: WORD wSubLang;
354: INT iLang;
355: INT iSubLang;
356: LPTSTR pszName;
357: INT cItems;
358:
359: hwndNameLB = GetDlgItem(hwnd, DID_SELECTDIALOGNAMELIST);
360: hwndLangLB = GetDlgItem(hwnd, DID_SELECTDIALOGLANGLIST);
361:
362: SendMessage(hwndLangLB, LB_RESETCONTENT, 0, 0);
363:
364: if ((iSelect = (INT)SendMessage(hwndNameLB, LB_GETCURSEL, 0, 0)) == LB_ERR)
365: return;
366:
367: /*
368: * Get the name of the dialog selected in the Name listbox
369: * (the reslink pointer is stored in the listbox items data field).
370: */
371: prl = (PRESLINK)SendMessage(hwndNameLB, LB_GETITEMDATA, iSelect, 0L);
372: pszName = prl->pszName;
373:
374: /*
375: * Insert each dialog found in the resource that matches that name.
376: */
377: for (prl = gprlHead; prl; prl = prl->prlNext) {
378: if (prl->fDlgResource && NameOrdCmp(prl->pszName, pszName) == 0) {
379: wPrimary = (WORD)PRIMARYLANGID(prl->wLanguage);
380: for (iLang = 0; iLang < gcLanguages; iLang++) {
381: if (gaLangTable[iLang].wPrimary == wPrimary) {
382: break;
383: }
384: }
385:
386: wSubLang = SUBLANGID(prl->wLanguage);
387: for (iSubLang = 0;
388: iSubLang < gaLangTable[iLang].cSubLangs;
389: iSubLang++) {
390: if (wSubLang == gaLangTable[iLang].asl[iSubLang].wSubLang) {
391: break;
392: }
393: }
394:
395: wsprintf(szLang, L"%s, %s",
396: ids(gaLangTable[iLang].idsLangDesc),
397: ids(gaLangTable[iLang].asl[iSubLang].idsSubLangDesc));
398:
399: i = (INT)SendMessage(hwndLangLB, LB_ADDSTRING, 0, (DWORD)szLang);
400: SendMessage(hwndLangLB, LB_SETITEMDATA, i, (DWORD)prl);
401: }
402: }
403:
404: iSelect = 0;
405: cItems = (INT)SendMessage(hwndLangLB, LB_GETCOUNT, 0, 0);
406: if (gcd.prl && NameOrdCmp(gcd.prl->pszName, pszName) == 0) {
407: for (i = 0; i < cItems; i++) {
408: prl = (PRESLINK)SendMessage(hwndLangLB, LB_GETITEMDATA, i, 0);
409: if (gcd.prl == prl) {
410: iSelect = i;
411: break;
412: }
413: }
414: }
415:
416: SendMessage(hwndLangLB, LB_SETCURSEL, iSelect, 0L);
417: }
418:
419:
420:
421: /************************************************************************
422: * SelectDialogOK
423: *
424: * Processes the selection of a new dialog from the Select Dialog
425: * dialog procedure.
426: *
427: * Arguments:
428: * HWND - handle to the select dialog box
429: *
430: * Returns:
431: * TRUE
432: *
433: ************************************************************************/
434:
435: STATICFN BOOL SelectDialogOK(
436: HWND hwnd)
437: {
438: HWND hwndLangLB;
439: INT iSelect;
440: PRESLINK prl;
441:
442: hwndLangLB = GetDlgItem(hwnd, DID_SELECTDIALOGLANGLIST);
443:
444: if ((iSelect = (INT)SendMessage(hwndLangLB, LB_GETCURSEL, 0, 0)) !=
445: LB_ERR) {
446: /*
447: * Get a pointer to the selected dialog (stored in the listbox
448: * items data field).
449: */
450: prl = (PRESLINK)SendMessage(hwndLangLB, LB_GETITEMDATA, iSelect, 0L);
451:
452: /*
453: * Is there a dialog currently being edited?
454: */
455: if (gfEditingDlg) {
456: /*
457: * If they chose the same dialog as what they are currently
458: * editing, just get out without doing anything more.
459: * Otherwise, delete the current dialog because we are
460: * now committed to loading a new one.
461: */
462: if (prl == gcd.prl)
463: return TRUE;
464: else
465: DeleteDialog(FALSE);
466: }
467:
468: /*
469: * Finally, load the new dialog (make it current).
470: */
471: ResLinkToDialog(prl);
472:
473: /*
474: * Select the new dialog, if it was successfully created.
475: */
476: if (gfEditingDlg)
477: SelectControl(gcd.npc, FALSE);
478: }
479:
480: return TRUE;
481: }
482:
483:
484:
485: /************************************************************************
486: * CreateTestDialog
487: *
488: * Creates a dialog for the test mode of the dialog editor
489: *
490: ************************************************************************/
491:
492: VOID CreateTestDialog(VOID)
493: {
494: PRES pRes;
495: PDIALOGBOXHEADER pdbh;
496:
497: if (!gfEditingDlg)
498: return;
499:
500: CancelSelection(TRUE);
501:
502: /*
503: * Save the current dialog in the resource buffer.
504: */
505: if (!SynchDialogResource())
506: return;
507:
508: /*
509: * Make a memory copy of the current dialog resource for test mode.
510: */
511: if (!(pRes = AllocDialogResource(TRUE, FALSE)))
512: return;
513:
514: pdbh = (PDIALOGBOXHEADER)SkipResHeader(pRes);
515:
516: /*
517: * Create the test dialog in a modeless loop using the test dialog proc.
518: */
519: ghwndTestDlg = CreateDialogIndirect(ghInst, (LPDLGTEMPLATE)pdbh,
520: ghwndSubClient, TestDlgProc);
521:
522: if (ghwndTestDlg) {
523: gfTestMode = TRUE;
524:
525: /*
526: * Disable various top level menus.
527: */
528: MyEnableMenuItemByPos(ghMenuMain, MENUPOS_FILE, FALSE);
529: MyEnableMenuItemByPos(ghMenuMain, MENUPOS_EDIT, FALSE);
530: MyEnableMenuItemByPos(ghMenuMain, MENUPOS_ARRANGE, FALSE);
531: DrawMenuBar(ghwndMain);
532:
533: ToolboxSelectTool(W_NOTHING, FALSE);
534: if (gfShowToolbox)
535: ToolboxShow(FALSE);
536:
537: StatusSetEnable();
538:
539: /*
540: * Remove the work mode dialog from view (actually, it is now
541: * hidden behind the test dialog, but we hide it in case the
542: * user moves the test dialog.
543: */
544: ShowWindow(gcd.npc->hwnd, SW_HIDE);
545: }
546: }
547:
548:
549:
550: /************************************************************************
551: * TestDlgProc
552: *
553: * This is the dialog procedure for the dialog in Test mode.
554: *
555: ************************************************************************/
556:
557: DIALOGPROC TestDlgProc(
558: HWND hwnd,
559: UINT msg,
560: WPARAM wParam,
561: LPARAM lParam)
562: {
563: switch (msg) {
564: case WM_INITDIALOG:
565: TestInitDlg(hwnd);
566: return TRUE;
567:
568: case WM_SYSCOMMAND:
569: if (wParam == SC_CLOSE) {
570: DestroyTestDialog();
571: return TRUE;
572: }
573:
574: return FALSE;
575:
576: case WM_DRAWITEM:
577: return DrawOwnerDrawButton((LPDRAWITEMSTRUCT)lParam);
578:
579: case WM_DESTROY:
580: gfTestMode = FALSE;
581:
582: ShowWindow(gcd.npc->hwnd, SW_SHOWNA);
583:
584: /*
585: * Enable various top level menus.
586: */
587: MyEnableMenuItemByPos(ghMenuMain, MENUPOS_FILE, TRUE);
588: MyEnableMenuItemByPos(ghMenuMain, MENUPOS_EDIT, TRUE);
589: MyEnableMenuItemByPos(ghMenuMain, MENUPOS_ARRANGE, TRUE);
590: DrawMenuBar(ghwndMain);
591:
592: if (gfShowToolbox)
593: ToolboxShow(TRUE);
594:
595: StatusSetEnable();
596:
597: return TRUE;
598:
599: default:
600: return FALSE;
601: }
602: }
603:
604:
605:
606: /************************************************************************
607: * TestInitDlg
608: *
609: * This function handles the initialization of the test dialog.
610: *
611: * Arguments:
612: * HWND hwnd = The test dialog window handle.
613: *
614: ************************************************************************/
615:
616: STATICFN VOID TestInitDlg(
617: HWND hwnd)
618: {
619: register INT i;
620: TCHAR szBuf[CCHTEXTMAX];
621: HWND hwndCtrl;
622: LPTSTR pszTextEnd;
623: TCHAR szClass[32];
624: INT iClass;
625:
626: /*
627: * The following will fill some controls with sample text lines.
628: */
629: lstrcpy(szBuf, ids(IDS_DEFLBTEXT));
630: pszTextEnd = szBuf + lstrlen(szBuf);
631: hwndCtrl = GetWindow(hwnd, GW_CHILD);
632: while (hwndCtrl) {
633: GetClassName(hwndCtrl, szClass, sizeof(szClass));
634:
635: switch (iClass = GetiClass(szClass)) {
636: case IC_LISTBOX:
637: case IC_COMBOBOX:
638: /*
639: * Fill listboxes and comboboxes with some sample lines.
640: */
641: for (i = 1; i <= CLBTESTLINES; i++) {
642: itoaw(i, pszTextEnd, 10);
643: SendMessage(hwndCtrl,
644: (WORD)((iClass == IC_LISTBOX) ?
645: LB_INSERTSTRING : CB_INSERTSTRING),
646: (WPARAM)-1, (DWORD)szBuf);
647: }
648:
649: break;
650: }
651:
652: hwndCtrl = GetWindow(hwndCtrl, GW_HWNDNEXT);
653: }
654: }
655:
656:
657:
658: /************************************************************************
659: * DestroyTestDialog
660: *
661: * Destroys the test dialog window.
662: ************************************************************************/
663:
664: VOID DestroyTestDialog(VOID)
665: {
666: DestroyWindow(ghwndTestDlg);
667: ghwndTestDlg = NULL;
668: }
669:
670:
671:
672: /************************************************************************
673: * ArrangeSettingsDialog
674: *
675: * This function displays the Arrange Settings dialog box.
676: *
677: ************************************************************************/
678:
679: VOID ArrangeSettingsDialog(VOID)
680: {
681: DlgBox(DID_ARRSETTINGS, (WNDPROC)ArrangeSettingsDlgProc);
682: }
683:
684:
685:
686: /************************************************************************
687: * ArrangeSettingsDlgProc
688: *
689: * This is the Arrange Settings dialog procedure.
690: *
691: ************************************************************************/
692:
693: DIALOGPROC ArrangeSettingsDlgProc(
694: HWND hwnd,
695: UINT msg,
696: WPARAM wParam,
697: LPARAM lParam)
698: {
699: switch (msg) {
700: case WM_INITDIALOG:
701: SendDlgItemMessage(hwnd, DID_ARRSETCXGRID, EM_LIMITTEXT,
702: CCHARRSETMAX, 0L);
703: SendDlgItemMessage(hwnd, DID_ARRSETCYGRID, EM_LIMITTEXT,
704: CCHARRSETMAX, 0L);
705: SetDlgItemInt(hwnd, DID_ARRSETCXGRID, gcxGrid, TRUE);
706: SetDlgItemInt(hwnd, DID_ARRSETCYGRID, gcyGrid, TRUE);
707:
708: SendDlgItemMessage(hwnd, DID_ARRSETXMARGIN, EM_LIMITTEXT,
709: CCHARRSETMAX, 0L);
710: SendDlgItemMessage(hwnd, DID_ARRSETYMARGIN, EM_LIMITTEXT,
711: CCHARRSETMAX, 0L);
712: SetDlgItemInt(hwnd, DID_ARRSETXMARGIN, gxMargin, TRUE);
713: SetDlgItemInt(hwnd, DID_ARRSETYMARGIN, gyMargin, TRUE);
714:
715: SendDlgItemMessage(hwnd, DID_ARRSETXSPACE, EM_LIMITTEXT,
716: CCHARRSETMAX, 0L);
717: SendDlgItemMessage(hwnd, DID_ARRSETYSPACE, EM_LIMITTEXT,
718: CCHARRSETMAX, 0L);
719: SetDlgItemInt(hwnd, DID_ARRSETXSPACE, gxSpace, TRUE);
720: SetDlgItemInt(hwnd, DID_ARRSETYSPACE, gySpace, TRUE);
721:
722: SendDlgItemMessage(hwnd, DID_ARRSETXMINPUSHSPACE, EM_LIMITTEXT,
723: CCHARRSETMAX, 0L);
724: SendDlgItemMessage(hwnd, DID_ARRSETXMAXPUSHSPACE, EM_LIMITTEXT,
725: CCHARRSETMAX, 0L);
726: SendDlgItemMessage(hwnd, DID_ARRSETYPUSHSPACE, EM_LIMITTEXT,
727: CCHARRSETMAX, 0L);
728: SetDlgItemInt(hwnd, DID_ARRSETXMINPUSHSPACE, gxMinPushSpace, TRUE);
729: SetDlgItemInt(hwnd, DID_ARRSETXMAXPUSHSPACE, gxMaxPushSpace, TRUE);
730: SetDlgItemInt(hwnd, DID_ARRSETYPUSHSPACE, gyPushSpace, TRUE);
731:
732: CenterWindow(hwnd);
733:
734: return TRUE;
735:
736: case WM_COMMAND:
737: switch (LOWORD(wParam)) {
738: INT cxGridNew;
739: INT cyGridNew;
740: INT xMarginNew;
741: INT yMarginNew;
742: INT xSpaceNew;
743: INT ySpaceNew;
744: INT xMinPushSpaceNew;
745: INT xMaxPushSpaceNew;
746: INT yPushSpaceNew;
747: BOOL fTranslated1;
748: BOOL fTranslated2;
749: BOOL fTranslated3;
750:
751: case IDOK:
752: cxGridNew = GetDlgItemInt(hwnd, DID_ARRSETCXGRID,
753: &fTranslated1, TRUE);
754: cyGridNew = GetDlgItemInt(hwnd, DID_ARRSETCYGRID,
755: &fTranslated2, TRUE);
756:
757: if (!fTranslated1 || !fTranslated2 ||
758: cxGridNew <= 0 || cyGridNew <= 0) {
759: Message(MSG_GTZERO, ids(IDS_GRID));
760: SetFocus(GetDlgItem(hwnd, DID_ARRSETCXGRID));
761: break;
762: }
763:
764: xMarginNew = GetDlgItemInt(hwnd, DID_ARRSETXMARGIN,
765: &fTranslated1, TRUE);
766: yMarginNew = GetDlgItemInt(hwnd, DID_ARRSETYMARGIN,
767: &fTranslated2, TRUE);
768:
769: if (!fTranslated1 || !fTranslated2 ||
770: xMarginNew < 0 || yMarginNew < 0) {
771: Message(MSG_POSITIVENUM, ids(IDS_MARGIN));
772: SetFocus(GetDlgItem(hwnd, DID_ARRSETXMARGIN));
773: break;
774: }
775:
776: xSpaceNew = GetDlgItemInt(hwnd, DID_ARRSETXSPACE,
777: &fTranslated1, TRUE);
778: ySpaceNew = GetDlgItemInt(hwnd, DID_ARRSETYSPACE,
779: &fTranslated2, TRUE);
780:
781: if (!fTranslated1 || !fTranslated2 ||
782: xSpaceNew < 0 || ySpaceNew < 0) {
783: Message(MSG_POSITIVENUM, ids(IDS_CTRLSPACING));
784: SetFocus(GetDlgItem(hwnd, DID_ARRSETXSPACE));
785: break;
786: }
787:
788: xMinPushSpaceNew = GetDlgItemInt(hwnd,
789: DID_ARRSETXMINPUSHSPACE, &fTranslated1, TRUE);
790: xMaxPushSpaceNew = GetDlgItemInt(hwnd,
791: DID_ARRSETXMAXPUSHSPACE, &fTranslated2, TRUE);
792: yPushSpaceNew = GetDlgItemInt(hwnd, DID_ARRSETYPUSHSPACE,
793: &fTranslated3, TRUE);
794:
795: if (!fTranslated1 || !fTranslated2 || !fTranslated3 ||
796: xMinPushSpaceNew < 0 || xMaxPushSpaceNew < 0 ||
797: yPushSpaceNew < 0) {
798: Message(MSG_POSITIVENUM, ids(IDS_PUSHSPACING));
799: SetFocus(GetDlgItem(hwnd, DID_ARRSETXMINPUSHSPACE));
800: break;
801: }
802:
803: if (xMinPushSpaceNew > xMaxPushSpaceNew) {
804: Message(MSG_MINGTMAXSPACE);
805: SetFocus(GetDlgItem(hwnd, DID_ARRSETXMINPUSHSPACE));
806: break;
807: }
808:
809: gcxGrid = cxGridNew;
810: gcyGrid = cyGridNew;
811: gxMargin = xMarginNew;
812: gyMargin = yMarginNew;
813: gxSpace = xSpaceNew;
814: gySpace = ySpaceNew;
815: gxMinPushSpace = xMinPushSpaceNew;
816: gxMaxPushSpace = xMaxPushSpaceNew;
817: gyPushSpace = yPushSpaceNew;
818:
819: EndDialog(hwnd, LOWORD(wParam));
820: break;
821:
822: case DID_ARRSETDEFAULTS:
823: SetDlgItemInt(hwnd, DID_ARRSETCXGRID,
824: DEFCXGRID, TRUE);
825: SetDlgItemInt(hwnd, DID_ARRSETCYGRID,
826: DEFCYGRID, TRUE);
827:
828: SetDlgItemInt(hwnd, DID_ARRSETXMARGIN,
829: DEFXMARGIN, TRUE);
830: SetDlgItemInt(hwnd, DID_ARRSETYMARGIN,
831: DEFYMARGIN, TRUE);
832:
833: SetDlgItemInt(hwnd, DID_ARRSETXSPACE,
834: DEFXSPACE, TRUE);
835: SetDlgItemInt(hwnd, DID_ARRSETYSPACE,
836: DEFYSPACE, TRUE);
837:
838: SetDlgItemInt(hwnd, DID_ARRSETXMINPUSHSPACE,
839: DEFXMINPUSHSPACE, TRUE);
840: SetDlgItemInt(hwnd, DID_ARRSETXMAXPUSHSPACE,
841: DEFXMAXPUSHSPACE, TRUE);
842: SetDlgItemInt(hwnd, DID_ARRSETYPUSHSPACE,
843: DEFYPUSHSPACE, TRUE);
844:
845: break;
846:
847: case IDCANCEL:
848: EndDialog(hwnd, IDCANCEL);
849: break;
850:
851: case IDHELP:
852: WinHelp(ghwndMain, gszHelpFile, HELP_CONTEXT,
853: HELPID_ARRSETTINGS);
854: break;
855: }
856:
857: return TRUE;
858:
859: default:
860: return FALSE;
861: }
862: }
863:
864:
865:
866: /************************************************************************
867: * AboutDlgProc
868: *
869: * This is the About Box dialog procedure.
870: *
871: ************************************************************************/
872:
873: DIALOGPROC AboutDlgProc(
874: HWND hwnd,
875: UINT msg,
876: WPARAM wParam,
877: LPARAM lParam)
878: {
879: switch (msg) {
880: case WM_INITDIALOG:
881: {
882: TCHAR szVersion[CCHTEXTMAX];
883:
884: lstrcpy(szVersion, ids(IDS_APPVERSION));
885: lstrcat(szVersion, ids(IDS_APPVERSIONMINOR));
886:
887: SetDlgItemText(hwnd, DID_ABOUTVERSION, szVersion);
888: CenterWindow(hwnd);
889: }
890:
891: return TRUE;
892:
893: case WM_COMMAND:
894: EndDialog(hwnd, IDOK);
895: return TRUE;
896:
897: default:
898: return FALSE;
899: }
900: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.