4 * This module is a simple wrap-arround the edit controls.
5 * At the point, it is good only for application who use the RICHEDIT control to
8 * Copyright 2000 by Jean-Claude Batista
15 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(richedit)
28 HANDLE RICHED32_hHeap = (HANDLE)NULL;
29 DWORD RICHED32_dwProcessesAttached = 0;
30 /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
31 HMODULE RICHED32_hModule = 0;
33 /***********************************************************************
34 * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
37 * hinstDLL [I] handle to the DLL's instance
39 * lpvReserved [I] reserved, must be NULL
47 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
51 case DLL_PROCESS_ATTACH:
53 if (RICHED32_dwProcessesAttached == 0) {
55 /* This will be wrong for any other process attching in this address-space! */
56 RICHED32_hModule = (HMODULE)hinstDLL;
58 /* create private heap */
59 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
63 /* register the Rich Edit class */
66 RICHED32_dwProcessesAttached++;
69 case DLL_PROCESS_DETACH:
70 RICHED32_dwProcessesAttached--;
72 /* unregister all common control classes */
73 RICHED32_Unregister ();
75 if (RICHED32_dwProcessesAttached == 0) {
76 HeapDestroy (RICHED32_hHeap);
77 RICHED32_hHeap = (HANDLE)NULL;
88 * Window procedure of the RichEdit control.
91 static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
94 int RTFToBuffer(char* pBuffer, int nBufferSize);
99 static char* rtfBuffer;
107 /* remove SCROLLBARS from the current window style */
108 newstyle = style = ((LPCREATESTRUCTA) lParam)->style;
109 newstyle &= ~WS_HSCROLL;
110 newstyle &= ~WS_VSCROLL;
111 newstyle &= ~ES_AUTOHSCROLL;
112 newstyle &= ~ES_AUTOVSCROLL;
114 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName,
116 hwnd, (HMENU) ID_EDIT,
117 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ;
119 SetWindowLongA(hwnd,GWL_STYLE, newstyle);
123 SetFocus (hwndEdit) ;
127 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
131 if (LOWORD (wParam) == ID_EDIT)
132 if (HIWORD (wParam) == EN_ERRSPACE ||
133 HIWORD (wParam) == EN_MAXTEXT)
135 MessageBoxA (hwnd, "RichEdit control out of space.",
136 "ERROR", MB_OK | MB_ICONSTOP) ;
141 /* setup the RTF parser */
142 RTFSetEditStream(( EDITSTREAM*)lParam);
150 rtfBufferSize = RTFToBuffer(NULL, 0);
151 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
154 RTFToBuffer(rtfBuffer, rtfBufferSize);
155 SetWindowTextA(hwndEdit,rtfBuffer);
156 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
159 WARN("Not enough memory for a allocating rtfBuffer\n");
163 /*return SendMessageA( hwndEdit,uMsg,wParam,lParam);*/
164 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
167 /***********************************************************************
168 * DllGetVersion [COMCTL32.25]
170 * Retrieves version information of the 'COMCTL32.DLL'
173 * pdvi [O] pointer to version information structure.
177 * Failure: E_INVALIDARG
180 * Returns version of a comctl32.dll from IE4.01 SP1.
184 RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
186 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
191 pdvi->dwMajorVersion = 4;
192 pdvi->dwMinorVersion = 0;
193 pdvi->dwBuildNumber = 0;
194 pdvi->dwPlatformID = 0;
201 * Registers the window class.
209 VOID RICHED32_Register(void)
213 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
214 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
215 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
216 wndClass.cbClsExtra = 0;
217 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
218 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
219 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
220 wndClass.lpszClassName = RICHEDIT_CLASS10A;//WC_RICHED32A;
222 RegisterClassA (&wndClass);
227 * Unregisters the window class.
235 VOID RICHED32_Unregister(void)
237 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);