有关C++MFC编程语句的问题,请大家帮我看看语句什么意思!
voidCMyDlg::OnSysCommand(UINTnID,LPARAMlParam){if((nID&0xFFF0)==IDM_ABOUTBOX){CAboutD...
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (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 = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
这段程序总是看不懂!!请高手帮忙注解!谢谢!我会追加分数的!! 展开
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (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 = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
这段程序总是看不懂!!请高手帮忙注解!谢谢!我会追加分数的!! 展开
1个回答
展开全部
OnSysCommand
最大化、最小化等都会发送该消息
这里是如果是发送的帮助命令,那么显示帮助对话框,其他的话交给系统默认处理。
OnPaint
画面显示
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
这个函数,是发送WM_ICONERASEBKGND到本窗口消息队列,(WPARAM) dc.GetSafeHdc(), 是响应这个消息的函数的参数。WM_ICONERASEBKGND发送给某个最小化窗口,仅当它在画图标前它的背景必须被重画
后面获取图标信息,设置,然后重新画
最大化、最小化等都会发送该消息
这里是如果是发送的帮助命令,那么显示帮助对话框,其他的话交给系统默认处理。
OnPaint
画面显示
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
这个函数,是发送WM_ICONERASEBKGND到本窗口消息队列,(WPARAM) dc.GetSafeHdc(), 是响应这个消息的函数的参数。WM_ICONERASEBKGND发送给某个最小化窗口,仅当它在画图标前它的背景必须被重画
后面获取图标信息,设置,然后重新画
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询