我编写了这段代码来在对话框中绘制一个简单的矩形,我还将 ON_WM_PAINT() 添加到我的消息映射中。但它没有在我的对话中显示任何内容!如果有人能说出我在代码中的错误,我真的很感激:
void Ctest4Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = 2;
int y = 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
//I want to draw a rectangle
dc.Rectangle(10,10,50,50);
}
else
{
CDialogEx::OnPaint();
}
}