// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// 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 CTestDrawComsDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
// 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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTestDrawComsDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CTestDrawComsDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CTestDrawComsDlg::MoveCldWnd(HWND hCldWnd, int offSetx, int offSety)
{
//移动子窗体
RECT rect;
::GetWindowRect(hCldWnd,&rect);
this->ScreenToClient(&rect);
::MapDialogRect(hCldWnd,&rect);
::OffsetRect(&rect,offSetx,offSety);
::MoveWindow(hCldWnd,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,true);
::UpdateWindow(hCldWnd);
}