VC++ full screen

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Win32 type screen source code:

1 remove the menu

ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style            = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra        = 0;
    wcex.cbWndExtra        = 0;
    wcex.hInstance        = hInstance;
    wcex.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_W32));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName    = NULL;//MAKEINTRESOURCE(IDC_W32); This is a revised
    wcex.lpszClassName    = szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

    return RegisterClassEx(&wcex);
}

2 Changes of window bar and width and height properties

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // The instance handle is stored in the global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_POPUP/*WS_OVERLAPPEDWINDOW*/,
      CW_USEDEFAULT, 0, ::GetSystemMetrics(SM_CXSCREEN)/*CW_USEDEFAULT*/, ::GetSystemMetrics(SM_CYSCREEN)/*0*/, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

Run, (alt+f4 exit.).


MFC SDI type of full screen code:

1 in the MainFrame to change the window style, remove the window bar display

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( !CFrameWndEx::PreCreateWindow(cs) )
        return FALSE;
    // By modifying the TODO: here
    //  CREATESTRUCT CS to modify the window class or style
    cs.style=WS_POPUPWINDOW;  //Add this sentence

cs.hMenu=NULL; //Remove the menu

return TRUE; }

2 in the App.cpp code window displays to maximize

m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED/*SW_SHOW*/);

3 in the CMainFrame:: all and menu, toolbar in OnCreate, statusbar related code, as follows:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
        return -1;

    BOOL bNameValid;
    // Lasting value and style based on Visual Manager
    OnApplicationLook(theApp.m_nAppLook);

    //if (!m_wndMenuBar.Create(this))
    //{
    //    TRACE0("Failed to create the \n menu bar");
    //    return -1;      // Failed to create
    //}

    //m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

    //// To prevent the menu bar focus on activation
    //CMFCPopupMenu::SetForceMenuFocus(FALSE);

    //if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    //    !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
    //{
    //    TRACE0("Failed to create the \n toolbar");
    //    return -1;      // Failed to create
    //}

    /*CString strToolBarName;
    bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
    ASSERT(bNameValid);
    m_wndToolBar.SetWindowText(strToolBarName);

    CString strCustomize;
    bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
    ASSERT(bNameValid);
    m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);*/

    // Allows the user to define the toolbar:
    //InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);

    //if (!m_wndStatusBar.Create(this))
    //{
    //    TRACE0("Failed to create the \n status bar");
    //    return -1;      // Failed to create
    //}
    //m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

    // TODO: if you don't want the toolbar and menu bar can be docked, please delete this row five
    
    /*m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockPane(&m_wndMenuBar);
    DockPane(&m_wndToolBar);*/


    // Enable Visual Studio 2005 style docking window behavior
    //CDockingManager::SetDockingMode(DT_SMART);
    // Enable Visual Studio 2005 style docking window automatically hide behavior
    //EnableAutoHidePanes(CBRS_ALIGN_ANY);

    // Turn on the toolbar and menu to replace the docked window
    //EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

    // Enable fast (press Alt to drag the toolbar custom)
    //CMFCToolBar::EnableQuickCustomization();

    if (CMFCToolBar::GetUserImages() == NULL)
    {
        // Image loading a user-defined toolbar
        if (m_UserImages.Load(_T(".\\UserImages.bmp")))
        {
            CMFCToolBar::SetUserImages(&m_UserImages);
        }
    }

    // Enable personalized menu (recently used commands)
    // TODO: defines the basic command of your own, to ensure that each dropdown menu at least a basic command. 
    CList<UINT, UINT> lstBasicCommands;

    lstBasicCommands.AddTail(ID_FILE_NEW);
    lstBasicCommands.AddTail(ID_FILE_OPEN);
    lstBasicCommands.AddTail(ID_FILE_SAVE);
    lstBasicCommands.AddTail(ID_FILE_PRINT);
    lstBasicCommands.AddTail(ID_APP_EXIT);
    lstBasicCommands.AddTail(ID_EDIT_CUT);
    lstBasicCommands.AddTail(ID_EDIT_PASTE);
    lstBasicCommands.AddTail(ID_EDIT_UNDO);
    lstBasicCommands.AddTail(ID_APP_ABOUT);
    lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
    lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA);
    lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7);

    CMFCToolBar::SetBasicCommands(lstBasicCommands);
    
    return 0;
}

4 in the corresponding View to remove the mouse right button shortcut menu event correlation

Well, get (alt+f4 exit).


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Melody at November 12, 2013 - 8:00 PM