2003-08-30 02:40:46 +02:00
|
|
|
/*
|
2004-07-30 03:35:13 +02:00
|
|
|
* Graphics configuration code
|
2003-08-30 02:40:46 +02:00
|
|
|
*
|
|
|
|
* Copyright 2003 Mark Westcott
|
2004-09-28 05:16:43 +02:00
|
|
|
* Copyright 2003-2004 Mike Hearn
|
2005-07-12 20:11:11 +02:00
|
|
|
* Copyright 2005 Raphael Junqueira
|
2003-08-30 02:40:46 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-30 02:40:46 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-08-30 02:40:46 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
#include <windows.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <wine/debug.h>
|
|
|
|
|
2003-08-30 02:40:46 +02:00
|
|
|
#include "resource.h"
|
|
|
|
#include "winecfg.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
|
|
|
|
|
2008-04-23 02:56:36 +02:00
|
|
|
#define RES_MAXLEN 5 /* max number of digits in a screen dimension. 5 digits should be plenty */
|
2007-07-31 00:16:51 +02:00
|
|
|
#define MINDPI 96
|
2008-04-29 17:27:15 +02:00
|
|
|
#define MAXDPI 480
|
2007-07-31 00:16:51 +02:00
|
|
|
#define DEFDPI 96
|
2003-09-08 20:58:07 +02:00
|
|
|
|
2008-03-28 11:04:11 +01:00
|
|
|
#define IDT_DPIEDIT 0x1234
|
|
|
|
|
2018-05-15 12:37:28 +02:00
|
|
|
static const UINT dpi_values[] = { 96, 120, 144, 168, 192, 216, 240, 288, 336, 384, 432, 480 };
|
2008-04-25 14:36:45 +02:00
|
|
|
|
2013-10-16 23:38:33 +02:00
|
|
|
static BOOL updating_ui;
|
2003-09-08 20:58:07 +02:00
|
|
|
|
2008-04-25 14:36:45 +02:00
|
|
|
/* convert the x11 desktop key to the new explorer config */
|
|
|
|
static void convert_x11_desktop_key(void)
|
|
|
|
{
|
2021-09-07 17:14:22 +02:00
|
|
|
WCHAR *buf;
|
2008-04-25 14:36:45 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
if (!(buf = get_reg_key(config_key, L"X11 Driver", L"Desktop", NULL))) return;
|
|
|
|
set_reg_key(config_key, L"Explorer\\Desktops", L"Default", buf);
|
|
|
|
set_reg_key(config_key, L"Explorer", L"Desktop", L"Default");
|
|
|
|
set_reg_key(config_key, L"X11 Driver", L"Desktop", NULL);
|
2008-04-25 14:36:45 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_gui_for_desktop_mode(HWND dialog)
|
|
|
|
{
|
|
|
|
WCHAR *buf, *bufindex;
|
2021-09-07 13:41:35 +02:00
|
|
|
const WCHAR *desktop_name = current_app ? current_app : L"Default";
|
2003-09-08 20:58:07 +02:00
|
|
|
|
2005-10-18 12:35:41 +02:00
|
|
|
WINE_TRACE("\n");
|
2004-09-28 05:55:16 +02:00
|
|
|
updating_ui = TRUE;
|
2006-03-29 13:49:36 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
buf = get_reg_key(config_key, L"Explorer\\Desktops", desktop_name, NULL);
|
2021-09-07 13:23:32 +02:00
|
|
|
if (buf && (bufindex = wcschr(buf, 'x')))
|
2006-03-29 13:49:36 +02:00
|
|
|
{
|
2015-08-16 12:08:41 +02:00
|
|
|
*bufindex++ = 0;
|
|
|
|
|
|
|
|
SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, buf);
|
|
|
|
SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, bufindex);
|
2008-04-25 14:36:45 +02:00
|
|
|
} else {
|
2021-09-07 17:14:22 +02:00
|
|
|
SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, L"800");
|
|
|
|
SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, L"600");
|
2006-03-29 13:49:36 +02:00
|
|
|
}
|
2008-04-25 14:36:45 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2006-03-29 13:49:36 +02:00
|
|
|
|
2003-09-08 20:58:07 +02:00
|
|
|
/* do we have desktop mode enabled? */
|
2021-09-07 17:14:22 +02:00
|
|
|
if (reg_key_exists(config_key, keypath(L"Explorer"), L"Desktop"))
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
2003-09-30 02:27:55 +02:00
|
|
|
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
|
2008-04-25 14:36:45 +02:00
|
|
|
enable(IDC_DESKTOP_WIDTH);
|
|
|
|
enable(IDC_DESKTOP_HEIGHT);
|
|
|
|
enable(IDC_DESKTOP_SIZE);
|
|
|
|
enable(IDC_DESKTOP_BY);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2008-04-25 14:36:45 +02:00
|
|
|
else
|
2004-09-28 05:55:16 +02:00
|
|
|
{
|
2003-09-30 02:27:55 +02:00
|
|
|
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_UNCHECKED);
|
|
|
|
disable(IDC_DESKTOP_WIDTH);
|
|
|
|
disable(IDC_DESKTOP_HEIGHT);
|
|
|
|
disable(IDC_DESKTOP_SIZE);
|
|
|
|
disable(IDC_DESKTOP_BY);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
updating_ui = FALSE;
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
|
|
|
|
2021-08-18 14:06:35 +02:00
|
|
|
static BOOL can_enable_desktop(void)
|
|
|
|
{
|
2021-09-07 17:14:22 +02:00
|
|
|
WCHAR *value;
|
2021-08-18 14:06:35 +02:00
|
|
|
UINT guid_atom;
|
|
|
|
BOOL ret = FALSE;
|
2021-09-07 17:14:22 +02:00
|
|
|
WCHAR key[sizeof("System\\CurrentControlSet\\Control\\Video\\{}\\0000") + 40];
|
2021-08-18 14:06:35 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
guid_atom = HandleToULong(GetPropW(GetDesktopWindow(), L"__wine_display_device_guid"));
|
|
|
|
wcscpy( key, L"System\\CurrentControlSet\\Control\\Video\\{" );
|
|
|
|
if (!GlobalGetAtomNameW(guid_atom, key + wcslen(key), 40)) return ret;
|
|
|
|
wcscat( key, L"}\\0000" );
|
|
|
|
if ((value = get_reg_key(HKEY_LOCAL_MACHINE, key, L"GraphicsDriver", NULL)))
|
2021-08-18 14:06:35 +02:00
|
|
|
{
|
2021-09-07 17:14:22 +02:00
|
|
|
if(wcscmp(value, L"winemac.drv"))
|
2021-08-18 14:06:35 +02:00
|
|
|
ret = TRUE;
|
|
|
|
HeapFree(GetProcessHeap(), 0, value);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:51:48 +02:00
|
|
|
static void init_dialog(HWND dialog)
|
|
|
|
{
|
2021-09-07 17:14:22 +02:00
|
|
|
WCHAR *buf;
|
2021-08-18 14:06:35 +02:00
|
|
|
BOOL enable_desktop;
|
2005-09-26 11:51:48 +02:00
|
|
|
|
2008-04-25 14:36:45 +02:00
|
|
|
convert_x11_desktop_key();
|
2021-08-18 14:06:35 +02:00
|
|
|
if ((enable_desktop = can_enable_desktop()))
|
|
|
|
update_gui_for_desktop_mode(dialog);
|
|
|
|
else
|
|
|
|
disable(IDC_ENABLE_DESKTOP);
|
2005-09-26 11:51:48 +02:00
|
|
|
|
|
|
|
updating_ui = TRUE;
|
2012-01-20 12:42:33 +01:00
|
|
|
|
2021-08-18 14:06:35 +02:00
|
|
|
if (enable_desktop)
|
|
|
|
{
|
|
|
|
SendDlgItemMessageW(dialog, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
|
|
|
|
SendDlgItemMessageW(dialog, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
|
|
|
|
}
|
2003-09-18 06:32:01 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"GrabFullscreen", L"N");
|
2003-09-18 06:32:01 +02:00
|
|
|
if (IS_OPTION_TRUE(*buf))
|
2011-05-11 14:49:07 +02:00
|
|
|
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_CHECKED);
|
2003-09-18 06:32:01 +02:00
|
|
|
else
|
2011-05-11 14:49:07 +02:00
|
|
|
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_UNCHECKED);
|
2004-09-28 05:55:16 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2003-09-22 23:13:51 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"Y");
|
2005-12-22 11:15:32 +01:00
|
|
|
if (IS_OPTION_TRUE(*buf))
|
|
|
|
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_CHECKED);
|
|
|
|
else
|
|
|
|
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_UNCHECKED);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"Y");
|
2008-04-10 22:05:13 +02:00
|
|
|
if (IS_OPTION_TRUE(*buf))
|
|
|
|
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_CHECKED);
|
|
|
|
else
|
|
|
|
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_UNCHECKED);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
updating_ui = FALSE;
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2003-08-30 02:40:46 +02:00
|
|
|
|
2008-04-25 14:36:45 +02:00
|
|
|
static void set_from_desktop_edits(HWND dialog)
|
|
|
|
{
|
2021-09-07 13:41:35 +02:00
|
|
|
WCHAR *width, *height;
|
|
|
|
int w = 800, h = 600;
|
|
|
|
WCHAR buffer[32];
|
|
|
|
const WCHAR *desktop_name = current_app ? current_app : L"Default";
|
2003-08-30 02:40:46 +02:00
|
|
|
|
2004-09-28 06:05:55 +02:00
|
|
|
if (updating_ui) return;
|
2021-09-07 13:41:35 +02:00
|
|
|
|
2003-09-08 20:58:07 +02:00
|
|
|
WINE_TRACE("\n");
|
2003-08-30 02:40:46 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
width = get_text(dialog, IDC_DESKTOP_WIDTH);
|
|
|
|
height = get_text(dialog, IDC_DESKTOP_HEIGHT);
|
2004-09-28 06:05:55 +02:00
|
|
|
|
2021-09-07 13:41:35 +02:00
|
|
|
if (width && width[0]) w = max( 640, wcstol(width, NULL, 10) );
|
|
|
|
if (height && height[0]) h = max( 480, wcstol(height, NULL, 10) );
|
2004-09-28 06:05:55 +02:00
|
|
|
|
2021-09-07 13:41:35 +02:00
|
|
|
swprintf( buffer, ARRAY_SIZE(buffer), L"%ux%u", w, h );
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, L"Explorer\\Desktops", desktop_name, buffer);
|
|
|
|
set_reg_key(config_key, keypath(L"Explorer"), L"Desktop", desktop_name);
|
2008-04-25 14:36:45 +02:00
|
|
|
|
2004-09-28 05:55:16 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, width);
|
|
|
|
HeapFree(GetProcessHeap(), 0, height);
|
2003-08-30 02:40:46 +02:00
|
|
|
}
|
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static void on_enable_desktop_clicked(HWND dialog) {
|
2003-09-08 20:58:07 +02:00
|
|
|
WINE_TRACE("\n");
|
2004-09-28 06:05:55 +02:00
|
|
|
|
|
|
|
if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
|
2005-01-14 20:48:41 +01:00
|
|
|
set_from_desktop_edits(dialog);
|
2003-09-08 20:58:07 +02:00
|
|
|
} else {
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"Explorer"), L"Desktop", NULL);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2004-09-28 06:05:55 +02:00
|
|
|
|
|
|
|
update_gui_for_desktop_mode(dialog);
|
2003-09-08 20:58:07 +02:00
|
|
|
}
|
2003-09-18 06:32:01 +02:00
|
|
|
|
2005-12-22 11:15:32 +01:00
|
|
|
static void on_enable_managed_clicked(HWND dialog) {
|
|
|
|
WINE_TRACE("\n");
|
|
|
|
|
|
|
|
if (IsDlgButtonChecked(dialog, IDC_ENABLE_MANAGED) == BST_CHECKED) {
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"Y");
|
2005-12-22 11:15:32 +01:00
|
|
|
} else {
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"N");
|
2005-12-22 11:15:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-10 22:05:13 +02:00
|
|
|
static void on_enable_decorated_clicked(HWND dialog) {
|
|
|
|
WINE_TRACE("\n");
|
|
|
|
|
|
|
|
if (IsDlgButtonChecked(dialog, IDC_ENABLE_DECORATED) == BST_CHECKED) {
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"Y");
|
2008-04-10 22:05:13 +02:00
|
|
|
} else {
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"N");
|
2008-04-10 22:05:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-11 14:49:07 +02:00
|
|
|
static void on_fullscreen_grab_clicked(HWND dialog)
|
|
|
|
{
|
|
|
|
if (IsDlgButtonChecked(dialog, IDC_FULLSCREEN_GRAB) == BST_CHECKED)
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"X11 Driver"), L"GrabFullscreen", L"Y");
|
2003-09-18 06:32:01 +02:00
|
|
|
else
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key(config_key, keypath(L"X11 Driver"), L"GrabFullscreen", L"N");
|
2003-09-18 06:32:01 +02:00
|
|
|
}
|
|
|
|
|
2007-07-31 00:16:51 +02:00
|
|
|
static INT read_logpixels_reg(void)
|
|
|
|
{
|
|
|
|
DWORD dwLogPixels;
|
2021-09-07 17:14:22 +02:00
|
|
|
WCHAR *buf = get_reg_key(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", NULL);
|
|
|
|
if (!buf) buf = get_reg_key(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", NULL);
|
2007-08-07 21:02:26 +02:00
|
|
|
dwLogPixels = buf ? *buf : DEFDPI;
|
2007-07-31 00:16:51 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
return dwLogPixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_dpi_editbox(HWND hDlg)
|
|
|
|
{
|
|
|
|
DWORD dwLogpixels;
|
|
|
|
|
2007-08-07 21:02:27 +02:00
|
|
|
updating_ui = TRUE;
|
|
|
|
|
2007-07-31 00:16:51 +02:00
|
|
|
dwLogpixels = read_logpixels_reg();
|
2008-03-28 11:04:11 +01:00
|
|
|
WINE_TRACE("%u\n", dwLogpixels);
|
2007-07-31 00:16:51 +02:00
|
|
|
|
2015-08-16 12:08:41 +02:00
|
|
|
SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, dwLogpixels, FALSE);
|
2007-08-07 21:02:27 +02:00
|
|
|
|
|
|
|
updating_ui = FALSE;
|
2007-07-31 00:16:51 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 12:37:28 +02:00
|
|
|
static int get_trackbar_pos( UINT dpi )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dpi_values) - 1; i++)
|
|
|
|
if ((dpi_values[i] + dpi_values[i + 1]) / 2 >= dpi) break;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2007-07-31 00:16:51 +02:00
|
|
|
static void init_trackbar(HWND hDlg)
|
|
|
|
{
|
|
|
|
HWND hTrackBar = GetDlgItem(hDlg, IDC_RES_TRACKBAR);
|
|
|
|
DWORD dwLogpixels;
|
|
|
|
|
2007-08-07 21:02:27 +02:00
|
|
|
updating_ui = TRUE;
|
|
|
|
|
2007-07-31 00:16:51 +02:00
|
|
|
dwLogpixels = read_logpixels_reg();
|
|
|
|
|
2018-05-15 12:37:28 +02:00
|
|
|
SendMessageW(hTrackBar, TBM_SETRANGE, TRUE, MAKELONG(0, ARRAY_SIZE(dpi_values)-1));
|
|
|
|
SendMessageW(hTrackBar, TBM_SETPAGESIZE, 0, 1);
|
|
|
|
SendMessageW(hTrackBar, TBM_SETPOS, TRUE, get_trackbar_pos(dwLogpixels));
|
2007-08-07 21:02:27 +02:00
|
|
|
|
|
|
|
updating_ui = FALSE;
|
2007-07-31 00:16:51 +02:00
|
|
|
}
|
2005-07-12 20:11:11 +02:00
|
|
|
|
2008-03-28 11:04:11 +01:00
|
|
|
static void update_dpi_trackbar_from_edit(HWND hDlg, BOOL fix)
|
|
|
|
{
|
|
|
|
DWORD dpi;
|
|
|
|
|
|
|
|
updating_ui = TRUE;
|
|
|
|
|
|
|
|
dpi = GetDlgItemInt(hDlg, IDC_RES_DPIEDIT, NULL, FALSE);
|
|
|
|
|
|
|
|
if (fix)
|
|
|
|
{
|
|
|
|
DWORD fixed_dpi = dpi;
|
|
|
|
|
|
|
|
if (dpi < MINDPI) fixed_dpi = MINDPI;
|
|
|
|
if (dpi > MAXDPI) fixed_dpi = MAXDPI;
|
|
|
|
|
|
|
|
if (fixed_dpi != dpi)
|
|
|
|
{
|
|
|
|
dpi = fixed_dpi;
|
2015-08-16 12:08:41 +02:00
|
|
|
SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, dpi, FALSE);
|
2008-03-28 11:04:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dpi >= MINDPI && dpi <= MAXDPI)
|
|
|
|
{
|
2018-05-15 12:37:28 +02:00
|
|
|
SendDlgItemMessageW(hDlg, IDC_RES_TRACKBAR, TBM_SETPOS, TRUE, get_trackbar_pos(dpi));
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", dpi);
|
2008-03-28 11:04:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
updating_ui = FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-29 17:27:15 +02:00
|
|
|
static void update_font_preview(HWND hDlg)
|
|
|
|
{
|
|
|
|
DWORD dpi;
|
|
|
|
|
|
|
|
updating_ui = TRUE;
|
|
|
|
|
|
|
|
dpi = GetDlgItemInt(hDlg, IDC_RES_DPIEDIT, NULL, FALSE);
|
|
|
|
|
|
|
|
if (dpi >= MINDPI && dpi <= MAXDPI)
|
|
|
|
{
|
2012-01-20 12:42:33 +01:00
|
|
|
static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
|
|
|
|
LOGFONTW lf;
|
2008-04-29 17:27:15 +02:00
|
|
|
HFONT hfont;
|
|
|
|
|
2012-01-20 12:42:33 +01:00
|
|
|
hfont = (HFONT)SendDlgItemMessageW(hDlg, IDC_RES_FONT_PREVIEW, WM_GETFONT, 0, 0);
|
2008-04-29 17:27:15 +02:00
|
|
|
|
2012-01-20 12:42:33 +01:00
|
|
|
GetObjectW(hfont, sizeof(lf), &lf);
|
2008-04-29 17:27:15 +02:00
|
|
|
|
2021-09-07 13:23:32 +02:00
|
|
|
if (wcscmp(lf.lfFaceName, tahomaW) != 0)
|
|
|
|
lstrcpyW(lf.lfFaceName, tahomaW);
|
2008-04-29 17:27:15 +02:00
|
|
|
else
|
|
|
|
DeleteObject(hfont);
|
|
|
|
lf.lfHeight = MulDiv(-10, dpi, 72);
|
2012-01-20 12:42:33 +01:00
|
|
|
hfont = CreateFontIndirectW(&lf);
|
|
|
|
SendDlgItemMessageW(hDlg, IDC_RES_FONT_PREVIEW, WM_SETFONT, (WPARAM)hfont, 1);
|
2008-04-29 17:27:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
updating_ui = FALSE;
|
|
|
|
}
|
|
|
|
|
2003-08-30 02:40:46 +02:00
|
|
|
INT_PTR CALLBACK
|
2005-09-26 11:51:48 +02:00
|
|
|
GraphDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2003-08-30 02:40:46 +02:00
|
|
|
{
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_INITDIALOG:
|
2007-07-31 00:16:51 +02:00
|
|
|
init_dpi_editbox(hDlg);
|
|
|
|
init_trackbar(hDlg);
|
2008-04-29 17:27:15 +02:00
|
|
|
update_font_preview(hDlg);
|
2003-08-30 02:40:46 +02:00
|
|
|
break;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
|
|
|
case WM_SHOWWINDOW:
|
|
|
|
set_window_title(hDlg);
|
|
|
|
break;
|
2008-03-28 11:04:11 +01:00
|
|
|
|
|
|
|
case WM_TIMER:
|
|
|
|
if (wParam == IDT_DPIEDIT)
|
|
|
|
{
|
|
|
|
KillTimer(hDlg, IDT_DPIEDIT);
|
|
|
|
update_dpi_trackbar_from_edit(hDlg, TRUE);
|
2008-04-29 17:27:15 +02:00
|
|
|
update_font_preview(hDlg);
|
2008-03-28 11:04:11 +01:00
|
|
|
}
|
|
|
|
break;
|
2004-09-28 05:55:16 +02:00
|
|
|
|
2003-08-30 02:40:46 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch(HIWORD(wParam)) {
|
|
|
|
case EN_CHANGE: {
|
2005-01-14 20:48:41 +01:00
|
|
|
if (updating_ui) break;
|
2012-01-20 12:42:33 +01:00
|
|
|
SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
2004-09-28 05:55:16 +02:00
|
|
|
if ( ((LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT)) && !updating_ui )
|
2004-09-28 06:05:55 +02:00
|
|
|
set_from_desktop_edits(hDlg);
|
2008-03-28 11:04:11 +01:00
|
|
|
else if (LOWORD(wParam) == IDC_RES_DPIEDIT)
|
|
|
|
{
|
|
|
|
update_dpi_trackbar_from_edit(hDlg, FALSE);
|
2008-04-29 17:27:15 +02:00
|
|
|
update_font_preview(hDlg);
|
2008-03-28 11:04:11 +01:00
|
|
|
SetTimer(hDlg, IDT_DPIEDIT, 1500, NULL);
|
|
|
|
}
|
2003-08-30 02:40:46 +02:00
|
|
|
break;
|
|
|
|
}
|
2003-09-08 20:58:07 +02:00
|
|
|
case BN_CLICKED: {
|
2004-09-28 05:55:16 +02:00
|
|
|
if (updating_ui) break;
|
2012-01-20 12:42:33 +01:00
|
|
|
SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
2003-09-08 20:58:07 +02:00
|
|
|
switch(LOWORD(wParam)) {
|
2004-09-28 06:05:55 +02:00
|
|
|
case IDC_ENABLE_DESKTOP: on_enable_desktop_clicked(hDlg); break;
|
2005-12-22 11:15:32 +01:00
|
|
|
case IDC_ENABLE_MANAGED: on_enable_managed_clicked(hDlg); break;
|
2008-04-10 22:05:13 +02:00
|
|
|
case IDC_ENABLE_DECORATED: on_enable_decorated_clicked(hDlg); break;
|
2011-05-11 14:49:07 +02:00
|
|
|
case IDC_FULLSCREEN_GRAB: on_fullscreen_grab_clicked(hDlg); break;
|
2004-09-28 06:05:55 +02:00
|
|
|
}
|
2003-09-08 20:58:07 +02:00
|
|
|
break;
|
|
|
|
}
|
2003-09-22 21:26:10 +02:00
|
|
|
case CBN_SELCHANGE: {
|
2012-01-20 12:42:33 +01:00
|
|
|
SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
|
2003-09-22 21:26:10 +02:00
|
|
|
break;
|
|
|
|
}
|
2003-09-08 20:58:07 +02:00
|
|
|
|
2003-08-30 02:40:46 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2003-09-08 20:58:07 +02:00
|
|
|
|
|
|
|
|
2003-08-30 02:40:46 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((LPNMHDR)lParam)->code) {
|
|
|
|
case PSN_KILLACTIVE: {
|
2012-01-20 12:42:33 +01:00
|
|
|
SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, FALSE);
|
2003-08-30 02:40:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PSN_APPLY: {
|
2004-09-28 05:55:16 +02:00
|
|
|
apply();
|
2012-01-20 12:42:33 +01:00
|
|
|
SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
|
2003-08-30 02:40:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PSN_SETACTIVE: {
|
2004-09-28 06:05:55 +02:00
|
|
|
init_dialog (hDlg);
|
2003-08-30 02:40:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-07-31 00:16:51 +02:00
|
|
|
case WM_HSCROLL:
|
|
|
|
switch (wParam) {
|
|
|
|
default: {
|
|
|
|
int i = SendMessageW(GetDlgItem(hDlg, IDC_RES_TRACKBAR), TBM_GETPOS, 0, 0);
|
2018-05-15 12:37:28 +02:00
|
|
|
SetDlgItemInt(hDlg, IDC_RES_DPIEDIT, dpi_values[i], TRUE);
|
2015-08-16 12:08:41 +02:00
|
|
|
update_font_preview(hDlg);
|
2021-09-07 17:14:22 +02:00
|
|
|
set_reg_key_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", dpi_values[i]);
|
2007-07-31 00:16:51 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-08-30 02:40:46 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|