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
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define NO_SHLWAPI_STREAM
39 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
45 HANDLE RICHED32_hHeap = (HANDLE)NULL;
46 /* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
48 #define DPRINTF_EDIT_MSG32(str) \
50 "32 bit : " str ": hwnd=%08x, wParam=%08x, lParam=%08x\n"\
52 hwnd, (UINT)wParam, (UINT)lParam)
55 /***********************************************************************
56 * RICHED32_LibMain [Internal] Initializes the internal 'RICHED32.DLL'.
59 * hinstDLL [I] handle to the DLL's instance
61 * lpvReserved [I] reserved, must be NULL
69 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
74 case DLL_PROCESS_ATTACH:
75 /* create private heap */
76 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
77 /* register the Rich Edit class */
81 case DLL_PROCESS_DETACH:
82 /* unregister all common control classes */
83 RICHED32_Unregister ();
84 HeapDestroy (RICHED32_hHeap);
85 RICHED32_hHeap = (HANDLE)NULL;
94 * Window procedure of the RichEdit control.
97 static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
100 int RTFToBuffer(char* pBuffer, int nBufferSize);
104 static HWND hwndEdit;
105 static HWND hwndParent;
106 static char* rtfBuffer;
115 DPRINTF_EDIT_MSG32("WM_CREATE");
117 /* remove SCROLLBARS from the current window style */
118 hwndParent = ((LPCREATESTRUCTA) lParam)->hwndParent;
120 newstyle = style = ((LPCREATESTRUCTA) lParam)->style;
121 newstyle &= ~WS_HSCROLL;
122 newstyle &= ~WS_VSCROLL;
123 newstyle &= ~ES_AUTOHSCROLL;
124 newstyle &= ~ES_AUTOVSCROLL;
126 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName,
128 hwnd, (HMENU) ID_EDIT,
129 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ;
131 SetWindowLongA(hwnd,GWL_STYLE, newstyle);
135 DPRINTF_EDIT_MSG32("WM_SETFOCUS");
136 SetFocus (hwndEdit) ;
140 DPRINTF_EDIT_MSG32("WM_SIZE");
141 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
145 DPRINTF_EDIT_MSG32("WM_COMMAND");
146 switch(HIWORD(wParam)) {
153 return SendMessageA(hwndParent, WM_COMMAND,
154 wParam, (LPARAM)(hwnd));
158 MessageBoxA (hwnd, "RichEdit control out of space.",
159 "ERROR", MB_OK | MB_ICONSTOP) ;
164 DPRINTF_EDIT_MSG32("EM_STREAMIN");
166 /* setup the RTF parser */
167 RTFSetEditStream(( EDITSTREAM*)lParam);
175 rtfBufferSize = RTFToBuffer(NULL, 0);
176 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
179 RTFToBuffer(rtfBuffer, rtfBufferSize);
180 SetWindowTextA(hwndEdit,rtfBuffer);
181 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
184 WARN("Not enough memory for a allocating rtfBuffer\n");
188 /* Message specific to Richedit controls */
190 case EM_AUTOURLDETECT:
191 DPRINTF_EDIT_MSG32("EM_AUTOURLDETECT");
195 DPRINTF_EDIT_MSG32("EM_CANPASTE");
199 DPRINTF_EDIT_MSG32("EM_CANREDO");
203 DPRINTF_EDIT_MSG32("EM_DISPLAYBAND");
207 DPRINTF_EDIT_MSG32("EM_EXGETSEL");
211 DPRINTF_EDIT_MSG32("EM_EXLIMITTEXT");
214 case EM_EXLINEFROMCHAR:
215 DPRINTF_EDIT_MSG32("EM_EXLINEFROMCHAR");
219 DPRINTF_EDIT_MSG32("EM_EXSETSEL");
223 DPRINTF_EDIT_MSG32("EM_FINDTEXT");
227 DPRINTF_EDIT_MSG32("EM_FINDTEXTEX");
231 DPRINTF_EDIT_MSG32("EM_FINDTEXTEXW");
235 DPRINTF_EDIT_MSG32("EM_FINDTEXTW");
238 case EM_FINDWORDBREAK:
239 DPRINTF_EDIT_MSG32("EM_FINDWORDBREAK");
243 DPRINTF_EDIT_MSG32("EM_FORMATRANGE");
246 case EM_GETAUTOURLDETECT:
247 DPRINTF_EDIT_MSG32("EM_GETAUTOURLDETECT");
250 case EM_GETBIDIOPTIONS:
251 DPRINTF_EDIT_MSG32("EM_GETBIDIOPTIONS");
254 case EM_GETCHARFORMAT:
255 DPRINTF_EDIT_MSG32("EM_GETCHARFORMAT");
258 case EM_GETEDITSTYLE:
259 DPRINTF_EDIT_MSG32("EM_GETEDITSTYLE");
262 case EM_GETEVENTMASK:
263 DPRINTF_EDIT_MSG32("EM_GETEVENTMASK");
267 DPRINTF_EDIT_MSG32("EM_GETIMECOLOR");
270 case EM_GETIMECOMPMODE:
271 DPRINTF_EDIT_MSG32("EM_GETIMECOMPMODE");
274 case EM_GETIMEOPTIONS:
275 DPRINTF_EDIT_MSG32("EM_GETIMEOPTIONS");
278 case EM_GETLANGOPTIONS:
279 DPRINTF_EDIT_MSG32("EM_GETLANGOPTIONS");
282 case EM_GETOLEINTERFACE:
283 DPRINTF_EDIT_MSG32("EM_GETOLEINTERFACE");
287 DPRINTF_EDIT_MSG32("EM_GETOPTIONS");
290 case EM_GETPARAFORMAT:
291 DPRINTF_EDIT_MSG32("EM_GETPARAFORMAT");
294 case EM_GETPUNCTUATION:
295 DPRINTF_EDIT_MSG32("EM_GETPUNCTUATION");
299 DPRINTF_EDIT_MSG32("EM_GETREDONAME");
302 case EM_GETSCROLLPOS:
303 DPRINTF_EDIT_MSG32("EM_GETSCROLLPOS");
307 DPRINTF_EDIT_MSG32("EM_GETSELTEXT");
311 DPRINTF_EDIT_MSG32("EM_GETTEXTEX");
314 case EM_GETTEXTLENGTHEX:
315 DPRINTF_EDIT_MSG32("EM_GETTEXTLENGTHEX");
319 DPRINTF_EDIT_MSG32("EM_GETTEXTMODE");
322 case EM_GETTEXTRANGE:
323 DPRINTF_EDIT_MSG32("EM_GETTEXTRANGE");
326 case EM_GETTYPOGRAPHYOPTIONS:
327 DPRINTF_EDIT_MSG32("EM_GETTYPOGRAPHYOPTIONS");
331 DPRINTF_EDIT_MSG32("EM_GETUNDONAME");
334 case EM_GETWORDBREAKPROCEX:
335 DPRINTF_EDIT_MSG32("EM_GETWORDBREAKPROCEX");
338 case EM_GETWORDWRAPMODE:
339 DPRINTF_EDIT_MSG32("EM_GETWORDWRAPMODE");
343 DPRINTF_EDIT_MSG32("EM_GETZOOM");
346 case EM_HIDESELECTION:
347 DPRINTF_EDIT_MSG32("EM_HIDESELECTION");
350 case EM_PASTESPECIAL:
351 DPRINTF_EDIT_MSG32("EM_PASTESPECIAL");
354 case EM_RECONVERSION:
355 DPRINTF_EDIT_MSG32("EM_RECONVERSION");
359 DPRINTF_EDIT_MSG32("EM_REDO");
362 case EM_REQUESTRESIZE:
363 DPRINTF_EDIT_MSG32("EM_REQUESTRESIZE");
366 case EM_SELECTIONTYPE:
367 DPRINTF_EDIT_MSG32("EM_SELECTIONTYPE");
370 case EM_SETBIDIOPTIONS:
371 DPRINTF_EDIT_MSG32("EM_SETBIDIOPTIONS");
374 case EM_SETBKGNDCOLOR:
375 DPRINTF_EDIT_MSG32("EM_SETBKGNDCOLOR");
378 case EM_SETCHARFORMAT:
379 DPRINTF_EDIT_MSG32("EM_SETCHARFORMAT");
382 case EM_SETEDITSTYLE:
383 DPRINTF_EDIT_MSG32("EM_SETEDITSTYLE");
386 case EM_SETEVENTMASK:
387 DPRINTF_EDIT_MSG32("EM_SETEVENTMASK");
391 DPRINTF_EDIT_MSG32("EM_SETFONTSIZE");
395 DPRINTF_EDIT_MSG32("EM_SETIMECOLO");
398 case EM_SETIMEOPTIONS:
399 DPRINTF_EDIT_MSG32("EM_SETIMEOPTIONS");
402 case EM_SETLANGOPTIONS:
403 DPRINTF_EDIT_MSG32("EM_SETLANGOPTIONS");
406 case EM_SETOLECALLBACK:
407 DPRINTF_EDIT_MSG32("EM_SETOLECALLBACK");
411 DPRINTF_EDIT_MSG32("EM_SETOPTIONS");
415 DPRINTF_EDIT_MSG32("EM_SETPALETTE");
418 case EM_SETPARAFORMAT:
419 DPRINTF_EDIT_MSG32("EM_SETPARAFORMAT");
422 case EM_SETPUNCTUATION:
423 DPRINTF_EDIT_MSG32("EM_SETPUNCTUATION");
426 case EM_SETSCROLLPOS:
427 DPRINTF_EDIT_MSG32("EM_SETSCROLLPOS");
430 case EM_SETTARGETDEVICE:
431 DPRINTF_EDIT_MSG32("EM_SETTARGETDEVICE");
435 DPRINTF_EDIT_MSG32("EM_SETTEXTEX");
439 DPRINTF_EDIT_MSG32("EM_SETTEXTMODE");
442 case EM_SETTYPOGRAPHYOPTIONS:
443 DPRINTF_EDIT_MSG32("EM_SETTYPOGRAPHYOPTIONS");
446 case EM_SETUNDOLIMIT:
447 DPRINTF_EDIT_MSG32("EM_SETUNDOLIMIT");
450 case EM_SETWORDBREAKPROCEX:
451 DPRINTF_EDIT_MSG32("EM_SETWORDBREAKPROCEX");
454 case EM_SETWORDWRAPMODE:
455 DPRINTF_EDIT_MSG32("EM_SETWORDWRAPMODE");
459 DPRINTF_EDIT_MSG32("EM_SETZOOM");
462 case EM_SHOWSCROLLBAR:
463 DPRINTF_EDIT_MSG32("EM_SHOWSCROLLBAR");
466 case EM_STOPGROUPTYPING:
467 DPRINTF_EDIT_MSG32("EM_STOPGROUPTYPING");
471 DPRINTF_EDIT_MSG32("EM_STREAMOUT");
474 /* Messaged dispatched to the edit control */
477 case EM_EMPTYUNDOBUFFER:
479 case EM_GETFIRSTVISIBLELINE:
481 /* case EM_GETIMESTATUS:*/
482 case EM_GETLIMITTEXT:
484 case EM_GETLINECOUNT:
487 case EM_GETPASSWORDCHAR:
491 case EM_GETWORDBREAKPROC:
492 case EM_LINEFROMCHAR:
501 /* case EM_SETIMESTATUS:*/
502 case EM_SETLIMITTEXT:
505 case EM_SETPASSWORDCHAR:
511 case EM_SETWORDBREAKPROC:
514 case WM_STYLECHANGING:
515 case WM_STYLECHANGED:
518 case WM_GETTEXTLENGTH:
520 return SendMessageA( hwndEdit, uMsg, wParam, lParam);
522 /* Messages known , but ignored. */
524 DPRINTF_EDIT_MSG32("WM_NCPAINT");
525 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
527 DPRINTF_EDIT_MSG32("WM_PAINT");
528 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
530 DPRINTF_EDIT_MSG32("WM_ERASEBKGND");
531 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
533 DPRINTF_EDIT_MSG32("WM_KILLFOCUS");
534 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
536 DPRINTF_EDIT_MSG32("WM_DESTROY");
537 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
538 case WM_CHILDACTIVATE:
539 DPRINTF_EDIT_MSG32("WM_CHILDACTIVATE");
540 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
542 case WM_WINDOWPOSCHANGING:
543 DPRINTF_EDIT_MSG32("WM_WINDOWPOSCHANGING");
544 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
545 case WM_WINDOWPOSCHANGED:
546 DPRINTF_EDIT_MSG32("WM_WINDOWPOSCHANGED");
547 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
548 /* case WM_INITIALUPDATE:
549 DPRINTF_EDIT_MSG32("WM_INITIALUPDATE");
550 return DefWindowProcA( hwnd,uMsg,wParam,lParam); */
551 case WM_CTLCOLOREDIT:
552 DPRINTF_EDIT_MSG32("WM_CTLCOLOREDIT");
553 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
555 DPRINTF_EDIT_MSG32("WM_SETCURSOR");
556 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
558 DPRINTF_EDIT_MSG32("WM_MOVE");
559 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
561 DPRINTF_EDIT_MSG32("WM_SHOWWINDOW");
562 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
567 FIXME("Unknown message 0x%04x\n", uMsg);
568 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
571 /***********************************************************************
572 * DllGetVersion [RICHED32.2]
574 * Retrieves version information of the 'RICHED32.DLL'
577 * pdvi [O] pointer to version information structure.
581 * Failure: E_INVALIDARG
584 * Returns version of a comctl32.dll from IE4.01 SP1.
588 RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
592 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
597 pdvi->dwMajorVersion = 4;
598 pdvi->dwMinorVersion = 0;
599 pdvi->dwBuildNumber = 0;
600 pdvi->dwPlatformID = 0;
607 * Registers the window class.
615 VOID RICHED32_Register(void)
621 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
622 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
623 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
624 wndClass.cbClsExtra = 0;
625 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
626 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
627 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
628 wndClass.lpszClassName = RICHEDIT_CLASS10A;//WC_RICHED32A;
630 RegisterClassA (&wndClass);
635 * Unregisters the window class.
643 VOID RICHED32_Unregister(void)
647 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);