Prevent crash when no URL is specified.
[wine] / dlls / ddraw / dsurface / wndproc.c
1 /*      User-based primary surface driver
2  *
3  * Copyright 2000 TransGaming Technologies Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include "config.h"
21
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include "winerror.h"
27
28 #include "ddraw_private.h"
29 #include "dsurface/wndproc.h"
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
34
35 static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
36
37 void DirectDrawSurface_RegisterClass(void)
38 {
39     WNDCLASSA wc;
40     memset(&wc, 0, sizeof(wc));
41     wc.lpfnWndProc = DirectDrawSurface_WndProc;
42     wc.cbWndExtra  = sizeof(IDirectDrawSurfaceImpl*);
43     wc.hCursor     = (HCURSOR)IDC_ARROW;
44     wc.lpszClassName = "WINE_DDRAW";
45     RegisterClassA(&wc);
46 }
47
48 void DirectDrawSurface_UnregisterClass(void)
49 {
50     UnregisterClassA("WINE_DDRAW", 0);
51 }
52
53 static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
54 {
55     IDirectDrawSurfaceImpl *This;
56     LRESULT ret;
57
58     This = (IDirectDrawSurfaceImpl *)GetWindowLongA(hwnd, 0);
59     if (This) {
60         HWND window = This->ddraw_owner->window;
61
62         switch (msg) {
63         case WM_DESTROY:
64         case WM_NCDESTROY:
65         case WM_SHOWWINDOW:
66         case WM_WINDOWPOSCHANGING:
67         case WM_WINDOWPOSCHANGED:
68         case WM_SIZE:
69         case WM_MOVE:
70         case WM_ERASEBKGND:
71         case WM_SYNCPAINT:
72             /* since we're pretending fullscreen,
73              * let's not pass these on to the app */
74             ret = DefWindowProcA(hwnd, msg, wParam, lParam);
75             break;
76         case WM_NCHITTEST:
77             ret = HTCLIENT;
78             break;
79         case WM_MOUSEACTIVATE:
80             ret = MA_NOACTIVATE;
81             break;
82         case WM_PAINT:
83             {
84                 PAINTSTRUCT ps;
85                 HDC dc;
86                 dc = BeginPaint(hwnd, &ps);
87                 /* call User_copy_to_screen? */
88                 EndPaint(hwnd, &ps);
89                 ret = 0;
90             }
91             break;
92         default:
93             ret = window ? SendMessageA(window, msg, wParam, lParam)
94                          : DefWindowProcA(hwnd, msg, wParam, lParam);
95         }
96     } else {
97         if (msg == WM_CREATE) {
98             CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
99             This = (IDirectDrawSurfaceImpl *)cs->lpCreateParams;
100             SetWindowLongA(hwnd, 0, (LONG)This);
101         }
102         ret = DefWindowProcA(hwnd, msg, wParam, lParam);
103     }
104     return ret;
105 }