Hi,
Can anyone help me to solve out this problem. I think DavidLowndes-6766 not understand the problem. Still, I get same message ""unable to read memory". And background color is not changed.
Thanks
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi,
I have a question about the background color of MFC.
My code is as follows
Mainfrm.h
class C_MainFrame : public CFrameWnd
{
public:
C_MainFrame(); // Declear Constructor
};
Mainfrm.cpp
// CMainFrame
//Define Constructor
C_MainFrame::C_MainFrame() {
HBRUSH hredBrush = ::CreateSolidBrush(RGB(255, 200, 20));
CString MyWindowClass = AfxRegisterWndClass(
CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW ,
AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING),
hredBrush, //"unable to read memory".
AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION));
Create(MyWindowClass, _T("Main Window A"), WS_OVERLAPPEDWINDOW);
::DeleteObject(hredBrush);
}
when I use hredBrush as parameter of AfxRegisterWndClass,It shows me "unable to read memory".
but when i use ::CreateSolidBrush(RGB(255, 200, 20)) as parameter of AfxRegisterWndClass it works fine.
I means refer the below code:
CString MyWindowClass = AfxRegisterWndClass(
CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW ,
AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING),
::CreateSolidBrush(RGB(255, 200, 20)), // work fine
AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION));
Create(MyWindowClass, _T("Main Window A"), WS_OVERLAPPEDWINDOW);
Can Anyone please help me to understand why this is happening?
Hi,
Can anyone help me to solve out this problem. I think DavidLowndes-6766 not understand the problem. Still, I get same message ""unable to read memory". And background color is not changed.
Thanks
Hi Viorel,
Thanks for Text.
If I define
HBRUSH hredBrush = ::CreateSolidBrush(RGB(255, 200, 20));
then
HBRUSH hredBrush = ::CreateSolidBrush(RGB(255, 200, 20));
CString MyWindowClass = AfxRegisterWndClass(
CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW ,
AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING),
hredBrush,
AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION));
Create(MyWindowClass, _T("Main Window A"), WS_OVERLAPPEDWINDOW);
::DeleteObject(hredBrush);
hredBrush is not able to change background color ,due to <Unable to read memory>
If I put only "::CreateSolidBrush(RGB(255, 200, 20))", insert of hredBrush in my code is work fine.
Can You Please tell me why this is happening?