-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowConfig.cpp
More file actions
151 lines (133 loc) · 3.73 KB
/
Copy pathWindowConfig.cpp
File metadata and controls
151 lines (133 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//#define LEGACY_USE_LISTBOX
#include <tchar.h>
#include <Windows.h>
#include <CommCtrl.h>
#include "WindowConfig.h"
#include "Window.h"
#include "SizeDialog.h"
#include "StylesDialog.h"
#include "misc.h"
#include "resource.h"
WindowConfig::WindowConfig(class Window * item)
{
this->item = item;
}
void WindowConfig::Config(HWND parent)
{
PROPSHEETHEADER psh;
PROPSHEETPAGE ps[2];
SIZEDIALOGPARAM size_param;
STYLESDIALOGPARAM style_param;
HICON icon;
if(!parent)
{
return;
}
if(!item)
{
return;
}
size_param.target = item->GetHandle();
size_param.callback = set_size;
size_param.callback_param = this;
style_param.style = item->GetStyle();
style_param.extend_style = item->GetExtendStyle();
style_param.callback = set_style;
style_param.callback_param = this;
ps[0] = pst_size;
ps[0].hInstance = (HINSTANCE)GetWindowLongPtr(parent, GWLP_HINSTANCE);
ps[0].lParam = (LPARAM)&size_param;
ps[1] = pst_style;
ps[1].hInstance = ps[0].hInstance;
ps[1].lParam = (LPARAM)&style_param;
icon = item->GetCaptionIcon();
icon_dup = icon ? (HICON)CopyImage(icon, IMAGE_ICON, 0, 0, 0) : NULL;
if(!icon_dup)
{
psh.dwFlags &= ~PSH_USEHICON;
}
psh = psht;
psh.hwndParent = parent;
psh.hInstance = NULL;
psh.hIcon = icon_dup;
psh.pszCaption = item->GetCaption();
psh.ppsp = ps;
PropertySheet(&psh);
LocalHeapFree((void *)psh.pszCaption);
if(icon_dup)
{
if(!DestroyIcon(icon_dup))
{
MessageBoxf(parent, NULL, MB_ICONWARNING, TEXT("アイコンハンドルの解放に失敗しました(%lu)"), GetLastError());
if(IsDebuggerPresent())
{
__debugbreak();
}
}
}
}
void CALLBACK WindowConfig::set_size(void * _this, ULONG flags, const POINT * pt, const SIZE * size, const TCHAR * newstr)
{
if(flags & SDAF_CLIENT_POS)
{
((WindowConfig *)_this)->item->ClientMove(pt);
}
else
{
((WindowConfig *)_this)->item->Move(pt);
}
if(flags & SDAF_CLIENT_SIZE)
{
((WindowConfig *)_this)->item->ClientResize(size);
}
else
{
((WindowConfig *)_this)->item->Resize(size);
}
if(flags & SDAF_SETCAPTION)
{
((WindowConfig *)_this)->item->SetCaption(newstr);
}
}
void CALLBACK WindowConfig::set_style(void * _this, DWORD style, DWORD exstyle)
{
((WindowConfig *)_this)->item->SetStyle(style);
((WindowConfig *)_this)->item->SetExtendStyle(exstyle);
}
const PROPSHEETHEADER WindowConfig::psht = {
/* dwSize */ sizeof(PROPSHEETHEADER),
/* dwFlags */ PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEHICON | PSH_NOCONTEXTHELP /*| PSH_MODELESS*/,
/* hwndParent */ NULL,
/* hInstance */ NULL,
/* hIcon */ NULL,
/* pszCaption */ NULL,
/* nPages */ 2,
/* nStartPage */ 0,
/* ppsp */ NULL,
/* pfnCallback */ NULL};
const PROPSHEETPAGE WindowConfig::pst_size = {
/* dwSize */ sizeof(PROPSHEETPAGE),
/* dwFlags */ 0,
/* hInstance */ NULL,
/* pszTemplate */ MAKEINTRESOURCE(IDD_WINDOW_POS),
/* hIcon */ NULL,
/* pszTitle */ NULL,
/* pfnDlgProc */ SizeDialog::DialogProc,
/* lParam */ 0,
/* pfnCallback */ NULL,
/* pcRefParent */ NULL,
/* pszHeaderTitle */ NULL,
/* pszHeaderSubTitle */ NULL};
const PROPSHEETPAGE WindowConfig::pst_style = {
/* dwSize */ sizeof(PROPSHEETPAGE),
/* dwFlags */ 0,
/* hInstance */ NULL,
/* pszTemplate */ MAKEINTRESOURCE(IDD_WINDOW_STYLE),
/* hIcon */ NULL,
/* pszTitle */ NULL,
/* pfnDlgProc */ StylesDialog::DialogProc,
/* lParam */ 0,
/* pfnCallback */ NULL,
/* pcRefParent */ NULL,
/* pszHeaderTitle */ NULL,
/* pszHeaderSubTitle */ NULL};