1
在资源rc中 添加对话框
并向对话框上拖放一个按钮
对话框的属性做下修改:Border改为None,Control改为Ture,Style改为Child,System改为False,Visible改为True,然后在对话框中双击,为对话 框添加一个类(将会自动打开类精灵)
2
在Ctrl.h中
public:
ViewDlg m_dlg; //自定义的对话框
3
int CclockCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
this->SetTimer(1,100,NULL);
this->m_BackColor=RGB(255,100,100);
this->m_ForeColor=RGB(55,55,0);
COLORREF color=this->TranslateColor(this->GetBackColor());
this->m_dlg.Create(IDD_DIALOG1,this);<span style="white-space:pre"> </span>//创建了对话框 上边的几行代码与本主题无关
return 0;
}
void CclockCtrl::OnSize(UINT nType, int cx, int cy)
{
COleControl::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rect;
this->GetClientRect(rect);
this->m_dlg.MoveWindow(rect);
}