Skip to content

Commit b4a165f

Browse files
committed
プリセットにシステムのDPIを適用するようにした。
1 parent f34e5cf commit b4a165f

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

program/ReMetrics.cpp

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Re-Metrics (C) 2012-2017,2020,2021 Tatsuhiko Shoji
2+
Re-Metrics (C) 2012-2017,2020,2021,2023 Tatsuhiko Shoji
33
The sources for Re-Metrics are distributed under the MIT open source license
44
*/
55
// ReMetrics.cpp : アプリケーションのエントリ ポイントを定義します。
@@ -605,7 +605,7 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
605605
padding = _T("0");
606606
iconHMergin = _T("46");
607607
iconVMergin = _T("43");
608-
UpdateData(false);
608+
applyDPIAndSet(false);
609609
return (INT_PTR)0;
610610
case IDM_SET_XP:
611611
borderWidth = _T("1");
@@ -620,7 +620,7 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
620620
padding = _T("0");
621621
iconHMergin = _T("46");
622622
iconVMergin = _T("43");
623-
UpdateData(false);
623+
applyDPIAndSet(false);
624624
return (INT_PTR)0;
625625
case IDM_SET_XP_LUNA:
626626
borderWidth = _T("1");
@@ -635,7 +635,7 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
635635
padding = _T("0");
636636
iconHMergin = _T("46");
637637
iconVMergin = _T("43");
638-
UpdateData(false);
638+
applyDPIAndSet(false);
639639
return (INT_PTR)0;
640640
case IDM_SET_VISTA:
641641
borderWidth = _T("1");
@@ -650,7 +650,7 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
650650
padding = _T("4");
651651
iconHMergin = _T("46");
652652
iconVMergin = _T("43");
653-
UpdateData(false);
653+
applyDPIAndSet(false);
654654
return (INT_PTR)0;
655655
case IDM_SET_7_STD:
656656
borderWidth = _T("1");
@@ -665,7 +665,7 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
665665
padding = _T("4");
666666
iconHMergin = _T("68");
667667
iconVMergin = _T("43");
668-
UpdateData(false);
668+
applyDPIAndSet(false);
669669
return (INT_PTR)0;
670670
case IDM_SET_7:
671671
borderWidth = _T("1");
@@ -680,7 +680,7 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
680680
padding = _T("4");
681681
iconHMergin = _T("68");
682682
iconVMergin = _T("43");
683-
UpdateData(false);
683+
applyDPIAndSet(false);
684684
return (INT_PTR)0;
685685
case IDM_SET_8:
686686
borderWidth = _T("1");
@@ -695,15 +695,15 @@ INT_PTR ReMetrics::OnCommand(WPARAM wParam, LPARAM lParam)
695695
padding = _T("4");
696696
iconHMergin = _T("68");
697697
iconVMergin = _T("43");
698-
UpdateData(false);
698+
applyDPIAndSet(false);
699699
return (INT_PTR)0;
700700
case IDM_SET_10:
701701
setWin10Setting();
702-
UpdateData(false);
702+
applyDPIAndSet(false);
703703
return (INT_PTR)0;
704704
case IDM_SET_11:
705705
setWin11Setting();
706-
UpdateData(false);
706+
applyDPIAndSet(false);
707707
return (INT_PTR)0;
708708
case IDM_OPEN:
709709
OnLoad();
@@ -790,6 +790,31 @@ void ReMetrics::setWin11Setting()
790790
iconVMergin = _T("75");
791791
}
792792

793+
/**
794+
* 入力値にDPIを反映して画面に設定する。
795+
*
796+
* @param toObj true:コントロール→オブジェクト false:オブジェクト→コントロール
797+
*/
798+
void ReMetrics::applyDPIAndSet(bool toObj)
799+
{
800+
// ここにダイアログのコントロールと同期を取るメンバ変数を記述します。
801+
802+
// DPIを適用した値を設定する。
803+
borderWidth = std::to_wstring((int)round(_tstof(borderWidth.c_str()) * ((double)dpiY / 96.0)));
804+
titleWidth = std::to_wstring((int)round(_tstof(titleWidth.c_str()) * ((double)dpiY / 96.0)));
805+
titleHeight = std::to_wstring((int)round(_tstof(titleHeight.c_str()) * ((double)dpiY / 96.0)));
806+
scrollWidth = std::to_wstring((int)round(_tstof(scrollWidth.c_str()) * ((double)dpiY / 96.0)));
807+
scrollHeight = std::to_wstring((int)round(_tstof(scrollHeight.c_str()) * ((double)dpiY / 96.0)));
808+
paletteWidth = std::to_wstring((int)round(_tstof(paletteWidth.c_str()) * ((double)dpiY / 96.0)));
809+
paletteHeight = std::to_wstring((int)round(_tstof(paletteHeight.c_str()) * ((double)dpiY / 96.0)));
810+
menuWidth = std::to_wstring((int)round(_tstof(menuWidth.c_str()) * ((double)dpiY / 96.0)));
811+
menuHeight = std::to_wstring((int)round(_tstof(menuHeight.c_str()) * ((double)dpiY / 96.0)));
812+
padding = std::to_wstring((int)round(_tstof(padding.c_str()) * ((double)dpiY / 96.0)));
813+
814+
UpdateData(toObj);
815+
}
816+
817+
793818
/**
794819
* 「ヘルプ」-「バージョン情報」選択時の処理
795820
*/

program/ReMetrics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Re-Metrics (C) 2012-2017,2020,2021 Tatsuhiko Shoji
2+
Re-Metrics (C) 2012-2017,2020,2021,2023 Tatsuhiko Shoji
33
The sources for Re-Metrics are distributed under the MIT open source license
44
*/
55
#ifndef MYAPPLI_H
@@ -83,6 +83,7 @@ class ReMetrics : public DialogAppliBase {
8383
void getDpi();
8484
void setWin10Setting();
8585
void setWin11Setting();
86+
void applyDPIAndSet(bool toObj);
8687

8788
protected:
8889
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);

0 commit comments

Comments
 (0)