Sync to Wine-20050830:
[reactos.git] / reactos / lib / 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 /* Unregisters the window class. */
44 static BOOL RICHED32_Unregister(void)
45 {
46 TRACE("\n");
47
48 UnregisterClassA(RICHEDIT_CLASS10A, NULL);
49 return TRUE;
50 }
51
52
53 /* Registers the window class. */
54 static BOOL RICHED32_Register(void)
55 {
56 WNDCLASSA wndClass;
57
58 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
59 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
60 wndClass.lpfnWndProc = RichEdit10ANSIWndProc;
61 wndClass.cbClsExtra = 0;
62 wndClass.cbWndExtra = 4;
63 wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
64 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
65 wndClass.lpszClassName = RICHEDIT_CLASS10A; /* WC_RICHED32A; */
66
67 RegisterClassA(&wndClass);
68
69 return TRUE;
70 }
71
72 /* Initialization function */
73 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
74 {
75 TRACE("\n");
76 switch (fdwReason)
77 {
78 case DLL_PROCESS_ATTACH:
79 DisableThreadLibraryCalls(hinstDLL);
80 return RICHED32_Register();
81
82 case DLL_PROCESS_DETACH:
83 return RICHED32_Unregister();
84 }
85 return TRUE;
86 }
87
88 /***********************************************************************
89 * DllGetVersion [RICHED32.2]
90 *
91 * Retrieves version information
92 */
93 HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
94 {
95 TRACE("\n");
96
97 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
98 return E_INVALIDARG;
99
100 pdvi->dwMajorVersion = 4;
101 pdvi->dwMinorVersion = 0;
102 pdvi->dwBuildNumber = 0;
103 pdvi->dwPlatformID = 0;
104
105 return S_OK;
106 }