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"
27 DEFAULT_DEBUG_CHANNEL(richedit);
29 HANDLE RICHED32_hHeap = (HANDLE)NULL;
30 DWORD RICHED32_dwProcessesAttached = 0;
31 /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
32 HMODULE RICHED32_hModule = 0;
34 /***********************************************************************
35 * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
38 * hinstDLL [I] handle to the DLL's instance
40 * lpvReserved [I] reserved, must be NULL
48 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
52 case DLL_PROCESS_ATTACH:
54 if (RICHED32_dwProcessesAttached == 0) {
56 /* This will be wrong for any other process attching in this address-space! */
57 RICHED32_hModule = (HMODULE)hinstDLL;
59 /* create private heap */
60 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
64 /* register the Rich Edit class */
67 RICHED32_dwProcessesAttached++;
70 case DLL_PROCESS_DETACH:
71 RICHED32_dwProcessesAttached--;
73 /* unregister all common control classes */
74 RICHED32_Unregister ();
76 if (RICHED32_dwProcessesAttached == 0) {
77 HeapDestroy (RICHED32_hHeap);
78 RICHED32_hHeap = (HANDLE)NULL;
89 * Window procedure of the RichEdit control.
92 static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
95 int RTFToBuffer(char* pBuffer, int nBufferSize);
100 static char* rtfBuffer;
108 /* remove SCROLLBARS from the current window style */
109 newstyle = style = ((LPCREATESTRUCTA) lParam)->style;
110 newstyle &= ~WS_HSCROLL;
111 newstyle &= ~WS_VSCROLL;
112 newstyle &= ~ES_AUTOHSCROLL;
113 newstyle &= ~ES_AUTOVSCROLL;
115 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName,
117 hwnd, (HMENU) ID_EDIT,
118 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ;
120 SetWindowLongA(hwnd,GWL_STYLE, newstyle);
124 SetFocus (hwndEdit) ;
128 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
132 if (LOWORD (wParam) == ID_EDIT)
133 if (HIWORD (wParam) == EN_ERRSPACE ||
134 HIWORD (wParam) == EN_MAXTEXT)
136 MessageBoxA (hwnd, "RichEdit control out of space.",
137 "ERROR", MB_OK | MB_ICONSTOP) ;
142 /* setup the RTF parser */
143 RTFSetEditStream(( EDITSTREAM*)lParam);
151 rtfBufferSize = RTFToBuffer(NULL, 0);
152 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
155 RTFToBuffer(rtfBuffer, rtfBufferSize);
156 SetWindowTextA(hwndEdit,rtfBuffer);
157 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
160 WARN("Not enough memory for a allocating rtfBuffer\n");
164 /*return SendMessageA( hwndEdit,uMsg,wParam,lParam);*/
165 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
168 /***********************************************************************
169 * DllGetVersion [COMCTL32.25]
171 * Retrieves version information of the 'COMCTL32.DLL'
174 * pdvi [O] pointer to version information structure.
178 * Failure: E_INVALIDARG
181 * Returns version of a comctl32.dll from IE4.01 SP1.
185 RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
187 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
192 pdvi->dwMajorVersion = 4;
193 pdvi->dwMinorVersion = 0;
194 pdvi->dwBuildNumber = 0;
195 pdvi->dwPlatformID = 0;
202 * Registers the window class.
210 VOID RICHED32_Register(void)
214 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
215 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
216 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
217 wndClass.cbClsExtra = 0;
218 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
219 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
220 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
221 wndClass.lpszClassName = RICHEDIT_CLASS10A;//WC_RICHED32A;
223 RegisterClassA (&wndClass);
228 * Unregisters the window class.
236 VOID RICHED32_Unregister(void)
238 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);