winecfg: Simplify code by using SetDlgItemInt.

This commit is contained in:
Carlo Bramini 2015-08-16 12:08:41 +02:00 committed by Alexandre Julliard
parent a8c6fe39af
commit 75e03c13e1
1 changed files with 10 additions and 21 deletions

View File

@ -78,13 +78,13 @@ static void update_gui_for_desktop_mode(HWND dialog)
buf = get_reg_keyW(config_key, explorer_desktopsW, desktop_name, NULL); buf = get_reg_keyW(config_key, explorer_desktopsW, desktop_name, NULL);
if (buf && (bufindex = strchrW(buf, 'x'))) if (buf && (bufindex = strchrW(buf, 'x')))
{ {
*bufindex = 0; *bufindex++ = 0;
++bufindex;
SetWindowTextW(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf); SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, buf);
SetWindowTextW(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex); SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, bufindex);
} else { } else {
SetWindowTextA(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "800"); SetDlgItemTextA(dialog, IDC_DESKTOP_WIDTH, "800");
SetWindowTextA(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "600"); SetDlgItemTextA(dialog, IDC_DESKTOP_HEIGHT, "600");
} }
HeapFree(GetProcessHeap(), 0, buf); HeapFree(GetProcessHeap(), 0, buf);
@ -244,17 +244,14 @@ static INT read_logpixels_reg(void)
static void init_dpi_editbox(HWND hDlg) static void init_dpi_editbox(HWND hDlg)
{ {
static const WCHAR fmtW[] = {'%','u',0};
DWORD dwLogpixels; DWORD dwLogpixels;
WCHAR szLogpixels[MAXBUFLEN];
updating_ui = TRUE; updating_ui = TRUE;
dwLogpixels = read_logpixels_reg(); dwLogpixels = read_logpixels_reg();
WINE_TRACE("%u\n", dwLogpixels); WINE_TRACE("%u\n", dwLogpixels);
sprintfW(szLogpixels, fmtW, dwLogpixels); SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, dwLogpixels, FALSE);
SetDlgItemTextW(hDlg, IDC_RES_DPIEDIT, szLogpixels);
updating_ui = FALSE; updating_ui = FALSE;
} }
@ -276,7 +273,6 @@ static void init_trackbar(HWND hDlg)
static void update_dpi_trackbar_from_edit(HWND hDlg, BOOL fix) static void update_dpi_trackbar_from_edit(HWND hDlg, BOOL fix)
{ {
static const WCHAR fmtW[] = {'%','u',0};
DWORD dpi; DWORD dpi;
updating_ui = TRUE; updating_ui = TRUE;
@ -292,11 +288,8 @@ static void update_dpi_trackbar_from_edit(HWND hDlg, BOOL fix)
if (fixed_dpi != dpi) if (fixed_dpi != dpi)
{ {
WCHAR buf[16];
dpi = fixed_dpi; dpi = fixed_dpi;
sprintfW(buf, fmtW, dpi); SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, dpi, FALSE);
SetDlgItemTextW(hDlg, IDC_RES_DPIEDIT, buf);
} }
} }
@ -420,12 +413,8 @@ GraphDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_HSCROLL: case WM_HSCROLL:
switch (wParam) { switch (wParam) {
default: { default: {
static const WCHAR fmtW[] = {'%','d',0};
WCHAR buf[MAXBUFLEN];
int i = SendMessageW(GetDlgItem(hDlg, IDC_RES_TRACKBAR), TBM_GETPOS, 0, 0); int i = SendMessageW(GetDlgItem(hDlg, IDC_RES_TRACKBAR), TBM_GETPOS, 0, 0);
buf[0] = 0; SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, i, TRUE);
sprintfW(buf, fmtW, i);
SendMessageW(GetDlgItem(hDlg, IDC_RES_DPIEDIT), WM_SETTEXT, 0, (LPARAM) buf);
update_font_preview(hDlg); update_font_preview(hDlg);
set_reg_key_dwordW(HKEY_LOCAL_MACHINE, logpixels_reg, logpixels, i); set_reg_key_dwordW(HKEY_LOCAL_MACHINE, logpixels_reg, logpixels, i);
break; break;