Prevent crash when no URL is specified.
[wine] / dlls / richedit / richedit.c
1 /*
2  * RichEdit32  functions
3  *
4  * This module is a simple wrapper for the RichEdit 2.0 control
5  *
6  * Copyright 2000 by Jean-Claude Batista
7  * Copyright 2005 Mike McCormack
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include <stdarg.h>
25 #include <string.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winreg.h"
30 #include "winerror.h"
31 #include "winuser.h"
32 #include "richedit.h"
33 #include "shlwapi.h"
34
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
38
39 /* Window procedure of the RichEdit 1.0 control in riched20.dll */
40 extern LRESULT WINAPI RichEdit10ANSIWndProc(HWND, UINT, WPARAM, LPARAM);
41
42
43 /***********************************************************************
44  * DllGetVersion [RICHED32.2]
45  *
46  * Retrieves version information
47  */
48 HRESULT WINAPI RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
49 {
50     TRACE("\n");
51
52     if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
53         return E_INVALIDARG;
54
55     pdvi->dwMajorVersion = 4;
56     pdvi->dwMinorVersion = 0;
57     pdvi->dwBuildNumber = 0;
58     pdvi->dwPlatformID = 0;
59
60     return S_OK;
61 }
62
63 /* Unregisters the window class. */
64 static BOOL RICHED32_Unregister(void)
65 {
66     TRACE("\n");
67
68     UnregisterClassA(RICHEDIT_CLASS10A, NULL);
69     return TRUE;
70 }
71
72
73 /* Registers the window class. */
74 static BOOL RICHED32_Register(void)
75 {
76     WNDCLASSA wndClass;
77
78     ZeroMemory(&wndClass, sizeof(WNDCLASSA));
79     wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
80     wndClass.lpfnWndProc = RichEdit10ANSIWndProc;
81     wndClass.cbClsExtra = 0;
82     wndClass.cbWndExtra = 4;
83     wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
84     wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
85     wndClass.lpszClassName = RICHEDIT_CLASS10A; /* WC_RICHED32A; */
86
87     RegisterClassA(&wndClass);
88
89     return TRUE;
90 }
91
92 /* Initialization function */
93 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
94 {
95     TRACE("\n");
96     switch (fdwReason)
97     {
98     case DLL_PROCESS_ATTACH:
99         DisableThreadLibraryCalls(hinstDLL);
100         return RICHED32_Register();
101
102     case DLL_PROCESS_DETACH:
103         return RICHED32_Unregister();
104     }
105     return TRUE;
106 }