Hi, Changelog: dlls/commdlg : fontdlg.c Remember (do not reset) font size and style parameters in the initial dialog and when another font is selected. Rein. -- Rein Klazes rklazes@xxxxxxxxx
--- refwine/dlls/commdlg/fontdlg.c 2003-11-27 09:09:12.000000000 +0100 +++ mywine/dlls/commdlg/fontdlg.c 2003-11-27 16:39:09.000000000 +0100 @@ -543,6 +543,47 @@ return 1 ; } +static INT CFn_FitFontSize( HWND hDlg, int points) +{ + int i,n; + int ret = 0; + /* look for fitting font size in combobox3 */ + n=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0); + for (i=0;i<n;i++) + { + if (points == (int)SendDlgItemMessageA + (hDlg,cmb3, CB_GETITEMDATA,i,0)) + { + SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0); + SendMessageA(hDlg, WM_COMMAND, + MAKEWPARAM(cmb3, CBN_SELCHANGE), + (LPARAM)GetDlgItem(hDlg,cmb3)); + ret = 1; + break; + } + } + return ret; +} + +static INT CFn_FitFontStyle( HWND hDlg, LONG packedstyle ) +{ + LONG id; + int i, ret = 0; + /* look for fitting font style in combobox2 */ + for (i=0;i<TEXT_EXTRAS;i++) + { + id =SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0); + if (packedstyle == id) + { + SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0); + SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb2, CBN_SELCHANGE), + (LPARAM)GetDlgItem(hDlg,cmb2)); + ret = 1; + break; + } + } + return ret; +} /*********************************************************************** * FontStyleEnumProc32 [internal] @@ -566,7 +607,7 @@ { HDC hdc; int i,j,init=0; - long l; + long pstyle; LPLOGFONTA lpxx; HCURSOR hcursor=SetCursor(LoadCursorA(0,(LPSTR)IDC_WAIT)); @@ -646,25 +687,16 @@ j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName); if (j!=CB_ERR) { + INT height = (lpcf->iPointSize + 5) / 10; + pstyle=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0); SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0); SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg,cmb1)); init=1; /* look for fitting font style in combobox2 */ - l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0); - for (i=0;i<TEXT_EXTRAS;i++) - { - if (l==SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0)) - SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0); - } - + CFn_FitFontStyle(hDlg, pstyle); /* look for fitting font size in combobox3 */ - j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0); - for (i=0;i<j;i++) - { - if (lpxx->lfHeight==(int)SendDlgItemMessageA(hDlg,cmb3, CB_GETITEMDATA,i,0)) - SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0); - } + CFn_FitFontSize(hDlg, height); } } if (!init) @@ -835,9 +867,18 @@ hdc=((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg); if (hdc) { - SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0); - SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0); - i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0); + INT pointsize; /* save current pointsize */ + LONG pstyle; /* save current style */ + int idx2, idx3; + idx3 = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0); + pointsize = (int)SendDlgItemMessageA( hDlg, cmb3, CB_GETITEMDATA, + idx3, 0); + idx2 = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0); + pstyle = SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, idx2, 0); + + SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0); + SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0); + i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0); if (i!=CB_ERR) { HCURSOR hcursor=SetCursor(LoadCursorA(0,(LPSTR)IDC_WAIT)); @@ -850,8 +891,8 @@ s.hWnd2=GetDlgItem(hDlg, cmb3); s.lpcf32a=lpcf; EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s); - SendDlgItemMessageA(hDlg,cmb2, CB_SETCURSEL, 0, 0); - SendDlgItemMessageA(hDlg,cmb3, CB_SETCURSEL, 0, 0); + CFn_FitFontStyle(hDlg, pstyle); + CFn_FitFontSize(hDlg, pointsize); SetCursor(hcursor); } if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC)) @@ -920,7 +961,7 @@ InvalidateRect( hDlg, &wininfo.rcWindow, TRUE ); } } - break; + break; case cmb4: i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);