C++ 在MFC中运行时更改编辑框属性
在我的应用程序中,我必须在运行时更改编辑框的字体、字体大小和背景色属性。当用户选择特定字体时,颜色应更新并在编辑框中可见。我正在尝试使用CColorDialog、CFontDialog来实现这一点。有什么有效的方法吗??。我可以使用VisualStudio环境中的属性栏来更改设置吗?我们在开发环境中用来更改属性的设置 您可以在以CEdit为父对象的类中捕获WM_CTLCOLOR消息,然后将CDC对象更改为您的内容。C++ 在MFC中运行时更改编辑框属性,c++,visual-studio-2008,visual-c++,mfc,C++,Visual Studio 2008,Visual C++,Mfc,在我的应用程序中,我必须在运行时更改编辑框的字体、字体大小和背景色属性。当用户选择特定字体时,颜色应更新并在编辑框中可见。我正在尝试使用CColorDialog、CFontDialog来实现这一点。有什么有效的方法吗??。我可以使用VisualStudio环境中的属性栏来更改设置吗?我们在开发环境中用来更改属性的设置 您可以在以CEdit为父对象的类中捕获WM_CTLCOLOR消息,然后将CDC对象更改为您的内容。 例如: HBRUSH CMyEdit::CtlColor(CDC* pDC, U
例如:
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;
}