Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在MFC中运行时更改编辑框属性_C++_Visual Studio 2008_Visual C++_Mfc - Fatal编程技术网

C++ 在MFC中运行时更改编辑框属性

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

在我的应用程序中,我必须在运行时更改编辑框的字体、字体大小和背景色属性。当用户选择特定字体时,颜色应更新并在编辑框中可见。我正在尝试使用CColorDialog、CFontDialog来实现这一点。有什么有效的方法吗??。我可以使用VisualStudio环境中的属性栏来更改设置吗?我们在开发环境中用来更改属性的设置

您可以在以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;
}