原始Win32中的Rich Edit控件 [英] Rich Edit Control in raw Win32

查看:189
本文介绍了原始Win32中的Rich Edit控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rich Edit Controls的文档真的像看起来一样糟糕(错误吗?)?现在,我正在手动调用LoadLibrary("riched20.dll")以便显示Rich Edit控件. Rich Edit的文档在使用Rich Edit控件的第一个代码示例中未能很好地说明这一点.

Is the documentation for Rich Edit Controls really as bad (wrong?) as it seems to be? Right now I'm manually calling LoadLibrary("riched20.dll") in order to get a Rich Edit Control to show up. The documentation for Rich Edit poorly demonstrates this in the first code sample for using Rich Edit controls.

它讨论了调用InitCommonControlsEx()添加视觉样式,但是没有提到要传递哪些标志.

It talks about calling InitCommonControlsEx() to add visual styles, but makes no mention of which flags to pass in.

是否有更好的方式来加载Rich Edit控件?

Is there a better way to load a Rich Edit control?

http://msdn.microsoft.com/zh-cn/library/bb787877(VS.85).aspx

这是我唯一可以编写的代码:

Here's the only code I could write to make it work:

#include "Richedit.h"
#include "commctrl.h"

INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_USEREX_CLASSES;  //Could be 0xFFFFFFFF and it still wouldn't work
InitCommonControlsEx(&icex);  //Does nothing for Rich Edit controls

LoadLibrary("riched20.dll");  //Manually?  For real?
hWndRichEdit = CreateWindowEx(
    ES_SUNKEN,
    RICHEDIT_CLASS,
    "",
    WS_BORDER | WS_VISIBLE | WS_CHILD,
    2, 2, 100, 24,
    hWnd, (HMENU) ID_RICH_EDIT, hInst, NULL);

推荐答案

使用MFC,RichEdit控件可以正常工作.

Using MFC, RichEdit controls just work.

使用InitCommonControlsEx()进行加载-ICC_USEREX_CLASSES不会加载RichEdit AFAIK,您不需要它,因为它只会加载不包含richedit的标准"通用控件.显然,您只需要调用此选项即可在Windows中启用视觉样式",而不必让RichEdits正常工作.

Loading with InitCommonControlsEx() - ICC_USEREX_CLASSES doesn't load RichEdit AFAIK, you don't need it as it only does the 'standard' common controls, which don't include richedit. Apparently you only need to call this to enable 'visual styles' in Windows, not to get RichEdits working.

如果您使用的是2008,则要包含Msftedit.dll并改用MSFTEDIT_CLASS(MS有时是向后兼容的垃圾).

If you're using 2008, you want to include Msftedit.dll and use the MSFTEDIT_CLASS instead (MS are rubbish for backward compatibilty sometimes).

文档确实建议您正在正确地进行Win32编程.

The docs do suggest you're doing it right for Win32 programming.

这篇关于原始Win32中的Rich Edit控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆