~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/shdocvw/iexplore.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * SHDOCVW - Internet Explorer main frame window
  3  *
  4  * Copyright 2006 Mike McCormack (for CodeWeavers)
  5  * Copyright 2006 Jacek Caban (for CodeWeavers)
  6  *
  7  * This library is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU Lesser General Public
  9  * License as published by the Free Software Foundation; either
 10  * version 2.1 of the License, or (at your option) any later version.
 11  *
 12  * This library is distributed in the hope that it will be useful,
 13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15  * Lesser General Public License for more details.
 16  *
 17  * You should have received a copy of the GNU Lesser General Public
 18  * License along with this library; if not, write to the Free Software
 19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 20  */
 21 
 22 #define COBJMACROS
 23 
 24 #include <stdarg.h>
 25 #include "windef.h"
 26 #include "winbase.h"
 27 #include "winuser.h"
 28 #include "wingdi.h"
 29 #include "winnls.h"
 30 #include "ole2.h"
 31 #include "exdisp.h"
 32 #include "oleidl.h"
 33 
 34 #include "shdocvw.h"
 35 
 36 #include "wine/debug.h"
 37 
 38 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
 39 
 40 static const WCHAR szIEWinFrame[] = { 'I','E','F','r','a','m','e',0 };
 41 
 42 static LRESULT iewnd_OnCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
 43 {
 44     SetWindowLongPtrW(hwnd, 0, (LONG_PTR) lpcs->lpCreateParams);
 45     return 0;
 46 }
 47 
 48 static LRESULT iewnd_OnSize(InternetExplorer *This, INT width, INT height)
 49 {
 50     if(This->doc_host.hwnd)
 51         SetWindowPos(This->doc_host.hwnd, NULL, 0, 0, width, height,
 52                      SWP_NOZORDER | SWP_NOACTIVATE);
 53 
 54     return 0;
 55 }
 56 
 57 static LRESULT iewnd_OnDestroy(InternetExplorer *This)
 58 {
 59     TRACE("%p\n", This);
 60 
 61     This->frame_hwnd = NULL;
 62     PostQuitMessage(0); /* FIXME */
 63 
 64     return 0;
 65 }
 66 
 67 static LRESULT CALLBACK
 68 ie_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 69 {
 70     InternetExplorer *This = (InternetExplorer*) GetWindowLongPtrW(hwnd, 0);
 71 
 72     switch (msg)
 73     {
 74     case WM_CREATE:
 75         return iewnd_OnCreate(hwnd, (LPCREATESTRUCTW)lparam);
 76     case WM_DESTROY:
 77         return iewnd_OnDestroy(This);
 78     case WM_SIZE:
 79         return iewnd_OnSize(This, LOWORD(lparam), HIWORD(lparam));
 80     case WM_DOCHOSTTASK:
 81         return process_dochost_task(&This->doc_host, lparam);
 82     }
 83     return DefWindowProcW(hwnd, msg, wparam, lparam);
 84 }
 85 
 86 void register_iewindow_class(void)
 87 {
 88     WNDCLASSW wc;
 89 
 90     memset(&wc, 0, sizeof wc);
 91     wc.style = 0;
 92     wc.lpfnWndProc = ie_window_proc;
 93     wc.cbClsExtra = 0;
 94     wc.cbWndExtra = sizeof(InternetExplorer*);
 95     wc.hInstance = shdocvw_hinstance;
 96     wc.hIcon = 0;
 97     wc.hCursor = LoadCursorW(0, MAKEINTRESOURCEW(IDI_APPLICATION));
 98     wc.hbrBackground = 0;
 99     wc.lpszClassName = szIEWinFrame;
100     wc.lpszMenuName = NULL;
101 
102     RegisterClassW(&wc);
103 }
104 
105 void unregister_iewindow_class(void)
106 {
107     UnregisterClassW(szIEWinFrame, shdocvw_hinstance);
108 }
109 
110 static void create_frame_hwnd(InternetExplorer *This)
111 {
112     /* Windows uses "Microsoft Internet Explorer" */
113     static const WCHAR wszWineInternetExplorer[] =
114         {'W','i','n','e',' ','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
115 
116     This->frame_hwnd = CreateWindowExW(
117             WS_EX_WINDOWEDGE,
118             szIEWinFrame, wszWineInternetExplorer,
119             WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
120                 | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
121             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
122             NULL, NULL /* FIXME */, shdocvw_hinstance, This);
123 }
124 
125 static IWebBrowser2 *create_ie_window(LPCSTR cmdline)
126 {
127     IWebBrowser2 *wb = NULL;
128 
129     InternetExplorer_Create(NULL, &IID_IWebBrowser2, (void**)&wb);
130     if(!wb)
131         return NULL;
132 
133     IWebBrowser2_put_Visible(wb, VARIANT_TRUE);
134 
135     if(!*cmdline) {
136         IWebBrowser2_GoHome(wb);
137     }else {
138         VARIANT var_url;
139         DWORD len;
140 
141         if(!strncasecmp(cmdline, "-nohome", 7))
142             cmdline += 7;
143 
144         V_VT(&var_url) = VT_BSTR;
145 
146         len = MultiByteToWideChar(CP_ACP, 0, cmdline, -1, NULL, 0);
147         V_BSTR(&var_url) = SysAllocStringLen(NULL, len);
148         MultiByteToWideChar(CP_ACP, 0, cmdline, -1, V_BSTR(&var_url), len);
149 
150         /* navigate to the first page */
151         IWebBrowser2_Navigate2(wb, &var_url, NULL, NULL, NULL, NULL);
152 
153         SysFreeString(V_BSTR(&var_url));
154     }
155 
156     return wb;
157 }
158 
159 HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv)
160 {
161     InternetExplorer *ret;
162     HRESULT hres;
163 
164     TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv);
165 
166     ret = heap_alloc(sizeof(InternetExplorer));
167     ret->ref = 0;
168 
169     ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);
170     DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
171 
172     InternetExplorer_WebBrowser_Init(ret);
173 
174     create_frame_hwnd(ret);
175     ret->doc_host.frame_hwnd = ret->frame_hwnd;
176 
177     hres = IWebBrowser2_QueryInterface(WEBBROWSER2(ret), riid, ppv);
178     if(FAILED(hres)) {
179         heap_free(ret);
180         return hres;
181     }
182 
183     return hres;
184 }
185 
186 /******************************************************************
187  *              IEWinMain            (SHDOCVW.101)
188  *
189  * Only returns on error.
190  */
191 DWORD WINAPI IEWinMain(LPSTR szCommandLine, int nShowWindow)
192 {
193     IWebBrowser2 *wb = NULL;
194     MSG msg;
195     HRESULT hres;
196 
197     TRACE("%s %d\n", debugstr_a(szCommandLine), nShowWindow);
198 
199     if(*szCommandLine == '-' || *szCommandLine == '/') {
200         if(!strcasecmp(szCommandLine+1, "regserver"))
201             return register_iexplore(TRUE);
202         if(!strcasecmp(szCommandLine+1, "unregserver"))
203             return register_iexplore(FALSE);
204     }
205 
206     CoInitialize(NULL);
207 
208     hres = register_class_object(TRUE);
209     if(FAILED(hres)) {
210         CoUninitialize();
211         ExitProcess(1);
212     }
213 
214     if(strcasecmp(szCommandLine, "-embedding"))
215         wb = create_ie_window(szCommandLine);
216 
217     /* run the message loop for this thread */
218     while (GetMessageW(&msg, 0, 0, 0))
219     {
220         TranslateMessage(&msg);
221         DispatchMessageW(&msg);
222     }
223 
224     if(wb)
225         IWebBrowser2_Release(wb);
226 
227     register_class_object(FALSE);
228 
229     CoUninitialize();
230 
231     ExitProcess(0);
232     return 0;
233 }
234 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.