关于RichEdit控件的一些资料
来源:互联网 发布:阿里云服务器怎么降配 编辑:程序博客网 时间:2024/05/30 23:15
How to Create Rich Edit Controls
To create a rich edit control, call the CreateWindowEx function, specifying the rich edit window class. For Microsoft Rich Edit 4.1 (Msftedit.dll), specify MSFTEDIT_CLASS as the window class. For all previous versions, specify RICHEDIT_CLASS. For more information, see Versions of Rich Edit.
Rich edit controls support most of the window styles used with edit controls as well as additional styles. You should specify the ES_MULTILINE window style if you want to allow more than one line of text in the control. For more information, see Rich Edit Control Styles.
What you need to know
Technologies
- Windows Controls
Prerequisites
- C/C++
- Windows User Interface Programming
Instructions
Create a Rich Edit Control
The following example function creates a rich edit control and initializes it with some text.
HWND CreateRichEdit(HWND hwndOwner, // Dialog box handle. int x, int y, // Location. int width, int height, // Dimensions. HINSTANCE hinst) // Application or DLL instance.{ LoadLibrary(TEXT("Msftedit.dll")); HWND hwndEdit= CreateWindowEx(0, MSFTEDIT_CLASS, TEXT("Type here"), ES_MULTILINE | WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP, x, y, width, height, hwndOwner, NULL, hinst, NULL); return hwndEdit;}
In Microsoft Visual Studio 2005 and later, it is possible to add a rich edit control into a dialog template by dragging the control from the toolbox. However, doing this in the dialog editor does not ensure that the required library will be loaded before the control is created. It is necessary to call the LoadLibrary function to load Riched32.dll, Riched20.dll, or Msftedit.dll before the dialog is created.
Remarks
To use visual styles with these controls, an application must include a manifest and must call the InitCommonControlsfunction at the beginning of the program. For information on visual styles, see Visual Styles. For information on manifests, see Enabling Visual Styles.
Related topics
- Using Rich Edit Controls
- Windows common controls demo (CppWindowsCommonControls)
Community Additions
ADDHow to create in C#
By default the RichTextBox control will use only use the 3.0 version of the rich edit control, you can make it use the 4.1 version by creating a subclass with the following code.
public class RichEdit50 : RichTextBox
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);
private const string MSFTEDIT_CLASS = "RICHEDIT50W";
protected override CreateParams CreateParams
{
get
{
CreateParams prams = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
prams.ClassName = MSFTEDIT_CLASS;
}
return prams;
}
}
}
RichEdit creation
HWND CreateRichEdit(HWND hWndOwner, int x, int y, int width, int height)
{
LoadLibrary("riched32.dll");
HWND hWndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, "", WS_CHILD | WS_VISIBLE | WS_VSCROLL |
WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, x, y, width, height,
hWndOwner, (HMENU) IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
return hWndEdit;
}
To compile this code, please add the header file <richedit.h> to your source code.
The variable IDC_MAINEDIT must be implemented as a define directive. Example:
#define IDC_MAINEDIT 101
- 关于RichEdit控件的一些资料
- 关于RICHEDIT控件的消息
- 关于类似RichEdit控件的设计思想
- 关于两个Richedit控件同步的实现
- 关于 richedit 控件
- RichEdit 控件的属性
- RichEdit控件的范例
- RichEdit控件的使用
- 关于ListCtrl,RichEdit和程序框架的一些东东
- RichEdit控件的使用(未完)
- delphi Richedit控件的用法
- 关于VIM的一些资料
- 关于sizeof的一些资料
- 关于OSB的一些资料
- 一些关于VANET的资料
- 关于ACM的一些资料
- 关于scheme的一些资料
- 一些关于电子信息工程的资料
- Mysql的优化
- Candy
- php动态网页实现页面静态化 通过在初次被访问时生成html文件保存起来,下次该PHP程序被访问时就直接找到以前被访问过的html页面
- Python中map()函数浅析
- 对于IP地址检测问题的考虑!
- 关于RichEdit控件的一些资料
- C#-format-删除字符串---ShinePans
- POJ 3792 Area of Polycubes(模拟)
- java23种设计模式的有趣解释
- 数据库连接 什么是长短连接??
- JAVA编程思想学习第一篇の对象导论
- 使用kingEditor实现图片上传
- Android设计模式——模板方法模式
- sed 用法