forked from Tobbe/CppIEEmbed
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webwindow.cpp
108 lines (85 loc) · 2.83 KB
/
webwindow.cpp
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
#include "webwindow.h"
WebWindow::WebWindow(WebformDispatchHandler *wdh) : webformDispatchHandler(wdh)
{
}
void WebWindow::Create(HINSTANCE hInstance, UINT x, UINT y, UINT width, UINT height, bool showScrollbars)
{
WNDCLASSEX wcex;
static const char *className = "WebWindowClass";
this->hInstWebWindow = hInstance;
this->showScrollbars = showScrollbars;
if (!GetClassInfoEx(hInstance, className, &wcex)) {
ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WebWindowWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = sizeof(this);
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = className;
wcex.hIconSm = NULL;
if (!RegisterClassEx(&wcex)) {
MessageBox(NULL, "Error registering WebWindow window class", "WebWindow::Create", MB_OK);
return;
}
}
webForm = new WebForm(webformDispatchHandler);
/*HWND hWndDesktop = FindWindow("DesktopBackgroundClass", 0);
if (hWndDesktop == NULL) {
hWndDesktop = GetDesktopWindow();
}*/
hWndWebWindow = CreateWindowEx(0, className, "WebWindowWindow", /*WS_CHILD*//*WS_POPUP | WS_CLIPCHILDREN*/WS_POPUPWINDOW | WS_CAPTION,
x, y, width, height, NULL/*hWndDesktop*/, NULL, hInstance, (LPVOID)this);
if (hWndWebWindow == NULL) {
MessageBox(NULL, "Error creating WebWindow window", "WebWindow::Create", MB_OK);
UnregisterClass(className, hInstance);
return;
}
ShowWindow(hWndWebWindow, SW_SHOW);
}
LRESULT CALLBACK WebWindow::WebWindowWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_NCCREATE) {
WebWindow *webw = (WebWindow*)((LPCREATESTRUCT(lParam))->lpCreateParams);
webw->hWndWebWindow = hWnd;
#pragma warning(suppress:4244)
SetWindowLongPtr(hWnd, 0, (LONG_PTR)webw);
return DefWindowProc(hWnd, msg, wParam, lParam);
}
#pragma warning(suppress:4312)
WebWindow *webw = (WebWindow*)GetWindowLongPtr(hWnd, 0);
if (webw == NULL) {
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return webw->InstanceWndProc(msg, wParam, lParam);
}
LRESULT WebWindow::InstanceWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_CREATE: {
webForm->create(hWndWebWindow, hInstWebWindow, 103, showScrollbars);
break;
}
case WM_SIZE:
if (webForm->hWnd) {
MoveWindow(webForm->hWnd, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
}
break;
case WM_COMMAND: {
int id = LOWORD(wParam);
int code = HIWORD(wParam);
if (id == 103 && code == WEBFN_LOADED) {
}
break;
}
case WM_DESTROY:
webForm->Close();
PostQuitMessage(0);
break;
}
return DefWindowProc(hWndWebWindow, msg, wParam, lParam);
}