Practical Learning Logo

Creating a Border-Less, Title Bar-Less, Maximized Dialog Box



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.

  1. Start Microsoft Visual C++ .Net or MS Visual Studio .Net and create a new MFC Application named MaxDialog1
    New Project
  2. Click OK
  3. Create the project as Dialog Based without an About Box
  4. Delete the TO DO line and the OK button
  5. Change the Caption of the Cancel button to X and resize it to 16 x 12 then set the Flat property to True
  6. Set the Title Bar property to False and the Border property to None
    Border-less and Title Bar-less dialog box
  7. Access the dialog's OnInitDialog event and implement it as follows:
    BOOL CMaxDialog1Dlg::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
    	POINT ptMinPos;
    	POINT ptMaxPos;
    	RECT rcNormalPos;
    	ptMinPos.x = 0;
    	ptMinPos.y = 0;
    	ptMaxPos.x = 0;
    	ptMaxPos.y = 0;
    	rcNormalPos.left    = 0;     = 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;
    	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
  8. Execute the application



Home Copyright © 2002-2005 FunctionX, Inc.