I have created a customized class with inheriting CDockablepane in SDI application MFC. for ex.
class CLoginPage : public CDockablePane
{
public:
CLoginPage();
protected:
CStatic lbl_username;
CStatic lbl_password;
CEdit txt_username;
CEdit txt_password;
CButton btn_login;
CButton btn_Signup;
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
DECLARE_MESSAGE_MAP()
};
in .cpp I override oncreate function and onsize funtion
int CLoginPage::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
if(!lbl_username.Create(_T("User Name"), WS_CHILD | WS_VISIBLE, CRect(150, 150, 100, 30), this, ID_STATIC_USERNAME))
{
TRACE0("Failed to create userName in LoginPage window\n");
return -1;
}
......................................same for other control
}
void CLoginPage::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
// Tab control should cover the whole client area:
CRect rectClient;
this->GetWindowRect(rectClient);
lbl_username.SetWindowPos (NULL, rectClient.left+150, rectClient.top+150, 100, 30, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
.............................same for other control
}
when I run this it is displaying correctly as present in below image.
but after resize login window or move login window, it display very badly. please see below image
I don't know how to resolve this. Do I need to do something in WM_PAINT message or something else. I tried a lot but i din't get any option. Can someone please help me on this??


SetWindowPoseven though you are telling the system, that it should ignore those values (SWP_NOMOVE). Anyway, your issue is one of these:1YourWM_PAINTmessage handler is buggy.2YourWM_ERASEBKGNDmessage handler is inappropriate.3Your window class registration is missing theCS_HREDRAW/CS_VREDRAWwindow class styles. In other words: It's in the code we cannot see. Please show a minimal reproducible example. - IInspectableCS_HREDRAWandCS_VREDRAWcan only be used when registering a window class. - IInspectable