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 /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
32 /***********************************************************************
33 * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
36 * hinstDLL [I] handle to the DLL's instance
38 * lpvReserved [I] reserved, must be NULL
46 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
50 case DLL_PROCESS_ATTACH:
51 /* create private heap */
52 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
53 /* register the Rich Edit class */
57 case DLL_PROCESS_DETACH:
58 /* unregister all common control classes */
59 RICHED32_Unregister ();
60 HeapDestroy (RICHED32_hHeap);
61 RICHED32_hHeap = (HANDLE)NULL;
70 * Window procedure of the RichEdit control.
73 static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
76 int RTFToBuffer(char* pBuffer, int nBufferSize);
81 static char* rtfBuffer;
89 /* remove SCROLLBARS from the current window style */
90 newstyle = style = ((LPCREATESTRUCTA) lParam)->style;
91 newstyle &= ~WS_HSCROLL;
92 newstyle &= ~WS_VSCROLL;
93 newstyle &= ~ES_AUTOHSCROLL;
94 newstyle &= ~ES_AUTOVSCROLL;
96 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName,
98 hwnd, (HMENU) ID_EDIT,
99 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ;
101 SetWindowLongA(hwnd,GWL_STYLE, newstyle);
105 SetFocus (hwndEdit) ;
109 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
113 if (LOWORD (wParam) == ID_EDIT)
114 if (HIWORD (wParam) == EN_ERRSPACE ||
115 HIWORD (wParam) == EN_MAXTEXT)
117 MessageBoxA (hwnd, "RichEdit control out of space.",
118 "ERROR", MB_OK | MB_ICONSTOP) ;
123 /* setup the RTF parser */
124 RTFSetEditStream(( EDITSTREAM*)lParam);
132 rtfBufferSize = RTFToBuffer(NULL, 0);
133 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
136 RTFToBuffer(rtfBuffer, rtfBufferSize);
137 SetWindowTextA(hwndEdit,rtfBuffer);
138 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
141 WARN("Not enough memory for a allocating rtfBuffer\n");
145 /*return SendMessageA( hwndEdit,uMsg,wParam,lParam);*/
146 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
149 /***********************************************************************
150 * DllGetVersion [COMCTL32.25]
152 * Retrieves version information of the 'COMCTL32.DLL'
155 * pdvi [O] pointer to version information structure.
159 * Failure: E_INVALIDARG
162 * Returns version of a comctl32.dll from IE4.01 SP1.
166 RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
168 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
173 pdvi->dwMajorVersion = 4;
174 pdvi->dwMinorVersion = 0;
175 pdvi->dwBuildNumber = 0;
176 pdvi->dwPlatformID = 0;
183 * Registers the window class.
191 VOID RICHED32_Register(void)
195 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
196 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
197 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
198 wndClass.cbClsExtra = 0;
199 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
200 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
201 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
202 wndClass.lpszClassName = RICHEDIT_CLASS10A;//WC_RICHED32A;
204 RegisterClassA (&wndClass);
209 * Unregisters the window class.
217 VOID RICHED32_Unregister(void)
219 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);