1 /* dialog management for wineconsole
3 * Copyright (c) 2001 Eric Pouech
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "winecon_user.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
32 WCUSER_ApplyToCursorSize,
33 WCUSER_ApplyToHistorySize, WCUSER_ApplyToHistoryMode, WCUSER_ApplyToMenuMask,
34 WCUSER_ApplyToEditMode,
36 WCUSER_ApplyToFont, WCUSER_ApplyToAttribute,
38 WCUSER_ApplyToBufferSize, WCUSER_ApplyToWindow
43 struct config_data* config; /* pointer to configuration used for dialog box */
44 struct inner_data* data; /* pointer to current winecon info */
45 HWND hDlg; /* handle to active propsheet */
46 int nFont; /* number of font size in size LB */
51 WCHAR faceName[LF_FACESIZE];
52 } *font; /* array of nFont. index sync'ed with SIZE LB */
53 void (*apply)(struct dialog_info*, HWND, enum WCUSER_ApplyTo, DWORD);
56 /******************************************************************
61 static void WCUSER_ApplyDefault(struct dialog_info* di, HWND hDlg, enum WCUSER_ApplyTo apply, DWORD val)
65 case WCUSER_ApplyToCursorSize:
66 case WCUSER_ApplyToHistorySize:
67 case WCUSER_ApplyToHistoryMode:
68 case WCUSER_ApplyToBufferSize:
69 case WCUSER_ApplyToWindow:
70 /* not saving those for now... */
72 case WCUSER_ApplyToMenuMask:
73 di->config->menu_mask = val;
75 case WCUSER_ApplyToEditMode:
76 di->config->quick_edit = val;
78 case WCUSER_ApplyToFont:
83 WCUSER_FillLogFont(&lf, di->font[val].faceName,
84 di->font[val].height, di->font[val].weight);
85 hFont = WCUSER_CopyFont(di->config, PRIVATE(di->data)->hWnd, &lf);
89 case WCUSER_ApplyToAttribute:
90 di->config->def_attr = val;
93 WINECON_RegSave(di->config);
96 /******************************************************************
101 static void WCUSER_ApplyCurrent(struct dialog_info* di, HWND hDlg, enum WCUSER_ApplyTo apply, DWORD val)
105 case WCUSER_ApplyToCursorSize:
107 CONSOLE_CURSOR_INFO cinfo;
109 cinfo.bVisible = di->config->cursor_visible;
110 /* this shall update (through notif) curcfg */
111 SetConsoleCursorInfo(di->data->hConOut, &cinfo);
114 case WCUSER_ApplyToHistorySize:
115 di->config->history_size = val;
116 WINECON_SetHistorySize(di->data->hConIn, val);
118 case WCUSER_ApplyToHistoryMode:
119 WINECON_SetHistoryMode(di->data->hConIn, val);
121 case WCUSER_ApplyToMenuMask:
122 di->config->menu_mask = val;
124 case WCUSER_ApplyToEditMode:
125 di->config->quick_edit = val;
127 case WCUSER_ApplyToFont:
130 WCUSER_FillLogFont(&lf, di->font[val].faceName,
131 di->font[val].height, di->font[val].weight);
132 WCUSER_SetFont(di->data, &lf);
135 case WCUSER_ApplyToAttribute:
136 di->config->def_attr = val;
137 SetConsoleTextAttribute(di->data->hConOut, val);
139 case WCUSER_ApplyToBufferSize:
140 /* this shall update (through notif) curcfg */
141 SetConsoleScreenBufferSize(di->data->hConOut, *(COORD*)val);
143 case WCUSER_ApplyToWindow:
144 /* this shall update (through notif) curcfg */
145 SetConsoleWindowInfo(di->data->hConOut, FALSE, (SMALL_RECT*)val);
150 /******************************************************************
151 * WCUSER_OptionDlgProc
153 * Dialog prop for the option property sheet
155 static BOOL WINAPI WCUSER_OptionDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
157 struct dialog_info* di;
163 di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
165 SetWindowLong(hDlg, DWL_USER, (DWORD)di);
167 if (di->config->cursor_size <= 25) idc = IDC_OPT_CURSOR_SMALL;
168 else if (di->config->cursor_size <= 50) idc = IDC_OPT_CURSOR_MEDIUM;
169 else idc = IDC_OPT_CURSOR_LARGE;
170 SendDlgItemMessage(hDlg, idc, BM_SETCHECK, BST_CHECKED, 0L);
171 SetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, WINECON_GetHistorySize(di->data->hConIn), FALSE);
172 if (WINECON_GetHistoryMode(di->data->hConIn))
173 SendDlgItemMessage(hDlg, IDC_OPT_HIST_DOUBLE, BM_SETCHECK, BST_CHECKED, 0L);
174 SendDlgItemMessage(hDlg, IDC_OPT_CONF_CTRL, BM_SETCHECK,
175 (di->config->menu_mask & MK_CONTROL) ? BST_CHECKED : BST_UNCHECKED, 0L);
176 SendDlgItemMessage(hDlg, IDC_OPT_CONF_SHIFT, BM_SETCHECK,
177 (di->config->menu_mask & MK_SHIFT) ? BST_CHECKED : BST_UNCHECKED, 0L);
178 SendDlgItemMessage(hDlg, IDC_OPT_QUICK_EDIT, BM_SETCHECK,
179 (di->config->quick_edit) ? BST_CHECKED : BST_UNCHECKED, 0L);
180 return FALSE; /* because we set the focus */
185 NMHDR* nmhdr = (NMHDR*)lParam;
189 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
194 /* needed in propsheet to keep properly the selected radio button
195 * otherwise, the focus would be set to the first tab stop in the
196 * propsheet, which would always activate the first radio button
198 if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED)
199 idc = IDC_OPT_CURSOR_SMALL;
200 else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED)
201 idc = IDC_OPT_CURSOR_MEDIUM;
203 idc = IDC_OPT_CURSOR_LARGE;
204 PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, idc), TRUE);
208 if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) val = 25;
209 else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) val = 50;
211 (di->apply)(di, hDlg, WCUSER_ApplyToCursorSize, val);
213 val = GetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, &done, FALSE);
214 if (done) (di->apply)(di, hDlg, WCUSER_ApplyToHistorySize, val);
216 (di->apply)(di, hDlg, WCUSER_ApplyToHistoryMode,
217 IsDlgButtonChecked(hDlg, IDC_OPT_HIST_DOUBLE) & BST_CHECKED);
220 if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_CTRL) & BST_CHECKED) val |= MK_CONTROL;
221 if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_SHIFT) & BST_CHECKED) val |= MK_SHIFT;
222 (di->apply)(di, hDlg, WCUSER_ApplyToMenuMask, val);
224 val = (IsDlgButtonChecked(hDlg, IDC_OPT_QUICK_EDIT) & BST_CHECKED) ? TRUE : FALSE;
225 (di->apply)(di, hDlg, WCUSER_ApplyToEditMode, val);
227 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
240 /******************************************************************
241 * WCUSER_FontPreviewProc
243 * Window proc for font previewer in font property sheet
245 static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
250 SetWindowLong(hWnd, 0, 0);
253 return GetWindowLong(hWnd, 0);
255 SetWindowLong(hWnd, 0, wParam);
258 InvalidateRect(hWnd, NULL, TRUE);
264 HFONT hFont = (HFONT)GetWindowLong(hWnd, 0L);
265 if (hFont) DeleteObject(hFont);
273 struct dialog_info* di;
274 HFONT hFont, hOldFont;
276 di = (struct dialog_info*)GetWindowLong(GetParent(hWnd), DWL_USER);
277 BeginPaint(hWnd, &ps);
279 font_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
280 size_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
282 hFont = (HFONT)GetWindowLong(hWnd, 0L);
289 len1 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_1,
290 buf1, sizeof(buf1) / sizeof(WCHAR));
291 len2 = LoadString(GetModuleHandle(NULL), IDS_FNT_PREVIEW_2,
292 buf2, sizeof(buf2) / sizeof(WCHAR));
293 buf1[len1] = buf2[len2] = 0;
296 hOldFont = SelectObject(ps.hdc, hFont);
297 SetBkColor(ps.hdc, WCUSER_ColorMap[GetWindowLong(GetDlgItem(di->hDlg, IDC_FNT_COLOR_BK), 0)]);
298 SetTextColor(ps.hdc, WCUSER_ColorMap[GetWindowLong(GetDlgItem(di->hDlg, IDC_FNT_COLOR_FG), 0)]);
299 TextOut(ps.hdc, 0, 0, buf1, len1);
301 TextOut(ps.hdc, 0, di->font[size_idx].height, buf2, len2);
302 SelectObject(ps.hdc, hOldFont);
309 return DefWindowProc(hWnd, msg, wParam, lParam);
314 /******************************************************************
315 * WCUSER_ColorPreviewProc
317 * Window proc for color previewer in font property sheet
319 static LRESULT WINAPI WCUSER_ColorPreviewProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
330 BeginPaint(hWnd, &ps);
331 GetClientRect(hWnd, &client);
332 step = client.right / 8;
334 for (i = 0; i < 16; i++)
336 r.top = (i / 8) * (client.bottom / 2);
337 r.bottom = r.top + client.bottom / 2;
338 r.left = (i & 7) * step;
339 r.right = r.left + step;
340 hbr = CreateSolidBrush(WCUSER_ColorMap[i]);
341 FillRect(ps.hdc, &r, hbr);
343 if (GetWindowLong(hWnd, 0) == i)
348 hOldPen = SelectObject(ps.hdc, GetStockObject(WHITE_PEN));
349 r.right--; r.bottom--;
352 MoveToEx(ps.hdc, r.left, r.bottom, NULL);
353 LineTo(ps.hdc, r.left, r.top);
354 LineTo(ps.hdc, r.right, r.top);
355 SelectObject(ps.hdc, GetStockObject(BLACK_PEN));
356 LineTo(ps.hdc, r.right, r.bottom);
357 LineTo(ps.hdc, r.left, r.bottom);
360 r.left++; r.top++; r.right--; r.bottom--;
361 SelectObject(ps.hdc, GetStockObject(WHITE_PEN));
363 SelectObject(ps.hdc, hOldPen);
374 GetClientRect(hWnd, &client);
375 step = client.right / 8;
376 i = (HIWORD(lParam) >= client.bottom / 2) ? 8 : 0;
377 i += LOWORD(lParam) / step;
378 SetWindowLong(hWnd, 0, i);
379 InvalidateRect(GetDlgItem(GetParent(hWnd), IDC_FNT_PREVIEW), NULL, FALSE);
380 InvalidateRect(hWnd, NULL, FALSE);
384 return DefWindowProc(hWnd, msg, wParam, lParam);
389 /******************************************************************
392 * enumerates all the font names with at least one valid font
394 static int CALLBACK font_enum_size2(const LOGFONT* lf, const TEXTMETRIC* tm,
395 DWORD FontType, LPARAM lParam)
397 struct dialog_info* di = (struct dialog_info*)lParam;
399 WCUSER_DumpTextMetric(tm, FontType);
400 if (WCUSER_ValidateFontMetric(di->data, tm, FontType))
408 static int CALLBACK font_enum(const LOGFONT* lf, const TEXTMETRIC* tm,
409 DWORD FontType, LPARAM lParam)
411 struct dialog_info* di = (struct dialog_info*)lParam;
414 WCUSER_DumpLogFont("font", lf, FontType);
415 if (WCUSER_ValidateFont(di->data, lf) && (hdc = GetDC(di->hDlg)))
417 if (FontType & RASTER_FONTTYPE)
420 EnumFontFamilies(hdc, lf->lfFaceName, font_enum_size2, (LPARAM)di);
427 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_ADDSTRING,
428 0, (LPARAM)lf->lfFaceName);
430 ReleaseDC(di->hDlg, hdc);
436 /******************************************************************
441 static int CALLBACK font_enum_size(const LOGFONT* lf, const TEXTMETRIC* tm,
442 DWORD FontType, LPARAM lParam)
444 struct dialog_info* di = (struct dialog_info*)lParam;
446 static const WCHAR fmt[] = {'%','l','d',0};
448 WCUSER_DumpTextMetric(tm, FontType);
449 if (di->nFont == 0 && !(FontType & RASTER_FONTTYPE))
451 static const int sizes[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
454 di->nFont = sizeof(sizes) / sizeof(sizes[0]);
455 di->font = HeapAlloc(GetProcessHeap(), 0, di->nFont * sizeof(di->font[0]));
456 for (i = 0; i < di->nFont; i++)
458 /* drop sizes where window size wouldn't fit on screen */
459 if (sizes[i] * di->data->curcfg.win_height > GetSystemMetrics(SM_CYSCREEN))
464 di->font[i].height = sizes[i];
465 di->font[i].weight = 400;
466 lstrcpy(di->font[i].faceName, lf->lfFaceName);
467 wsprintf(buf, fmt, sizes[i]);
468 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_INSERTSTRING, i, (LPARAM)buf);
470 /* don't need to enumerate other */
474 if (WCUSER_ValidateFontMetric(di->data, tm, FontType))
478 /* we want the string to be sorted with a numeric order, not a lexicographic...
479 * do the job by hand... get where to insert the new string
481 for (idx = 0; idx < di->nFont && tm->tmHeight > di->font[idx].height; idx++);
482 while (idx < di->nFont &&
483 tm->tmHeight == di->font[idx].height &&
484 tm->tmWeight > di->font[idx].weight)
486 if (idx == di->nFont ||
487 tm->tmHeight != di->font[idx].height ||
488 tm->tmWeight < di->font[idx].weight)
490 /* here we need to add the new entry */
491 wsprintf(buf, fmt, tm->tmHeight);
492 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_INSERTSTRING, idx, (LPARAM)buf);
494 /* now grow our arrays and insert the values at the same index than in the list box */
495 di->font = HeapReAlloc(GetProcessHeap(), 0, di->font, sizeof(*di->font) * (di->nFont + 1));
496 if (idx != di->nFont)
497 memmove(&di->font[idx + 1], &di->font[idx], (di->nFont - idx) * sizeof(*di->font));
498 di->font[idx].height = tm->tmHeight;
499 di->font[idx].weight = tm->tmWeight;
500 lstrcpy(di->font[idx].faceName, lf->lfFaceName);
507 /******************************************************************
512 static BOOL select_font(struct dialog_info* di)
514 int font_idx, size_idx;
518 HFONT hFont, hOldFont;
519 struct config_data config;
521 font_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
522 size_idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
524 if (font_idx < 0 || size_idx < 0 || size_idx >= di->nFont)
527 WCUSER_FillLogFont(&lf, di->font[size_idx].faceName,
528 di->font[size_idx].height, di->font[size_idx].weight);
529 hFont = WCUSER_CopyFont(&config, PRIVATE(di->data)->hWnd, &lf);
530 if (!hFont) return FALSE;
532 if (config.cell_height != di->font[size_idx].height)
533 WINE_TRACE("select_font: mismatched heights (%u<>%u)\n",
534 config.cell_height, di->font[size_idx].height);
535 hOldFont = (HFONT)SendDlgItemMessage(di->hDlg, IDC_FNT_PREVIEW, WM_GETFONT, 0L, 0L);
537 SendDlgItemMessage(di->hDlg, IDC_FNT_PREVIEW, WM_SETFONT, (DWORD)hFont, TRUE);
538 if (hOldFont) DeleteObject(hOldFont);
540 LoadString(GetModuleHandle(NULL), IDS_FNT_DISPLAY, fmt, sizeof(fmt) / sizeof(WCHAR));
541 wsprintf(buf, fmt, config.cell_width, config.cell_height);
543 SendDlgItemMessage(di->hDlg, IDC_FNT_FONT_INFO, WM_SETTEXT, 0, (LPARAM)buf);
548 /******************************************************************
551 * fills the size list box according to selected family in font LB
553 static BOOL fill_list_size(struct dialog_info* di, BOOL doInit)
557 WCHAR lfFaceName[LF_FACESIZE];
559 idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
560 if (idx < 0) return FALSE;
562 hdc = GetDC(di->hDlg);
563 if (!hdc) return FALSE;
565 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETTEXT, idx, (LPARAM)lfFaceName);
566 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_RESETCONTENT, 0L, 0L);
567 if (di->font) HeapFree(GetProcessHeap(), 0, di->font);
571 EnumFontFamilies(hdc, lfFaceName, font_enum_size, (LPARAM)di);
572 ReleaseDC(di->hDlg, hdc);
578 for (idx = 0; idx < di->nFont; idx++)
580 if (!lstrcmp(di->font[idx].faceName, di->config->face_name) &&
581 di->font[idx].height == di->config->cell_height &&
582 di->font[idx].weight == di->config->font_weight)
584 if (ref == -1) ref = idx;
585 else WINE_TRACE("Several matches found: ref=%d idx=%d\n", ref, idx);
588 idx = (ref == -1) ? 0 : ref;
592 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_SETCURSEL, idx, 0L);
597 /******************************************************************
602 static BOOL fill_list_font(struct dialog_info* di)
606 hdc = GetDC(di->hDlg);
607 if (!hdc) return FALSE;
609 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L);
610 EnumFontFamilies(hdc, NULL, font_enum, (LPARAM)di);
611 ReleaseDC(di->hDlg, hdc);
612 if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING,
613 (WPARAM)-1, (LPARAM)di->config->face_name) == LB_ERR)
614 SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L);
615 fill_list_size(di, TRUE);
619 /******************************************************************
622 * Dialog proc for the Font property sheet
624 static BOOL WINAPI WCUSER_FontDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
626 struct dialog_info* di;
631 di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
633 SetWindowLong(hDlg, DWL_USER, (DWORD)di);
634 /* remove dialog from this control, font will be reset when listboxes are filled */
635 SendDlgItemMessage(hDlg, IDC_FNT_PREVIEW, WM_SETFONT, 0L, 0L);
637 SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0, (di->config->def_attr >> 4) & 0x0F);
638 SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0, di->config->def_attr & 0x0F);
641 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
642 switch (LOWORD(wParam))
644 case IDC_FNT_LIST_FONT:
645 if (HIWORD(wParam) == LBN_SELCHANGE)
647 fill_list_size(di, FALSE);
650 case IDC_FNT_LIST_SIZE:
651 if (HIWORD(wParam) == LBN_SELCHANGE)
660 NMHDR* nmhdr = (NMHDR*)lParam;
663 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
670 val = SendDlgItemMessage(hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L);
672 if (val < di->nFont) (di->apply)(di, hDlg, WCUSER_ApplyToFont, val);
674 (di->apply)(di, hDlg, WCUSER_ApplyToAttribute,
675 (GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0) << 4) |
676 GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0));
678 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
691 /******************************************************************
692 * WCUSER_ConfigDlgProc
694 * Dialog proc for the config property sheet
696 static BOOL WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
698 struct dialog_info* di;
703 di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam;
705 SetWindowLong(hDlg, DWL_USER, (DWORD)di);
706 SetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, di->config->sb_width, FALSE);
707 SetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, di->config->sb_height, FALSE);
708 SetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, di->config->win_width, FALSE);
709 SetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, di->config->win_height, FALSE);
712 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
713 switch (LOWORD(wParam))
719 NMHDR* nmhdr = (NMHDR*)lParam;
724 di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER);
731 sb.X = GetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, &st_w, FALSE);
732 sb.Y = GetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, &st_h, FALSE);
733 if (st_w && st_h && (sb.X != di->config->sb_width || sb.Y != di->config->sb_height))
735 (di->apply)(di, hDlg, WCUSER_ApplyToBufferSize, (DWORD)&sb);
738 pos.Right = GetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, &st_w, FALSE);
739 pos.Bottom = GetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, &st_h, FALSE);
741 (pos.Right != di->config->win_width || pos.Bottom != di->config->win_height))
743 pos.Left = pos.Top = 0;
744 pos.Right--; pos.Bottom--;
745 (di->apply)(di, hDlg, WCUSER_ApplyToWindow, (DWORD)&pos);
747 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
760 /******************************************************************
761 * WCUSER_GetProperties
763 * Runs the dialog box to set up the winconsole options
765 BOOL WCUSER_GetProperties(struct inner_data* data, BOOL current)
767 HPROPSHEETPAGE psPage[3];
769 PROPSHEETHEADER psHead;
772 static const WCHAR szFntPreview[] = {'W','i','n','e','C','o','n','F','o','n','t','P','r','e','v','i','e','w',0};
773 static const WCHAR szColorPreview[] = {'W','i','n','e','C','o','n','C','o','l','o','r','P','r','e','v','i','e','w',0};
774 struct dialog_info di;
776 InitCommonControls();
781 di.config = &data->curcfg;
782 di.apply = WCUSER_ApplyCurrent;
786 di.config = &data->defcfg;
787 di.apply = WCUSER_ApplyDefault;
793 wndclass.lpfnWndProc = WCUSER_FontPreviewProc;
794 wndclass.cbClsExtra = 0;
795 wndclass.cbWndExtra = 4; /* for hFont */
796 wndclass.hInstance = GetModuleHandle(NULL);
798 wndclass.hCursor = LoadCursor(0, IDC_ARROW);
799 wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
800 wndclass.lpszMenuName = NULL;
801 wndclass.lpszClassName = szFntPreview;
802 RegisterClass(&wndclass);
805 wndclass.lpfnWndProc = WCUSER_ColorPreviewProc;
806 wndclass.cbClsExtra = 0;
807 wndclass.cbWndExtra = sizeof(DWORD);
808 wndclass.hInstance = GetModuleHandle(NULL);
810 wndclass.hCursor = LoadCursor(0, IDC_ARROW);
811 wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
812 wndclass.lpszMenuName = NULL;
813 wndclass.lpszClassName = szColorPreview;
814 RegisterClass(&wndclass);
816 memset(&psp, 0, sizeof(psp));
817 psp.dwSize = sizeof(psp);
819 psp.hInstance = wndclass.hInstance;
820 psp.lParam = (LPARAM)&di;
822 psp.u.pszTemplate = MAKEINTRESOURCE(IDD_OPTION);
823 psp.pfnDlgProc = WCUSER_OptionDlgProc;
824 psPage[0] = CreatePropertySheetPage(&psp);
826 psp.u.pszTemplate = MAKEINTRESOURCE(IDD_FONT);
827 psp.pfnDlgProc = WCUSER_FontDlgProc;
828 psPage[1] = CreatePropertySheetPage(&psp);
830 psp.u.pszTemplate = MAKEINTRESOURCE(IDD_CONFIG);
831 psp.pfnDlgProc = WCUSER_ConfigDlgProc;
832 psPage[2] = CreatePropertySheetPage(&psp);
834 memset(&psHead, 0, sizeof(psHead));
835 psHead.dwSize = sizeof(psHead);
837 if (!LoadString(GetModuleHandle(NULL),
838 (current) ? IDS_DLG_TIT_CURRENT : IDS_DLG_TIT_DEFAULT,
839 buff, sizeof(buff) / sizeof(buff[0])))
849 psHead.pszCaption = buff;
851 psHead.hwndParent = PRIVATE(data)->hWnd;
852 psHead.u3.phpage = psPage;
854 PropertySheet(&psHead);