/****************************************************************** * fill_list_font * * Fills the font LB */ static BOOL fill_list_font(struct dialog_info* di) { SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L); EnumFontFamilies(PRIVATE(di->data)->hMemDC, NULL, font_enum, (LPARAM)di); if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)di->config.face_name) == LB_ERR) SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L); fill_list_size(di, TRUE); return TRUE; }
/****************************************************************** * WCUSER_FontDlgProc * * Dialog proc for the Font property sheet */ static INT_PTR WINAPI WCUSER_FontDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct dialog_info* di; switch (msg) { case WM_INITDIALOG: di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; di->hDlg = hDlg; SetWindowLongPtr(hDlg, DWLP_USER, (DWORD_PTR)di); /* remove dialog from this control, font will be reset when listboxes are filled */ SendDlgItemMessage(hDlg, IDC_FNT_PREVIEW, WM_SETFONT, 0L, 0L); fill_list_font(di); SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0, (di->config.def_attr >> 4) & 0x0F); SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0, di->config.def_attr & 0x0F); break; case WM_COMMAND: di = (struct dialog_info*)GetWindowLongPtr(hDlg, DWLP_USER); switch (LOWORD(wParam)) { case IDC_FNT_LIST_FONT: if (HIWORD(wParam) == LBN_SELCHANGE) { fill_list_size(di, FALSE); } break; case IDC_FNT_LIST_SIZE: if (HIWORD(wParam) == LBN_SELCHANGE) { select_font(di); } break; } break; case WM_NOTIFY: { NMHDR* nmhdr = (NMHDR*)lParam; DWORD val; di = (struct dialog_info*)GetWindowLongPtr(hDlg, DWLP_USER); switch (nmhdr->code) { case PSN_SETACTIVE: di->hDlg = hDlg; break; case PSN_APPLY: val = SendDlgItemMessage(hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L); if (val < di->nFont) { LOGFONT lf; WCUSER_FillLogFont(&lf, di->font[val].faceName, di->font[val].height, di->font[val].weight); DeleteObject(WCUSER_CopyFont(&di->config, di->data->hWnd, &lf, NULL)); } val = (GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0) << 4) | GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0); di->config.def_attr = val; SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR); return TRUE; default: return FALSE; } break; } default: return FALSE; } return TRUE; }
/****************************************************************** * WCUSER_FontDlgProc * * Dialog proc for the Font property sheet */ static BOOL WINAPI WCUSER_FontDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct dialog_info* di; switch (msg) { case WM_INITDIALOG: di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; di->hDlg = hDlg; SetWindowLong(hDlg, DWL_USER, (DWORD)di); /* remove dialog from this control, font will be reset when listboxes are filled */ SendDlgItemMessage(hDlg, IDC_FNT_PREVIEW, WM_SETFONT, 0L, 0L); fill_list_font(di); SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0, (di->config->def_attr >> 4) & 0x0F); SetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0, di->config->def_attr & 0x0F); break; case WM_COMMAND: di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); switch (LOWORD(wParam)) { case IDC_FNT_LIST_FONT: if (HIWORD(wParam) == LBN_SELCHANGE) { fill_list_size(di, FALSE); } break; case IDC_FNT_LIST_SIZE: if (HIWORD(wParam) == LBN_SELCHANGE) { select_font(di); } break; } break; case WM_NOTIFY: { NMHDR* nmhdr = (NMHDR*)lParam; DWORD val; di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); switch (nmhdr->code) { case PSN_SETACTIVE: di->hDlg = hDlg; break; case PSN_APPLY: val = SendDlgItemMessage(hDlg, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0L, 0L); if (val < di->nFont) (di->apply)(di, hDlg, WCUSER_ApplyToFont, val); (di->apply)(di, hDlg, WCUSER_ApplyToAttribute, (GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_BK), 0) << 4) | GetWindowLong(GetDlgItem(hDlg, IDC_FNT_COLOR_FG), 0)); SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); return TRUE; default: return FALSE; } break; } default: return FALSE; } return TRUE; }