4 * This module is a simple wrapper for the edit controls.
5 * At the point, it is good only for application who use the RICHEDIT
6 * control to display RTF text.
8 * Copyright 2000 by Jean-Claude Batista
21 #define NO_SHLWAPI_STREAM
26 #include "debugtools.h"
30 DEFAULT_DEBUG_CHANNEL(richedit);
32 HANDLE RICHED32_hHeap = (HANDLE)NULL;
33 /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
35 /***********************************************************************
36 * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
39 * hinstDLL [I] handle to the DLL's instance
41 * lpvReserved [I] reserved, must be NULL
49 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
53 case DLL_PROCESS_ATTACH:
54 /* create private heap */
55 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
56 /* register the Rich Edit class */
60 case DLL_PROCESS_DETACH:
61 /* unregister all common control classes */
62 RICHED32_Unregister ();
63 HeapDestroy (RICHED32_hHeap);
64 RICHED32_hHeap = (HANDLE)NULL;
73 * Window procedure of the RichEdit control.
76 static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
79 int RTFToBuffer(char* pBuffer, int nBufferSize);
84 static char* rtfBuffer;
92 /* remove SCROLLBARS from the current window style */
93 newstyle = style = ((LPCREATESTRUCTA) lParam)->style;
94 newstyle &= ~WS_HSCROLL;
95 newstyle &= ~WS_VSCROLL;
96 newstyle &= ~ES_AUTOHSCROLL;
97 newstyle &= ~ES_AUTOVSCROLL;
99 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName,
101 hwnd, (HMENU) ID_EDIT,
102 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ;
104 SetWindowLongA(hwnd,GWL_STYLE, newstyle);
108 SetFocus (hwndEdit) ;
112 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
116 if (LOWORD (wParam) == ID_EDIT)
117 if (HIWORD (wParam) == EN_ERRSPACE ||
118 HIWORD (wParam) == EN_MAXTEXT)
120 MessageBoxA (hwnd, "RichEdit control out of space.",
121 "ERROR", MB_OK | MB_ICONSTOP) ;
126 /* setup the RTF parser */
127 RTFSetEditStream(( EDITSTREAM*)lParam);
135 rtfBufferSize = RTFToBuffer(NULL, 0);
136 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
139 RTFToBuffer(rtfBuffer, rtfBufferSize);
140 SetWindowTextA(hwndEdit,rtfBuffer);
141 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
144 WARN("Not enough memory for a allocating rtfBuffer\n");
148 /*return SendMessageA( hwndEdit,uMsg,wParam,lParam);*/
149 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
152 /***********************************************************************
153 * DllGetVersion [RICHED32.2]
155 * Retrieves version information of the 'RICHED32.DLL'
158 * pdvi [O] pointer to version information structure.
162 * Failure: E_INVALIDARG
165 * Returns version of a comctl32.dll from IE4.01 SP1.
169 RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
171 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
176 pdvi->dwMajorVersion = 4;
177 pdvi->dwMinorVersion = 0;
178 pdvi->dwBuildNumber = 0;
179 pdvi->dwPlatformID = 0;
186 * Registers the window class.
194 VOID RICHED32_Register(void)
198 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
199 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
200 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
201 wndClass.cbClsExtra = 0;
202 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
203 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
204 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
205 wndClass.lpszClassName = RICHEDIT_CLASS10A;//WC_RICHED32A;
207 RegisterClassA (&wndClass);
212 * Unregisters the window class.
220 VOID RICHED32_Unregister(void)
222 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);