更改MFC中运行时的编辑框属性
Change Edit Box Properties at Runtime in MFC
在我的应用程序中,我必须在运行时更改编辑框的Font、Font Size和Background Color属性。当用户选择一种特定的字体时,它的颜色应该更新并在编辑框中可见。我正在尝试使用CColorDialog、CFontDialog来实现这一点。有什么有效的方法吗??。我可以像在Visual Studio环境中那样使用属性栏来更改设置吗?我们在开发环境中使用它来更改属性。
您可以在以CEdit为父级的类中捕获WM_CTLCOLOR消息,然后将CDC对象更改为您的内容
例如:
HBRUSH CMyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH hBrush;
hBrush = (HBRUSH)m_myBrush; // An handle on a brush which was created with your background color for the edit
pDC->SetBkColor(RGB(0, 0, 0)); // Color for the text background
pDC->SetTextColor(RGB(255, 255, 255)); // Color for the text
// More changes on the pDC like changing the font, etc...
return hBrush;
}
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- C++概念:如何使用'concept'检查模板化结构的属性?
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- 子目录是否继承属性,例如add_definitions,include_directories和父Cmakelist.t
- 通过指向指针数组的指针访问子类的属性
- MSVC是否支持C++11样式的属性而不是__declspec
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 类的C++属性似乎已重新初始化
- Qt Quick-如何仅从c++代码与qml属性交互
- 编辑文件中的文本
- 编辑期间的 QTableWidgetItem text() 属性
- 如何将按钮添加到节点的属性编辑器面板,该面板调用该节点内的方法?
- C++基类指针容器中,编辑特定对象的属性
- 删除/编辑 ATL COM DLL 属性/方法
- 在OpenGL中,如何从内存中编辑特定的顶点缓冲区属性
- 如何通过在运行时编辑文件来设置窗口属性
- 从qml编辑QObject属性
- 自定义构件上的 float 类型的Q_PROPERTY不会显示在属性编辑器中
- 通过代码添加具有可编辑属性的小部件
- 更改MFC中运行时的编辑框属性