Module: wine Branch: master Commit: 77d65c39486ffc2b4c17aec958e361b180a029a1 URL: https://source.winehq.org/git/wine.git/?a=commit;h=77d65c39486ffc2b4c17aec95...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Jan 18 19:51:06 2018 +0100
comdlg32: Add a helper function to select a combo box item.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/comdlg32/fontdlg.c | 60 ++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 38 deletions(-)
diff --git a/dlls/comdlg32/fontdlg.c b/dlls/comdlg32/fontdlg.c index 82992cb..768ca4a 100644 --- a/dlls/comdlg32/fontdlg.c +++ b/dlls/comdlg32/fontdlg.c @@ -483,6 +483,16 @@ static inline void CFn_ReleaseDC(const CHOOSEFONTW *lpcf, HDC hdc) ReleaseDC(0, hdc); }
+/************************************************************************* + * select_combo_item [internal] + */ +static void select_combo_item( HWND dialog, int id, int sel ) +{ + HWND combo = GetDlgItem( dialog, id ); + SendMessageW( combo, CB_SETCURSEL, sel, 0 ); + SendMessageW( dialog, WM_COMMAND, MAKEWPARAM( id, CBN_SELCHANGE ), (LPARAM)combo ); +} + /*********************************************************************** * AddFontStyle [internal] */ @@ -543,10 +553,7 @@ static void CFn_FitFontSize( HWND hDlg, int points) if (points == (int)SendDlgItemMessageW (hDlg,cmb3, CB_GETITEMDATA,i,0)) { - SendDlgItemMessageW(hDlg,cmb3,CB_SETCURSEL,i,0); - SendMessageW(hDlg, WM_COMMAND, - MAKEWPARAM(cmb3, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb3)); + select_combo_item( hDlg, cmb3, i ); return; } } @@ -559,21 +566,17 @@ static BOOL CFn_FitFontStyle( HWND hDlg, LONG packedstyle ) { LONG id; int i; - BOOL ret = FALSE; /* look for fitting font style in combobox2 */ for (i=0;i<TEXT_EXTRAS;i++) { id = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0); if (packedstyle == id) { - SendDlgItemMessageW(hDlg, cmb2, CB_SETCURSEL, i, 0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb2, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb2)); - ret = TRUE; - break; + select_combo_item( hDlg, cmb2, i ); + return TRUE; } } - return ret; + return FALSE; }
@@ -587,16 +590,12 @@ static BOOL CFn_FitCharSet( HWND hDlg, int charset ) cs =SendDlgItemMessageW(hDlg, cmb5, CB_GETITEMDATA, i, 0); if (charset == cs) { - SendDlgItemMessageW(hDlg, cmb5, CB_SETCURSEL, i, 0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb2)); + select_combo_item( hDlg, cmb5, i ); return TRUE; } } /* no charset fits: select the first one in the list */ - SendDlgItemMessageW(hDlg, cmb5, CB_SETCURSEL, 0, 0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb2)); + select_combo_item( hDlg, cmb5, 0 ); return FALSE; }
@@ -729,9 +728,7 @@ static LRESULT CFn_WMInitDialog(HWND hDlg, LPARAM lParam, LPCHOOSEFONTW lpcf) points = MulDiv( height, 72, GetScreenDPI()); pstyle = MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD: FW_NORMAL,lpxx->lfItalic !=0); - SendDlgItemMessageW(hDlg, cmb1, CB_SETCURSEL, j, 0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb1)); + select_combo_item( hDlg, cmb1, j ); init = TRUE; /* look for fitting font style in combobox2 */ CFn_FitFontStyle(hDlg, pstyle); @@ -742,18 +739,10 @@ static LRESULT CFn_WMInitDialog(HWND hDlg, LPARAM lParam, LPCHOOSEFONTW lpcf) } if (!init) { - SendDlgItemMessageW(hDlg,cmb1,CB_SETCURSEL,0,0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb1)); - SendDlgItemMessageW(hDlg,cmb2,CB_SETCURSEL,0,0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb2, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb1)); - SendDlgItemMessageW(hDlg,cmb3,CB_SETCURSEL,0,0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb3, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb3)); - SendDlgItemMessageW(hDlg,cmb5,CB_SETCURSEL,0,0); - SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE), - (LPARAM)GetDlgItem(hDlg,cmb5)); + select_combo_item( hDlg, cmb1, 0 ); + select_combo_item( hDlg, cmb2, 0 ); + select_combo_item( hDlg, cmb3, 0 ); + select_combo_item( hDlg, cmb5, 0 ); } /* limit text length user can type in as font size */ SendDlgItemMessageW(hDlg, cmb3, CB_LIMITTEXT, 5, 0); @@ -761,12 +750,7 @@ static LRESULT CFn_WMInitDialog(HWND hDlg, LPARAM lParam, LPCHOOSEFONTW lpcf) if ((lpcf->Flags & CF_USESTYLE) && lpcf->lpszStyle) { j=SendDlgItemMessageW(hDlg,cmb2,CB_FINDSTRING,-1,(LPARAM)lpcf->lpszStyle); - if (j!=CB_ERR) - { - j=SendDlgItemMessageW(hDlg,cmb2,CB_SETCURSEL,j,0); - SendMessageW(hDlg,WM_COMMAND,cmb2, - MAKELONG(LOWORD(GetDlgItem(hDlg,cmb2)),CBN_SELCHANGE)); - } + if (j!=CB_ERR) select_combo_item( hDlg, cmb2, j ); } CFn_ReleaseDC(lpcf, hdc); SetCursor(hcursor);