2 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <wtf/PassOwnPtr.h>
30 static const LPCWSTR kMainWindowTitle = L"WebKit for WinCE";
31 static const LPCWSTR kMainWindowClassName = L"MainWindowClass";
34 static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
42 return DefWindowProc(hWnd, message, wParam, lParam);
48 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
50 UNREFERENCED_PARAMETER(hPrevInstance);
52 CoInitializeEx(0, COINIT_MULTITHREADED);
53 WebView::initialize(hInstance);
55 LPCWSTR homeUrl = lpCmdLine;
56 bool enableDoubleBuffer = true;
57 bool fullscreen = false;
59 if (homeUrl[0] == '-') {
60 for (; *homeUrl && *homeUrl != ' '; ++homeUrl) {
63 enableDoubleBuffer = false;
76 DWORD styles = WS_VISIBLE;
88 wc.style = CS_HREDRAW | CS_VREDRAW;
89 wc.lpfnWndProc = WndProc;
92 wc.hInstance = hInstance;
95 wc.hbrBackground = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
97 wc.lpszClassName = kMainWindowClassName;
100 HWND hMainWindow = CreateWindowW(kMainWindowClassName, kMainWindowTitle, styles,
101 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, 0);
104 SetWindowPos(hMainWindow, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN),
105 GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
108 ShowWindow(hMainWindow, nCmdShow);
109 UpdateWindow(hMainWindow);
111 WTF::OwnPtr<WebView> webView = WTF::adoptPtr(new WebView(hMainWindow, enableDoubleBuffer ? WebView::EnableDoubleBuffering : WebView::NoFeature));
112 webView->load(homeUrl);
114 // Main message loop:
117 while (bRet = GetMessage(&msg, 0, 0, 0)) {
119 // FIXME: Handle the error and possibly exit.
121 TranslateMessage(&msg);
122 DispatchMessage(&msg);
127 DestroyWindow(hMainWindow);