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
16 #include "debugtools.h"
28 DEFAULT_DEBUG_CHANNEL(richedit
);
30 HANDLE RICHED32_hHeap
= (HANDLE
)NULL
;
31 /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
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
:
52 /* create private heap */
53 RICHED32_hHeap
= HeapCreate (0, 0x10000, 0);
54 /* register the Rich Edit class */
58 case DLL_PROCESS_DETACH
:
59 /* unregister all common control classes */
60 RICHED32_Unregister ();
61 HeapDestroy (RICHED32_hHeap
);
62 RICHED32_hHeap
= (HANDLE
)NULL
;
71 * Window procedure of the RichEdit control.
74 static LRESULT WINAPI
RICHED32_WindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
,
77 int RTFToBuffer(char* pBuffer
, int nBufferSize
);
82 static char* rtfBuffer
;
90 /* remove SCROLLBARS from the current window style */
91 newstyle
= style
= ((LPCREATESTRUCTA
) lParam
)->style
;
92 newstyle
&= ~WS_HSCROLL
;
93 newstyle
&= ~WS_VSCROLL
;
94 newstyle
&= ~ES_AUTOHSCROLL
;
95 newstyle
&= ~ES_AUTOVSCROLL
;
97 hwndEdit
= CreateWindowA ("edit", ((LPCREATESTRUCTA
) lParam
)->lpszName
,
99 hwnd
, (HMENU
) ID_EDIT
,
100 ((LPCREATESTRUCTA
) lParam
)->hInstance
, NULL
) ;
102 SetWindowLongA(hwnd
,GWL_STYLE
, newstyle
);
106 SetFocus (hwndEdit
) ;
110 MoveWindow (hwndEdit
, 0, 0, LOWORD (lParam
), HIWORD (lParam
), TRUE
) ;
114 if (LOWORD (wParam
) == ID_EDIT
)
115 if (HIWORD (wParam
) == EN_ERRSPACE
||
116 HIWORD (wParam
) == EN_MAXTEXT
)
118 MessageBoxA (hwnd
, "RichEdit control out of space.",
119 "ERROR", MB_OK
| MB_ICONSTOP
) ;
124 /* setup the RTF parser */
125 RTFSetEditStream(( EDITSTREAM
*)lParam
);
133 rtfBufferSize
= RTFToBuffer(NULL
, 0);
134 rtfBuffer
= HeapAlloc(RICHED32_hHeap
, 0,rtfBufferSize
*sizeof(char));
137 RTFToBuffer(rtfBuffer
, rtfBufferSize
);
138 SetWindowTextA(hwndEdit
,rtfBuffer
);
139 HeapFree(RICHED32_hHeap
, 0,rtfBuffer
);
142 WARN("Not enough memory for a allocating rtfBuffer\n");
146 /*return SendMessageA( hwndEdit,uMsg,wParam,lParam);*/
147 return DefWindowProcA( hwnd
,uMsg
,wParam
,lParam
);
150 /***********************************************************************
151 * DllGetVersion [COMCTL32.25]
153 * Retrieves version information of the 'COMCTL32.DLL'
156 * pdvi [O] pointer to version information structure.
160 * Failure: E_INVALIDARG
163 * Returns version of a comctl32.dll from IE4.01 SP1.
167 RICHED32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
169 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
)) {
174 pdvi
->dwMajorVersion
= 4;
175 pdvi
->dwMinorVersion
= 0;
176 pdvi
->dwBuildNumber
= 0;
177 pdvi
->dwPlatformID
= 0;
184 * Registers the window class.
192 VOID
RICHED32_Register(void)
196 ZeroMemory(&wndClass
, sizeof(WNDCLASSA
));
197 wndClass
.style
= CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
;
198 wndClass
.lpfnWndProc
= (WNDPROC
)RICHED32_WindowProc
;
199 wndClass
.cbClsExtra
= 0;
200 wndClass
.cbWndExtra
= 0; /*(sizeof(RICHED32_INFO *);*/
201 wndClass
.hCursor
= LoadCursorA(0, IDC_ARROWA
);
202 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
203 wndClass
.lpszClassName
= RICHEDIT_CLASS10A
;//WC_RICHED32A;
205 RegisterClassA (&wndClass
);
210 * Unregisters the window class.
218 VOID
RICHED32_Unregister(void)
220 UnregisterClassA(RICHEDIT_CLASS10A
, (HINSTANCE
)NULL
);