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 #define DPRINTF_EDIT_MSG32(str) \
37 "32 bit : " str ": hwnd=%08x, wParam=%08x, lParam=%08x\n"\
39 hwnd, (UINT)wParam, (UINT)lParam)
42 /***********************************************************************
43 * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
46 * hinstDLL [I] handle to the DLL's instance
48 * lpvReserved [I] reserved, must be NULL
56 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
61 case DLL_PROCESS_ATTACH:
62 /* create private heap */
63 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
64 /* register the Rich Edit class */
68 case DLL_PROCESS_DETACH:
69 /* unregister all common control classes */
70 RICHED32_Unregister ();
71 HeapDestroy (RICHED32_hHeap);
72 RICHED32_hHeap = (HANDLE)NULL;
81 * Window procedure of the RichEdit control.
84 static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
87 int RTFToBuffer(char* pBuffer, int nBufferSize);
92 static HWND hwndParent;
93 static char* rtfBuffer;
102 DPRINTF_EDIT_MSG32("WM_CREATE");
104 /* remove SCROLLBARS from the current window style */
105 hwndParent = ((LPCREATESTRUCTA) lParam)->hwndParent;
107 newstyle = style = ((LPCREATESTRUCTA) lParam)->style;
108 newstyle &= ~WS_HSCROLL;
109 newstyle &= ~WS_VSCROLL;
110 newstyle &= ~ES_AUTOHSCROLL;
111 newstyle &= ~ES_AUTOVSCROLL;
113 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName,
115 hwnd, (HMENU) ID_EDIT,
116 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ;
118 SetWindowLongA(hwnd,GWL_STYLE, newstyle);
122 DPRINTF_EDIT_MSG32("WM_SETFOCUS");
123 SetFocus (hwndEdit) ;
127 DPRINTF_EDIT_MSG32("WM_SIZE");
128 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
132 DPRINTF_EDIT_MSG32("WM_COMMAND");
133 switch(HIWORD(wParam)) {
140 return SendMessageA(hwndParent, WM_COMMAND,
141 wParam, (LPARAM)(hwnd));
145 MessageBoxA (hwnd, "RichEdit control out of space.",
146 "ERROR", MB_OK | MB_ICONSTOP) ;
151 DPRINTF_EDIT_MSG32("EM_STREAMIN");
153 /* setup the RTF parser */
154 RTFSetEditStream(( EDITSTREAM*)lParam);
162 rtfBufferSize = RTFToBuffer(NULL, 0);
163 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
166 RTFToBuffer(rtfBuffer, rtfBufferSize);
167 SetWindowTextA(hwndEdit,rtfBuffer);
168 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
171 WARN("Not enough memory for a allocating rtfBuffer\n");
175 /* Message specific to Richedit controls */
177 case EM_AUTOURLDETECT:
178 DPRINTF_EDIT_MSG32("EM_AUTOURLDETECT");
182 DPRINTF_EDIT_MSG32("EM_CANPASTE");
186 DPRINTF_EDIT_MSG32("EM_CANREDO");
190 DPRINTF_EDIT_MSG32("EM_DISPLAYBAND");
194 DPRINTF_EDIT_MSG32("EM_EXGETSEL");
198 DPRINTF_EDIT_MSG32("EM_EXLIMITTEXT");
201 case EM_EXLINEFROMCHAR:
202 DPRINTF_EDIT_MSG32("EM_EXLINEFROMCHAR");
206 DPRINTF_EDIT_MSG32("EM_EXSETSEL");
210 DPRINTF_EDIT_MSG32("EM_FINDTEXT");
214 DPRINTF_EDIT_MSG32("EM_FINDTEXTEX");
218 DPRINTF_EDIT_MSG32("EM_FINDTEXTEXW");
222 DPRINTF_EDIT_MSG32("EM_FINDTEXTW");
225 case EM_FINDWORDBREAK:
226 DPRINTF_EDIT_MSG32("EM_FINDWORDBREAK");
230 DPRINTF_EDIT_MSG32("EM_FORMATRANGE");
233 case EM_GETAUTOURLDETECT:
234 DPRINTF_EDIT_MSG32("EM_GETAUTOURLDETECT");
237 case EM_GETBIDIOPTIONS:
238 DPRINTF_EDIT_MSG32("EM_GETBIDIOPTIONS");
241 case EM_GETCHARFORMAT:
242 DPRINTF_EDIT_MSG32("EM_GETCHARFORMAT");
245 case EM_GETEDITSTYLE:
246 DPRINTF_EDIT_MSG32("EM_GETEDITSTYLE");
249 case EM_GETEVENTMASK:
250 DPRINTF_EDIT_MSG32("EM_GETEVENTMASK");
254 DPRINTF_EDIT_MSG32("EM_GETIMECOLOR");
257 case EM_GETIMECOMPMODE:
258 DPRINTF_EDIT_MSG32("EM_GETIMECOMPMODE");
261 case EM_GETIMEOPTIONS:
262 DPRINTF_EDIT_MSG32("EM_GETIMEOPTIONS");
265 case EM_GETLANGOPTIONS:
266 DPRINTF_EDIT_MSG32("EM_GETLANGOPTIONS");
269 case EM_GETOLEINTERFACE:
270 DPRINTF_EDIT_MSG32("EM_GETOLEINTERFACE");
274 DPRINTF_EDIT_MSG32("EM_GETOPTIONS");
277 case EM_GETPARAFORMAT:
278 DPRINTF_EDIT_MSG32("EM_GETPARAFORMAT");
281 case EM_GETPUNCTUATION:
282 DPRINTF_EDIT_MSG32("EM_GETPUNCTUATION");
286 DPRINTF_EDIT_MSG32("EM_GETREDONAME");
289 case EM_GETSCROLLPOS:
290 DPRINTF_EDIT_MSG32("EM_GETSCROLLPOS");
294 DPRINTF_EDIT_MSG32("EM_GETSELTEXT");
298 DPRINTF_EDIT_MSG32("EM_GETTEXTEX");
301 case EM_GETTEXTLENGTHEX:
302 DPRINTF_EDIT_MSG32("EM_GETTEXTLENGTHEX");
306 DPRINTF_EDIT_MSG32("EM_GETTEXTMODE");
309 case EM_GETTEXTRANGE:
310 DPRINTF_EDIT_MSG32("EM_GETTEXTRANGE");
313 case EM_GETTYPOGRAPHYOPTIONS:
314 DPRINTF_EDIT_MSG32("EM_GETTYPOGRAPHYOPTIONS");
318 DPRINTF_EDIT_MSG32("EM_GETUNDONAME");
321 case EM_GETWORDBREAKPROCEX:
322 DPRINTF_EDIT_MSG32("EM_GETWORDBREAKPROCEX");
325 case EM_GETWORDWRAPMODE:
326 DPRINTF_EDIT_MSG32("EM_GETWORDWRAPMODE");
330 DPRINTF_EDIT_MSG32("EM_GETZOOM");
333 case EM_HIDESELECTION:
334 DPRINTF_EDIT_MSG32("EM_HIDESELECTION");
337 case EM_PASTESPECIAL:
338 DPRINTF_EDIT_MSG32("EM_PASTESPECIAL");
341 case EM_RECONVERSION:
342 DPRINTF_EDIT_MSG32("EM_RECONVERSION");
346 DPRINTF_EDIT_MSG32("EM_REDO");
349 case EM_REQUESTRESIZE:
350 DPRINTF_EDIT_MSG32("EM_REQUESTRESIZE");
353 case EM_SELECTIONTYPE:
354 DPRINTF_EDIT_MSG32("EM_SELECTIONTYPE");
357 case EM_SETBIDIOPTIONS:
358 DPRINTF_EDIT_MSG32("EM_SETBIDIOPTIONS");
361 case EM_SETBKGNDCOLOR:
362 DPRINTF_EDIT_MSG32("EM_SETBKGNDCOLOR");
365 case EM_SETCHARFORMAT:
366 DPRINTF_EDIT_MSG32("EM_SETCHARFORMAT");
369 case EM_SETEDITSTYLE:
370 DPRINTF_EDIT_MSG32("EM_SETEDITSTYLE");
373 case EM_SETEVENTMASK:
374 DPRINTF_EDIT_MSG32("EM_SETEVENTMASK");
378 DPRINTF_EDIT_MSG32("EM_SETFONTSIZE");
382 DPRINTF_EDIT_MSG32("EM_SETIMECOLO");
385 case EM_SETIMEOPTIONS:
386 DPRINTF_EDIT_MSG32("EM_SETIMEOPTIONS");
389 case EM_SETLANGOPTIONS:
390 DPRINTF_EDIT_MSG32("EM_SETLANGOPTIONS");
393 case EM_SETOLECALLBACK:
394 DPRINTF_EDIT_MSG32("EM_SETOLECALLBACK");
398 DPRINTF_EDIT_MSG32("EM_SETOPTIONS");
402 DPRINTF_EDIT_MSG32("EM_SETPALETTE");
405 case EM_SETPARAFORMAT:
406 DPRINTF_EDIT_MSG32("EM_SETPARAFORMAT");
409 case EM_SETPUNCTUATION:
410 DPRINTF_EDIT_MSG32("EM_SETPUNCTUATION");
413 case EM_SETSCROLLPOS:
414 DPRINTF_EDIT_MSG32("EM_SETSCROLLPOS");
417 case EM_SETTARGETDEVICE:
418 DPRINTF_EDIT_MSG32("EM_SETTARGETDEVICE");
422 DPRINTF_EDIT_MSG32("EM_SETTEXTEX");
426 DPRINTF_EDIT_MSG32("EM_SETTEXTMODE");
429 case EM_SETTYPOGRAPHYOPTIONS:
430 DPRINTF_EDIT_MSG32("EM_SETTYPOGRAPHYOPTIONS");
433 case EM_SETUNDOLIMIT:
434 DPRINTF_EDIT_MSG32("EM_SETUNDOLIMIT");
437 case EM_SETWORDBREAKPROCEX:
438 DPRINTF_EDIT_MSG32("EM_SETWORDBREAKPROCEX");
441 case EM_SETWORDWRAPMODE:
442 DPRINTF_EDIT_MSG32("EM_SETWORDWRAPMODE");
446 DPRINTF_EDIT_MSG32("EM_SETZOOM");
449 case EM_SHOWSCROLLBAR:
450 DPRINTF_EDIT_MSG32("EM_SHOWSCROLLBAR");
453 case EM_STOPGROUPTYPING:
454 DPRINTF_EDIT_MSG32("EM_STOPGROUPTYPING");
458 DPRINTF_EDIT_MSG32("EM_STREAMOUT");
461 /* Messaged dispatched to the edit control */
464 case EM_EMPTYUNDOBUFFER:
466 case EM_GETFIRSTVISIBLELINE:
468 /* case EM_GETIMESTATUS:*/
469 case EM_GETLIMITTEXT:
471 case EM_GETLINECOUNT:
474 case EM_GETPASSWORDCHAR:
478 case EM_GETWORDBREAKPROC:
479 case EM_LINEFROMCHAR:
488 /* case EM_SETIMESTATUS:*/
489 case EM_SETLIMITTEXT:
492 case EM_SETPASSWORDCHAR:
498 case EM_SETWORDBREAKPROC:
501 case WM_STYLECHANGING:
502 case WM_STYLECHANGED:
505 case WM_GETTEXTLENGTH:
507 return SendMessageA( hwndEdit, uMsg, wParam, lParam);
509 /* Messages known , but ignored. */
511 DPRINTF_EDIT_MSG32("WM_NCPAINT");
512 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
514 DPRINTF_EDIT_MSG32("WM_PAINT");
515 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
517 DPRINTF_EDIT_MSG32("WM_ERASEBKGND");
518 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
520 DPRINTF_EDIT_MSG32("WM_KILLFOCUS");
521 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
523 DPRINTF_EDIT_MSG32("WM_DESTROY");
524 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
525 case WM_CHILDACTIVATE:
526 DPRINTF_EDIT_MSG32("WM_CHILDACTIVATE");
527 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
529 case WM_WINDOWPOSCHANGING:
530 DPRINTF_EDIT_MSG32("WM_WINDOWPOSCHANGING");
531 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
532 case WM_WINDOWPOSCHANGED:
533 DPRINTF_EDIT_MSG32("WM_WINDOWPOSCHANGED");
534 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
535 /* case WM_INITIALUPDATE:
536 DPRINTF_EDIT_MSG32("WM_INITIALUPDATE");
537 return DefWindowProcA( hwnd,uMsg,wParam,lParam); */
538 case WM_CTLCOLOREDIT:
539 DPRINTF_EDIT_MSG32("WM_CTLCOLOREDIT");
540 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
542 DPRINTF_EDIT_MSG32("WM_SETCURSOR");
543 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
545 DPRINTF_EDIT_MSG32("WM_MOVE");
546 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
548 DPRINTF_EDIT_MSG32("WM_SHOWWINDOW");
549 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
554 FIXME("Unknown message %d\n", uMsg);
555 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
558 /***********************************************************************
559 * DllGetVersion [RICHED32.2]
561 * Retrieves version information of the 'RICHED32.DLL'
564 * pdvi [O] pointer to version information structure.
568 * Failure: E_INVALIDARG
571 * Returns version of a comctl32.dll from IE4.01 SP1.
575 RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
579 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
584 pdvi->dwMajorVersion = 4;
585 pdvi->dwMinorVersion = 0;
586 pdvi->dwBuildNumber = 0;
587 pdvi->dwPlatformID = 0;
594 * Registers the window class.
602 VOID RICHED32_Register(void)
608 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
609 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
610 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
611 wndClass.cbClsExtra = 0;
612 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
613 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
614 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
615 wndClass.lpszClassName = RICHEDIT_CLASS10A;//WC_RICHED32A;
617 RegisterClassA (&wndClass);
622 * Unregisters the window class.
630 VOID RICHED32_Unregister(void)
634 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);