下面的代码是用来创建 圆形对话框。
在对话框初始化代码中添加或者其它启动阶段添加。
BOOL CTestRoundDialogDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // 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 // TODO: Add extra initialization here CRgn rgn; rgn.CreateRectRgn(0,0,400,400); //画出方框 CRgn rox; rox.CreateEllipticRgn(0,0,400,400);//画出圆形 rox.CombineRgn(&rgn,&rox,RGN_AND);//两个区域重叠,其中第三个参数是负责划分两个区域的合并关系。有RGn_Copy、Rgn_diff等。 rgn.DeleteObject();//删除方框的object SetWindowRgn((HRGN)rox, TRUE);//设置窗口为这个rox。 return TRUE; // return TRUE unless you set the focus to a control }