WebBrowser на окне

 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
#include <Windows.h>
#include "webpage.h"
LRESULT CALLBACK Dlg_Proc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
switch ( wMsg )
{
case WM_CREATE:
if( EmbedBrowserObject(hWnd) )
return -1;
++WindowCount;
break;
case WM_SHOWWINDOW:
AttachSink(hWnd);
break;
case WM_SIZE:
HWND cw,pw;
pw = hWnd;
int i;
i = 0;
do
{
cw = FindWindowEx(pw, 0, 0, 0);
if( cw )
{
i++;
RECT rect;
GetClientRect(pw, &rect);
MoveWindow(cw, 0, 0, rect.right, rect.bottom, 1);
pw = cw;
}
}
while ( cw && (i < 2) );
break;
case WM_CLOSE:
SendMessage(hWnd, WM_DESTROY, 0, 0);
break;
case WM_DESTROY:
UnEmbedBrowserObject(hWnd);
--WindowCount;
if ( !WindowCount )
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, wMsg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain( __in HINSTANCE hInstance,
__in_opt HINSTANCE hPrevInstance,
__in_opt LPSTR lpCmdLine,
__in int nShowCmd )
{
MSG msg;
if ( OleInitialize(NULL) == S_OK )
{
WNDCLASSEX wc;
ZeroMemory(&wc,sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hInstance = hInstance;
wc.lpfnWndProc = Dlg_Proc;
wc.lpszClassName = &ClassName[0];
RegisterClassEx(&wc);
if( (msg.hwnd = CreateWindowEx(0, &ClassName[0], "News", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_DESKTOP, NULL, hInstance, 0)) )
{
DisplayHTMLPage(msg.hwnd, "http://www.freedomworld.ru");
ShowWindow(msg.hwnd, SW_SHOW);
UpdateWindow(msg.hwnd);
}
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
OleUninitialize();
}
return 0;
}