1 /** DGui project file.
2 
3 Copyright: Trogu Antonio Davide 2011-2013
4 
5 License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 
7 Authors: Trogu Antonio Davide
8 */
9 
10 /*
11    From MSDN
12 
13    Rich Edit version	DLL	Window Class
14    ----
15    1.0	Riched32.dll	RICHEDIT_CLASS
16    2.0	Riched20.dll	RICHEDIT_CLASS
17    3.0	Riched20.dll	RICHEDIT_CLASS
18    4.1	Msftedit.dll	MSFTEDIT_CLASS
19 
20    Windows XP SP1:  Includes Microsoft Rich Edit 4.1, Microsoft Rich Edit 3.0, and a Microsoft Rich Edit 1.0 emulator.
21    Windows XP: 		Includes Microsoft Rich Edit 3.0 with a Microsoft Rich Edit 1.0 emulator.
22    Windows Me: 		Includes Microsoft Rich Edit 1.0 and 3.0.
23    Windows 2000:	Includes Microsoft Rich Edit 3.0 with a Microsoft Rich Edit 1.0 emulator.
24    Windows NT 4.0:	Includes Microsoft Rich Edit 1.0 and 2.0.
25    Windows 98:		Includes Microsoft Rich Edit 1.0 and 2.0.
26    Windows 95:		Includes only Microsoft Rich Edit 1.0. However, Riched20.dll is compatible with Windows 95 and may be installed by an application that requires it.
27  */
28 
29 module dgui.richtextbox;
30 
31 public import dgui.core.controls.textcontrol;
32 
33 class RichTextBox: TextControl
34 {
35 	private static int _refCount = 0;
36 	private static HMODULE _hRichDLL;
37 
38 	public override void dispose()
39 	{
40 		--_refCount;
41 
42 		if(!_refCount)
43 		{
44 			FreeLibrary(_hRichDLL);
45 			_hRichDLL = null;
46 		}
47 
48 		super.dispose();
49 	}
50 
51 	public void redo()
52 	{
53 		this.sendMessage(EM_REDO, 0, 0);
54 	}
55 
56 	protected override void createControlParams(ref CreateControlParams ccp)
57 	{
58 		// Probably the RichTextbox ignores the wParam parameter in WM_PAINT
59 
60 		++_refCount;
61 
62 		if(!_hRichDLL)
63 		{
64 			_hRichDLL = loadLibrary("RichEd20.dll"); // Load the standard version
65 		}
66 
67 		this.setStyle(ES_MULTILINE | ES_WANTRETURN, true);
68 		ccp.superclassName = WC_RICHEDIT;
69 		ccp.className = WC_DRICHEDIT;
70 
71 		super.createControlParams(ccp);
72 	}
73 
74 	protected override void onHandleCreated(EventArgs e)
75 	{
76 		super.onHandleCreated(e);
77 
78 		this.sendMessage(EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_UPDATE);
79 		this.sendMessage(EM_SETBKGNDCOLOR, 0, this._backColor.colorref);
80 	}
81 }