#include "..\..\Resources\GuiResource.h"
#include "WinNativeWindow.h"
#include "ServicesImpl\WindowsResourceService.h"
#include "ServicesImpl\WindowsClipboardService.h"
#include "ServicesImpl\WindowsImageService.h"
#include "ServicesImpl\WindowsAsyncService.h"
#include "ServicesImpl\WindowsScreenService.h"
#include "ServicesImpl\WindowsCallbackService.h"
#include "ServicesImpl\WindowsInputService.h"
#include "ServicesImpl\WindowsDialogService.h"
#include <CommCtrl.h>
#pragma comment(lib,
"Imm32.lib"
)
#pragma comment(lib,
"Shlwapi.lib"
)
#pragma comment(lib,
"Comctl32.lib"
)
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
=
nullptr
;
(
=
0
)
{
if (!defaultIconResourceName) return NULL;
if
(!
defaultIconResourceName
)
return
0
;
return (HICON)LoadImage(GetModuleHandle(NULL), defaultIconResourceName, IMAGE_ICON, (int)size, (int)size, (size ? 0 : LR_DEFAULTSIZE) | LR_SHARED);
return
(
)
(
(
0
),
defaultIconResourceName
,
1
, (
int
)
, (
int
)
, (
?
0
:
0x00000040
) |
0x00008000
);
}
void
(
)
{
CHECK_ERROR(defaultIconResourceName == nullptr, L"vl::presentation::windows::SetWindowDefaultIcon(UINT)#This function can only be called once.");
do
{
if
(!(
defaultIconResourceName
==
nullptr
))
throw
(
L"vl::presentation::windows::SetWindowDefaultIcon(UINT)#This function can only be called once."
);}
while
(
0
);
defaultIconResourceName = MAKEINTRESOURCE(resourceId);
defaultIconResourceName
= ((
)((
)((
)(
))));
}
GetHWNDFromNativeWindowHandle
(
*
)
{
*
=
(
);
return
form
->
();
}
class
:
public
{
protected
:
;
;
;
public
:
(
,
bool
,
bool
,
,
)
{
;
ZeroMemory(&windowClass, sizeof(windowClass));
.
=
sizeof
(
);
windowClass.style=CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | (shadow?CS_DROPSHADOW:0) | (ownDC?CS_OWNDC:0);
.
=
0x0002
|
0x0001
|
0x0008
| (
?
0x00020000
:
0
) | (
?
0x0020
:
0
);
.
=
;
.
=
0
;
.
=
0
;
.
=
;
if
(
defaultIconResourceName
)
{
.
=
();
}
windowClass.hCursor=NULL;//LoadCursor(NULL,IDC_ARROW);
windowClass.hbrBackground=GetSysColorBrush(COLOR_BTNFACE);
windowClass.lpszMenuName=NULL;
.
=
.
();
windowClass.hIconSm=NULL;
windowAtom=RegisterClassEx(&windowClass);
}
bool
()
{
return
!=
0
;
}
()
{
return
;
}
()
{
return
;
}
};
class
:
public
,
public
,
public
{
protected
:
()
{
return GetWindowLongPtr(handle, GWL_EXSTYLE);
}
void
(
)
{
LONG_PTR result = SetWindowLongPtr(handle, GWL_EXSTYLE, exStyle);
SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
(
,
0
,
0
,
0
,
0
,
0
,
0x0001
|
0x0002
|
0x0004
|
0x0010
|
0x0020
);
}
()
{
return GetWindowLongPtr(handle, GWL_STYLE);
}
void
(
)
{
SetWindowLongPtr(handle, GWL_STYLE, style);
SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
(
,
0
,
0
,
0
,
0
,
0
,
0x0001
|
0x0002
|
0x0004
|
0x0010
|
0x0020
);
}
(
,
)
{
return
|
;
}
(
,
)
{
return
& (~
);
}
bool
(
)
{
return
(
() &
) !=
0
;
}
void
(
,
bool
)
{
if
(
)
{
(
(
(),
));
}
else
{
(
(
(),
));
}
}
bool
(
)
{
return
(
() &
) !=
0
;
}
void
(
,
bool
)
{
if
(
)
{
(
(
(),
));
}
else
{
(
(
(),
));
}
}
#pragma push_macro("_CONTROL")
#if defined _CONTROL
#undef _CONTROL
#endif
(
,
,
bool
,
bool
)
{
;
info
.
=
false
;
if
(
)
{
switch
(
)
{
break
;
default
:
info
.
=
true
;
break
;
}
}
if
(
)
{
info.wheel=GET_WHEEL_DELTA_WPARAM(wParam);
info
.
=((
short
)((
)((((
)(
)) >>
16
) &
0xffff
)));
wParam=GET_KEYSTATE_WPARAM(wParam);
=(((
)(((
)(
)) &
0xffff
)));
}
else
{
info
.
=
0
;
}
if
(
)
{
info
.
=
(
::_CONTROL);
info
.
=
(
::
);
info
.
=
(
::
);
info
.
=
(
::
);
info
.
=
(
::
);
POINTS point = MAKEPOINTS(lParam);
=
().
();
info
.
point
.
-
offset
.
.
;
info
.
point
.
-
offset
.
.
;
}
else
{
info
.
=((
)
&
::_CONTROL)!=(
)
0
;
info
.
=((
)
::
)
(
)
0
;
info
.
=((
)
::
)
(
)
0
;
info
.
=((
)
::
)
(
)
0
;
info
.
=((
)
::
)
(
)
0
;
POINTS point = MAKEPOINTS(lParam);
if
(
)
{
=
().
();
info
.
point
.
-
offset
.
.
;
info
.
point
.
-
offset
.
.
;
}
else
{
info
.
point
.
;
info
.
point
.
;
}
}
return
info
;
}
(
,
)
{
;
info
.
=(
)
;
info
.
=
(
::_CONTROL);
info
.
=
(
::
);
info
.
=
(
::
);
info
.
=
(
::
);
info
.
= (((
)
) >>
30
) %
2
==
1
;
return
info
;
}
(
)
{
;
info
.
=(
wchar_t
)
;
info
.
=
(
::_CONTROL);
info
.
=
(
::
);
info
.
=
(
::
);
info
.
=
(
::
);
return
info
;
}
#pragma pop_macro("_CONTROL")
void
(
bool
)
{
;
trackMouseEvent
.
=
sizeof
(
trackMouseEvent
);
trackMouseEvent
.
=
;
trackMouseEvent.dwFlags=(enable?0:TME_CANCEL) | TME_HOVER | TME_LEAVE;
trackMouseEvent
.
=(
?
0
:
0x80000000
) |
0x00000001
|
0x00000002
;
trackMouseEvent.dwHoverTime=HOVER_DEFAULT;
trackMouseEvent
.
=
0xFFFFFFFF
;
(&
trackMouseEvent
);
}
void
UpdateCompositionForContent
()
{
=
(
);
;
cf
.
.
= (
int
)
.
.
;
cf
.
.
= (
int
)
.
.
;
(
imc
, &
cf
);
(
,
imc
);
}
bool
=
false
;
static
void
(
* ,
<
*>& )
{
for
(
=
0
;
i
<
->
.
();
i
++)
{
auto
=
->
i
];
if
(
popup
->
!=
&&
popup
->
())
{
if
(!
.
(
popup
))
{
popup
->
(
false
);
}
}
(
popup
,
);
}
}
bool
(
,
,
,
,
&
)
{
if
(!
)
{
bool
=
false
;
*
=
nullptr
;
*
=
nullptr
;
<
*>
;
switch
(
)
{
{
closePopups
=
true
;
}
break
;
switch (LOWORD(wParam))
switch
(((
)(((
)(
)) &
0xffff
)))
{
activatedWindow
=
this
;
closePopups
=
true
;
break
;
}
break
;
activatedWindow
=
this
;
closePopups
=
true
;
break
;
}
if
(
activatedWindow
)
{
rootWindow
=
activatedWindow
;
exceptions
.
(
rootWindow
);
while
(
auto
=
rootWindow
->
)
{
rootWindow
=
parentWindow
;
exceptions
.
(
parentWindow
);
}
}
if
(
closePopups
)
{
<
*>
;
(
allRootWindows
,
true
);
for
(
=
0
;
i
<
allRootWindows
.
();
i
++)
{
if
(
auto
=
dynamic_cast
<
*>(
allRootWindows
i
]))
{
(
windowsForm
,
exceptions
);
}
}
}
}
bool
=
false
;
switch
(
)
{
case WM_MOVING:case WM_SIZING:
{
=(
)
;
(
rawBounds
->
,
rawBounds
->
,
rawBounds
->
,
rawBounds
->
);
for
(
=
0
;
i
<
.
();
i
++)
{
listeners[i]->Moving(bounds, false, (uMsg == WM_SIZING));
i
]->
(
bounds
,
false
, (
==
0x0214
));
}
if
(
rawBounds
->
!=
bounds
.
().
||
rawBounds
->
!=
bounds
.
().
||
rawBounds
->
!=
bounds
.
().
||
rawBounds
->
!=
bounds
.
().
)
{
rawBounds
->
=(
int
)
bounds
.
().
;
rawBounds
->
=(
int
)
bounds
.
().
;
rawBounds
->
=(
int
)
bounds
.
().
;
rawBounds
->
=(
int
)
bounds
.
().
;
}
}
break
;
case WM_MOVE:case WM_SIZE:
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
break
;
{
dpiY = HIWORD(wParam);
= ((
)((((
)(
)) >>
16
) &
0xffff
));
(
false
);
auto
= (
*)
;
MoveWindow(handle, newRect->left, newRect->top, (newRect->right - newRect->left), (newRect->bottom - newRect->top), FALSE);
(
,
newRect
->
,
newRect
->
, (
newRect
->
-
newRect
->
), (
newRect
->
-
newRect
->
),
0
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
break
;
{
for
(
=
0
;
i
<
.
();
i
++)
{
{
i
]->
();
}
else
{
i
]->
();
}
}
}
break
;
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
break
;
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
break
;
if
(!
)
{
return
true
;
}
break
;
{
for
(
=
0
;
i
<
.
();
i
++)
{
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE)
{
i
]->
();
}
else
{
i
]->
();
}
}
}
break
;
if
(
==
0
)
{
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
else
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
}
break
;
{
bool
=
false
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
cancel
);
}
return
cancel
;
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
if
(!
)
break
;
nonClient
=
true
;
{
=
(
,
,
false
,
nonClient
);
if
(
info
.
||
info
.
!=
)
{
if
(!
)
{
=
true
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
(
true
);
}
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
}
break
;
{
=
(
,
,
true
,
false
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
{
=
(
,
,
true
,
false
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
nonClient
=
true
;
if
(
==
nonClient
)
{
=-
1
;
=-
1
;
=
false
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
break
;
{
(
true
);
}
break
;
{
=
(
,
);
info
.
=
false
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
{
=
(
,
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
{
=
(
,
);
info
.
=
false
;
if
(
&& !
info
.
&& !
info
.
&&
info
.
==
::
)
{
=
false
;
break
;
}
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
{
=
(
,
);
if
(
&& !
info
.
&& !
info
.
&&
info
.
==
::
)
{
break
;
}
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
{
=
(
);
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
info
);
}
}
break
;
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
break
;
=
0
;
return
true
;
if
(
)
{
=
0
;
return
true
;
}
break
;
{
=
(
);
(
,
imc
);
(
,
imc
);
}
break
;
case WM_IME_STARTCOMPOSITION:
UpdateCompositionForContent
();
break
;
{
POINTS location=MAKEPOINTS(lParam);
=
().
();
location
.
-=(
)
windowLocation
.
.
;
location
.
-=(
)
windowLocation
.
.
;
for
(
=
0
;
i
<
.
();
i
++)
{
switch
(
i
]->
(
(
location
.
,
location
.
)))
{
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
case
::
:
return
true
;
}
}
}
break
;
{
DWORD hitTestResult=LOWORD(lParam);
if(hitTestResult==HTCLIENT)
{
=
->
();
if
(
()!=
cursorHandle
)
{
(
cursorHandle
);
}
return
true
;
}
}
break
;
if
((
)
&&
)
{
=
0
;
return
true
;
}
break
;
if
(
)
{
{
}
else
{
}
return
true
;
}
break
;
}
if
(
)
{
switch
(
)
{
switch
(
)
{
=
0
;
return
true
;
}
break
;
{
POINTS location = MAKEPOINTS(lParam);
for
(
=
0
;
i
<
.
();
i
++)
{
switch
(
i
]->
(
(
location
.
,
location
.
)))
{
case
::
:
();
return
false
;
case
::
:
if
(
() ==
::
)
{
();
}
else
{
();
}
return
false
;
case
::
:
(
true
);
return
false
;
}
}
}
break
;
}
}
return
false
;
}
protected
:
;
;
*
=
nullptr
;
;
*
=
nullptr
;
<
*>
;
;
<
*>
;
= -
1
;
= -
1
;
bool
=
false
;
*
=
nullptr
;
bool
=
false
;
bool
=
true
;
<
<
>>
;
bool
=
false
;
<
bool
>
=
new
bool
(
false
);
;
<
>
;
<
>
;
HICON replacementHIcon = NULL;
=
0
;
=
0
;
void
(
bool
)
{
if
(
)
{
DpiAwared_GetDpiForWindow
(
, &
, &
);
}
auto padding = (vint)(DpiAwared_GetSystemMetrics(SM_CXSIZEFRAME, dpiX) + DpiAwared_GetSystemMetrics(SM_CXPADDEDBORDER, dpiX));
auto
= (
)(
DpiAwared_GetSystemMetrics
(
32
,
) +
DpiAwared_GetSystemMetrics
(
92
,
));
(
padding
,
padding
,
padding
,
padding
);
}
public
:
(
,
,
,
::
)
:windowMode(
)
{
{
DWORD exStyle = WS_EX_APPWINDOW | WS_EX_CONTROLPARENT;
=
0x00040000L
|
0x00010000L
;
DWORD style = WS_BORDER | WS_CAPTION | WS_SIZEBOX | WS_SYSMENU | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
=
0x00800000L
|
0x00C00000L
|
0x00040000L
|
0x00080000L
|
0x80000000L
|
0x04000000L
|
0x02000000L
|
0x00010000L
|
0x00020000L
;
handle = CreateWindowEx(exStyle, className.Buffer(), L"", style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, hInstance, NULL);
=
(
exStyle
,
.
(),
L""
,
style
, ((
int
)
0x80000000
), ((
int
)
0x80000000
), ((
int
)
0x80000000
), ((
int
)
0x80000000
),
,
0
,
,
0
);
}
if
(
==
::
)
{
auto
=
();
style = TurnOnStyle(style, WS_OVERLAPPED);
style
=
(
style
,
0x00000000L
);
style = TurnOffStyle(style, WS_POPUP);
style
=
(
style
,
0x80000000L
);
(
style
);
}
(
true
);
}
()
{
if
(
)
{
->
.
(
this
);
}
for
(
=
.
() -
1
;
i
>=
0
;
i
--)
{
i
]->
(
);
}
*
.
() =
true
;
<
*>
;
(
copiedListeners
,
);
for
(
=
0
;
i
<
copiedListeners
.
();
i
++)
{
*
=
copiedListeners
i
];
if
(
.
(
listener
))
{
listener
->
();
}
}
(
);
}
void
()
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
bool
(
,
,
,
,
&
)
{
#define CHECK_DISPOSED if (*flag.Obj()) return skip
auto
=
;
bool
=
false
;
{
FOREACH(Ptr<INativeMessageHandler>, handler, messageHandlers)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
handler
);)
{
handler
(
,
,
,
,
skip
);
CHECK_DISPOSED;
if
(*
flag
.
())
return
skip
;
}
if
(
skip
)
{
return
true
;
}
}
skip
=
(
,
,
,
,
);
CHECK_DISPOSED;
if
(*
flag
.
())
return
skip
;
if
(
(
))
{
FOREACH(Ptr<INativeMessageHandler>, handler, messageHandlers)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
handler
);)
{
handler
(
,
,
,
,
skip
,
);
CHECK_DISPOSED;
if
(*
flag
.
())
return
skip
;
}
}
return
skip
;
#undef CHECK_DISPOSED
}
()
override
{
return
;
}
*
()
override
{
return
;
}
void
(
*
)
override
{
=
;
}
bool
(
<
>
)
override
{
if
(
.
(
.
()))
{
return
false
;
}
.
(
);
return
true
;
}
bool
(
<
>
)
override
{
=
.
(
.
());
if
(
index
== -
1
)
return
false
;
.
(
);
return
true
;
}
(
)
override
{
return
((
)
.
.
*
96
/
, (
)
.
.
*
96
/
);
}
(
)
override
{
return
(
.
*
/
96
,
.
*
/
96
);
}
(
)
override
{
return
((
)
.
.
*
96
/
, (
)
.
.
*
96
/
);
}
(
)
override
{
return
(
.
*
/
96
,
.
*
/
96
);
}
(
)
override
{
return
(
(
)
.
.
*
96
/
,
(
)
.
.
*
96
/
,
(
)
.
.
*
96
/
,
(
)
.
.
*
96
/
);
}
(
)
override
{
return
(
(
)
.
*
/
96
,
(
)
.
*
/
96
,
(
)
.
*
/
96
,
(
)
.
*
/
96
);
}
()
override
{
;
(
, &
rect
);
return
(
rect
.
,
rect
.
,
rect
.
,
rect
.
);
}
void
(
const
&
)
override
{
=
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
newBounds
,
true
,
false
);
}
MoveWindow(handle, (int)newBounds.Left().value, (int)newBounds.Top().value, (int)newBounds.Width().value, (int)newBounds.Height().value, FALSE);
(
, (
int
)
newBounds
.
().
, (
int
)
newBounds
.
().
, (
int
)
newBounds
.
().
, (
int
)
newBounds
.
().
,
0
);
}
()
override
{
return
().
();
}
void
(
)
override
{
={
0
,
0
,(
int
)
.
.
,(
int
)
.
.
};
;
(
, &
bounds
);
DpiAwared_AdjustWindowRect
(&
required
,
,
);
(
(
(
bounds
.
,
bounds
.
),
(
required
.
-
required
.
,
required
.
-
required
.
)));
}
()
override
{
if
(
)
{
return
();
}
else
{
={
0
,
0
,
0
,
0
};
;
(
, &
bounds
);
DpiAwared_AdjustWindowRect
(&
required
,
,
);
return
(
(
(
bounds
.
-
required
.
),
(
bounds
.
-
required
.
)
),
(
(
bounds
.
-
bounds
.
)-(
required
.
-
required
.
),
(
bounds
.
-
bounds
.
)-(
required
.
-
required
.
)
)
);
}
}
()
override
{
return
;
}
void
(
)
override
{
;
SetWindowText(handle, title.Buffer());
}
*
()
override
{
return
;
}
void
(
*
)
override
{
*
=
dynamic_cast
<
*>(
);
if
(
newCursor
&&
!=
newCursor
)
{
=
newCursor
;
if
(
&&
())
{
(
->
());
}
}
}
()
override
{
return
;
}
void
(
)
override
{
;
UpdateCompositionForContent
();
}
*
()
override
{
return
;
}
void
(
*
)
override
{
if
(
)
{
->
.
(
this
);
}
if
((
=
dynamic_cast
<
*>(
)))
{
->
.
(
this
);
SetWindowLongPtr(handle, GWLP_HWNDPARENT, (LONG_PTR)parentWindow->handle);
}
else
{
SetWindowLongPtr(handle, GWLP_HWNDPARENT, NULL);
}
}
()
override
{
return
;
}
void
()
override
{
=
true
;
}
void
()
override
{
=
false
;
}
bool
()
override
{
return
;
}
()
override
{
if
(
() ||
())
{
return
;
}
else
{
return
(
0
,
0
,
0
,
0
);
}
}
<
>
()
override
{
if
(
&&
())
{
return
;
}
else
{
if
(!
)
{
auto
=
(
16
);
{
icon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 16, 16, LR_SHARED);
icon
= (
)
(
0
, ((
)((
)((
)(
32512
)))),
1
,
16
,
16
,
0x00008000
);
}
{
new
(
(
icon
),
0
);
}
}
return
;
}
}
static
double
(
)
{
if
(
>
32
)
{
return
32.0
/
;
}
else
if
(
<
32
)
{
return
/
32.0
-
1
;
}
else
{
return
1.0
;
}
}
static
(
const
&
)
{
if
(
==
GUID_WICPixelFormat1bppIndexed
)
return
1
;
if
(
==
GUID_WICPixelFormat2bppIndexed
)
return
2
;
if
(
==
GUID_WICPixelFormat4bppIndexed
)
return
4
;
if
(
==
GUID_WICPixelFormat8bppIndexed
)
return
8
;
if
(
==
GUID_WICPixelFormatBlackWhite
)
return
1
;
if
(
==
GUID_WICPixelFormat2bppGray
)
return
2
;
if
(
==
GUID_WICPixelFormat4bppGray
)
return
4
;
if
(
==
GUID_WICPixelFormat8bppGray
)
return
8
;
if
(
==
GUID_WICPixelFormat8bppAlpha
)
return
8
;
if
(
==
GUID_WICPixelFormat16bppBGR555
)
return
16
;
if
(
==
GUID_WICPixelFormat16bppBGR565
)
return
16
;
if
(
==
GUID_WICPixelFormat16bppBGRA5551
)
return
16
;
if
(
==
GUID_WICPixelFormat16bppGray
)
return
16
;
if
(
==
GUID_WICPixelFormat24bppBGR
)
return
24
;
if
(
==
GUID_WICPixelFormat24bppRGB
)
return
24
;
if
(
==
GUID_WICPixelFormat32bppBGR
)
return
32
;
if
(
==
GUID_WICPixelFormat32bppBGRA
)
return
32
;
if
(
==
GUID_WICPixelFormat32bppPBGRA
)
return
32
;
return
-
1
;
}
void
(
<
>
)
override
{
;
HICON newReplacementHIcon = NULL;
if
(
&&
())
{
stream
::
;
()
(
memoryStream
,
::
);
if
(
memoryStream
.
() >
0
)
{
newReplacementHIcon = CreateIconFromResource((PBYTE)memoryStream.GetInternalBuffer(), (DWORD)memoryStream.Size(), TRUE, 0x00030000);
newReplacementHIcon
=
((
)
memoryStream
.
(), (
)
memoryStream
.
(),
1
,
0x00030000
);
if (newReplacementHIcon != NULL)
if
(
newReplacementHIcon
!=
0
)
{
goto
SKIP;
}
}
*
=
nullptr
;
for
(
=
0
;
i
<
()
();
i
++)
{
auto
=
()
(
i
);
auto
=
frame
->
();
if
(
size
.
==
size
.
)
{
auto
=
(
frame
);
;
=
bitmap
->
(&
format
);
if (hr != S_OK) continue;
if
(
hr
!= ((
)
0L
))
continue
;
if
(!
selectedFrame
)
{
selectedFrame
=
frame
;
}
else
{
auto
=
(
size
.
);
auto
=
(
selectedFrame
->
().
);
if
(
score
>
scoreSelected
)
{
selectedFrame
=
frame
;
}
else
if
(
score
==
scoreSelected
)
{
;
auto
=
(
selectedFrame
);
hr
=
selectedBitmap
->
(&
selectedFormat
);
auto
=
(
format
);
auto
=
(
selectedFormat
);
if
(
bpp
>
bppSelected
)
{
selectedFrame
=
frame
;
}
}
}
}
}
if
(
selectedFrame
)
{
bool
=
false
;
(
()
(),
(
selectedFrame
),
()
());
newBitmap
.
(
memoryStream
,
::
);
if
(
memoryStream
.
() >
0
)
{
auto
= (
char
*)
memoryStream
.
();
= *(
*)
pBuffer
;
= *(
*)(
pBuffer
+
sizeof
(
));
= *(
*)(
pBuffer
+
sizeof
(
) +
sizeof
(
));
;
bi
.
[
0
]
rgb
;
bi
.
bih
;
char
*
= (
pBuffer
+
bfh
.
);
char
*
;
auto hBitmap = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&ppvBits, NULL, 0);
auto
=
(
0
, &
bi
,
0
, (
void
**)&
ppvBits
,
0
,
0
);
{
SetDIBits(NULL, hBitmap, 0, bih.biHeight, pPixels, &bi, DIB_RGB_COLORS);
(
0
,
hBitmap
,
0
,
bih
.
,
pPixels
, &
bi
,
0
);
auto himl = ImageList_Create(32, 32, ILC_COLOR32, 1, 1);
auto
=
(
32
,
32
,
0x00000020
,
1
,
1
);
{
int addResult = ImageList_Add(himl, hBitmap, NULL);
int
=
(
himl
,
hBitmap
,
0
);
newReplacementHIcon = ImageList_GetIcon(himl, 0, ILD_NORMAL);
newReplacementHIcon
=
(
himl
,
0
,
0x00000000
);
(
himl
);
}
(
hBitmap
);
}
}
}
}
SKIP:
{
=
newReplacementHIcon
;
if (hAppIcon == NULL) hAppIcon = CreateWindowDefaultIcon();
if
(
hAppIcon
==
0
)
hAppIcon
=
();
if (hAppIcon == NULL) hAppIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
if
(
hAppIcon
==
0
)
hAppIcon
= (
)
(
0
, ((
)((
)((
)(
32512
)))),
1
,
0
,
0
,
0x00000040
|
0x00008000
);
bool
=
();
if (isVisible) SendMessage(handle, WM_SETREDRAW, (WPARAM)FALSE, NULL);
if
(
isVisible
)
(
,
0x000B
, (
)
0
,
0
);
SendMessage(handle, WM_SETICON, ICON_BIG, (LPARAM)hAppIcon);
(
,
0x0080
,
1
, (
)
hAppIcon
);
SendMessage(handle, WM_SETICON, ICON_SMALL, (LPARAM)hAppIcon);
(
,
0x0080
,
0
, (
)
hAppIcon
);
if (isVisible) SendMessage(handle, WM_SETREDRAW, (WPARAM)TRUE, NULL);
if
(
isVisible
)
(
,
0x000B
, (
)
1
,
0
);
if
(
this
==
()->
()->
())
{
SendMessage(GetWindow(handle, GW_OWNER), WM_SETICON, ICON_BIG, (LPARAM)hAppIcon);
(
(
,
4
),
0x0080
,
1
, (
)
hAppIcon
);
SendMessage(GetWindow(handle, GW_OWNER), WM_SETICON, ICON_SMALL, (LPARAM)hAppIcon);
(
(
,
4
),
0x0080
,
0
, (
)
hAppIcon
);
}
}
if (replacementHIcon != NULL)
{
(
);
}
=
newReplacementHIcon
;
}
()
override
{
if
(
(
))
{
return
::
;
}
else
if
(
(
))
{
return
::
;
}
else
{
return
::
;
}
}
void
()
override
{
ShowWindow(handle, SW_SHOWNORMAL);
}
void
()
override
{
ShowWindow(handle, SW_SHOWNOACTIVATE);
SetWindowPos(handle,HWND_TOP,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
(
,((
)
0
),
0
,
0
,
0
,
0
,
0x0001
|
0x0002
|
0x0010
);
}
void
()
override
{
ShowWindow(handle, SW_RESTORE);
}
void
()
override
{
ShowWindow(handle, SW_SHOWMAXIMIZED);
}
void
()
override
{
ShowWindow(handle, SW_SHOWMINIMIZED);
}
void
(
bool
)
override
{
if
(
)
{
PostMessage(handle, WM_CLOSE, NULL, NULL);
}
else
{
ShowWindow(handle, SW_HIDE);
}
}
bool
()
override
{
return
(
)!=
0
;
}
void
()
override
{
EnableWindow(handle, TRUE);
}
void
()
override
{
EnableWindow(handle, FALSE);
}
bool
()
override
{
return
(
)!=
0
;
}
void
()
override
{
::
(
);
}
bool
()
override
{
return
()==
;
}
void
()
override
{
(
);
}
bool
()
override
{
return
()==
;
}
void
()
override
{
SetExStyle(WS_EX_APPWINDOW, true);
}
void
()
override
{
SetExStyle(WS_EX_APPWINDOW, false);
}
bool
()
override
{
return GetExStyle(WS_EX_APPWINDOW);
}
void
()
override
{
=
true
;
SetExStyle(WS_EX_NOACTIVATE, false);
}
void
()
override
{
=
false
;
SetExStyle(WS_EX_NOACTIVATE, true);
}
bool
()
override
{
return
;
}
bool
()
override
{
(
);
return
true
;
}
bool
()
override
{
::
();
return
true
;
}
bool
()
override
{
return
()==
;
}
bool
()
override
{
return GetStyle(WS_MAXIMIZEBOX);
}
void
(
bool
)
override
{
SetStyle(WS_MAXIMIZEBOX, visible);
}
bool
()
override
{
return GetStyle(WS_MINIMIZEBOX);
}
void
(
bool
)
override
{
SetStyle(WS_MINIMIZEBOX, visible);
}
bool
()
override
{
return GetStyle(WS_BORDER);
}
void
(
bool
)
override
{
SetStyle(WS_BORDER, visible);
}
bool
()
override
{
return GetStyle(WS_SIZEBOX);
}
void
(
bool
)
override
{
SetStyle(WS_SIZEBOX, visible);
}
bool
()
override
{
return GetStyle(WS_SYSMENU);
}
void
(
bool
)
override
{
SetStyle(WS_SYSMENU, visible);
}
bool
()
override
{
return GetStyle(WS_CAPTION);
}
void
(
bool
)
override
{
SetStyle(WS_CAPTION, visible);
}
bool
()
override
{
return GetExStyle(WS_EX_TOPMOST);
}
void
(
bool
)
override
{
SetWindowPos(handle, (topmost ? HWND_TOPMOST : HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
(
, (
? ((
)-
1
) : ((
)-
2
)),
0
,
0
,
0
,
0
,
0x0001
|
0x0002
|
0x0010
|
0x0020
);
}
void
()
override
{
if
(!
)
{
=
true
;
PostMessage(handle, WM_SYSKEYDOWN, VK_MENU, 0);
PostMessage(handle, WM_SYSKEYUP, VK_MENU, 0);
}
}
bool
(
*
)
override
{
if
(
.
(
))
{
return
false
;
}
else
{
.
(
);
return
true
;
}
}
bool
(
*
)
override
{
if
(
.
(
))
{
.
(
);
return
true
;
}
else
{
return
false
;
}
}
void
()
override
{
if
(
)
{
SendMessage(this->handle, WM_PAINT, NULL, NULL);
}
}
};
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
class
:
public
,
public
virtual
,
public
virtual
{
protected
:
;
;
;
;
<
,
*>
;
*
;
;
;
;
;
;
;
;
;
;
public
:
(
)
:hInstance(
)
,windowClass(
L"VczhWindow"
,
false
,
false
,
,
)
,godClass(
L"GodWindow"
,
false
,
false
,
,
)
,mainWindow(
0
)
,mainWindowHandle(
0
)
,screenService(&
GetHWNDFromNativeWindowHandle
)
,dialogService(&
GetHWNDFromNativeWindowHandle
)
{
godWindow=CreateWindowEx(WS_EX_CONTROLPARENT, godClass.GetName().Buffer(), L"GodWindow", WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
=
(
0x00010000L
,
.
().
(),
L"GodWindow"
, (
0x00000000L
|
0x00C00000L
|
0x00080000L
|
0x00040000L
|
0x00020000L
|
0x00010000L
),
0
,
0
,
0
,
0
,
0
,
0
,
,
0
);
.
(
);
.
(
);
}
()
{
.
();
clipboardService.SetOwnerHandle(NULL);
(
);
}
*
(
)
{
=
.
().
(
);
if
(
index
== -
1
)
return
0
;
return
.
()
index
];
}
void
(
collections
::
<
*>&
,
bool
)
{
if
(
)
{
FOREACH(WindowsForm*, window, windows.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
window
);)
{
if
(
window
->
() ==
::
)
{
.
(
window
);
}
}
}
else
{
(
,
.
());
}
}
bool
(
,
,
,
,
&
)
{
bool
=
false
;
{
=
.
().
(
);
if
(
index
!= -
1
)
{
*
=
.
().
(
index
);
skipDefaultProcedure
=
window
->
(
,
,
,
,
);
switch
(
)
{
if
(!
skipDefaultProcedure
)
{
ShowWindow(window->GetWindowHandle(), SW_HIDE);
if
(
window
!=
)
{
skipDefaultProcedure
=
true
;
}
}
break
;
(
window
);
break
;
}
}
}
{
if (hwnd == mainWindowHandle && uMsg == WM_DESTROY)
{
FOREACH(WindowsForm*, window, windows.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
window
);)
{
if
(
window
->
())
{
window
->
(
true
);
}
}
<
*>
;
(
normalWindows
,
(
.
())
.
([](
*
)
{
return
window
->
() ==
::
;
})
);
FOREACH(WindowsForm*, window, normalWindows)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
normalWindows
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
window
);)
{
(
window
);
}
for
(
=
.
() -
1
;
i
>=
0
;
i
--)
{
auto
=
.
()
i
];
(
window
);
}
(
0
);
}
}
return
skipDefaultProcedure
;
}
*
(
::
)
override
{
*
=
new
(
,
.
(),
,
);
.
(
window
->
(),
window
);
.
InvokeNativeWindowCreated
(
window
);
window
->
(
.
());
return
window
;
}
void
(
*
)
override
{
*
=
dynamic_cast
<
*>(
);
windowsForm
->
();
if
(
windowsForm
!=
0
&&
.
().
(
windowsForm
->
()))
{
.
InvokeNativeWindowDestroyed
(
);
.
(
windowsForm
->
());
delete
windowsForm
;
}
}
*
()
override
{
return
;
}
void
(
*
)
override
{
=
;
=
(
)->
();
->
();
;
while(GetMessage(&message, NULL, 0, 0))
while
(
(&
message
,
0
,
0
,
0
))
{
(&
message
);
DispatchMessage(&message);
.
();
}
}
*
(
)
override
{
;
p
.
=(
int
)
.
.
;
p
.
=(
int
)
.
.
;
=
(
p
);
=
.
().
(
handle
);
if
(
index
==-
1
)
{
return
0
;
}
else
{
return
.
().
(
index
);
}
}
*
()
{
return
&
;
}
*
()
{
return
&
;
}
*
()
{
return
&
;
}
*
()
{
return
&
;
}
*
()
{
return
&
;
}
*
()
{
return
&
;
}
*
()
{
return
this
;
}
*
()
{
return
&
;
}
*
()
{
return
&
;
}
()
{
<
wchar_t
>
(
65536
);
GetModuleFileName(NULL, &buffer[0], (DWORD)buffer.Count());
(
0
, &
buffer
0
], (
)
buffer
.
());
return
&
buffer
0
];
}
void
()
{
.
();
}
void
()
{
.
();
}
};
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
*
=
dynamic_cast
<
*>(
());
if
(
controller
)
{
=
0
;
if
(
controller
->
(
,
,
,
,
result
))
{
return
result
;
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
*
=
dynamic_cast
<
*>(
());
if
(
controller
)
{
switch
(
)
{
controller
->
();
break
;
controller
->
();
break
;
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
*
CreateWindowsNativeController
(
)
{
return
new
(
);
}
*
(
)
{
auto
=
dynamic_cast
<
*>(
());
if
(
controller
)
{
return
controller
->
(
);
}
return
nullptr
;
}
*
(
*
)
{
return
dynamic_cast
<
*>(
);
}
void
(
collections
::
<
*>&
,
bool
)
{
auto
=
dynamic_cast
<
*>(
());
if
(
controller
)
{
controller
->
(
,
);
}
}
void
DestroyWindowsNativeController
(
*
)
{
delete
;
}
void
EnableCrossKernelCrashing
()
{
typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
typedef
(
__stdcall
*
)(
lpFlags);
typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
typedef
(
__stdcall
*
)(
dwFlags);
const
=
0x1
;
HMODULE kernel32 = LoadLibrary(L"kernel32.dll");
= (
)
(
kernel32
,
"GetProcessUserModeExceptionPolicy"
);
= (
)
(
kernel32
,
"SetProcessUserModeExceptionPolicy"
);
if
(
pGetPolicy
&&
pSetPolicy
)
{
;
if
(
pGetPolicy
(&
dwFlags
))
{
pSetPolicy
(
dwFlags
& ~
EXCEPTION_SWALLOWING
);
}
}
}
}
}
}