In some applications, you may want to have a window
that occupies the whole desktop without a title bar or borders. Just as
you can achieve this with a Document/View based application, you can start
from a dialog box.
- Start Microsoft Visual C++ .Net or MS Visual Studio .Net and create
a new MFC Application named MaxDialog1
- Click OK
- Create the project as Dialog Based without an About Box
- Delete the TO DO line and the OK button
- Change the Caption of the Cancel button to X and resize it to 16 x
12 then set the Flat property to True
- Set the Title Bar property to False and the Border property to None
- Access the dialog's OnInitDialog event and implement it as follows:
BOOL CMaxDialog1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
WINDOWPLACEMENT WP;
POINT ptMinPos;
POINT ptMaxPos;
RECT rcNormalPos;
ptMinPos.x = 0;
ptMinPos.y = 0;
ptMaxPos.x = 0;
ptMaxPos.y = 0;
rcNormalPos.left = 0;
rcNormalPos.top = 0;
rcNormalPos.right = GetSystemMetrics(SM_CXSCREEN);
rcNormalPos.bottom = GetSystemMetrics(SM_CYSCREEN);
WP.length = sizeof(WINDOWPLACEMENT);
WP.flags = WPF_RESTORETOMAXIMIZED;
WP.showCmd = SW_SHOWMAXIMIZED;
WP.ptMinPosition = ptMinPos;
WP.ptMaxPosition = ptMaxPos;
WP.rcNormalPosition = rcNormalPos;
SetWindowPlacement(&WP);
CButton *btnClose;
btnClose = reinterpret_cast<CButton *>(GetDlgItem(IDCANCEL));
btnClose->MoveWindow(GetSystemMetrics(SM_CXSCREEN) - 22, 0, 22, 20);
return TRUE; // return TRUE unless you set the focus to a control
}
|
- Execute the application
|
|