我在BOOL C......App::InitInstance()中添加以下代码 
        CMainFrame *pMain = (CMainFrame*)AfxGetApp()->m_pMainWnd; 
pMain->SetMenu(NULL);// int maxx = ::GetSystemMetrics(SM_CXSCREEN); 
int maxy = ::GetSystemMetrics(SM_CYSCREEN); 
pMain->ShowWindow(SW_SHOWMAXIMIZED); 
pMain->ModifyStyle(WS_OVERLAPPEDWINDOW|WS_TILEDWINDOW,WS_MAXIMIZE); 
::SetWindowPos(pMain->m_hWnd,HWND_TOPMOST,0 ,0,maxx,maxy,SWP_NOMOVE|SWP_SHOWWINDOW); 
pMain->ActivateFrame(0); pMain->ShowWindow(SW_SHOWMAXIMIZED); 
程序启动时自动隐藏菜单和标题栏,但新建文件或打开文件时菜单又出现, 
怎样才能保证在新建文档或打开文档时菜单不出现呢?

解决方案 »

  1.   

    如果想在应用程序中一直看不到菜单,可以在CMainFrame的PreCreateWindow()下的cs.hMenu = 0或为NULL即可
      

  2.   

    上面我说的那个方法对单文档是可以的,对多文档不行。不好意思啊!我试了下,现在可以解决这个问题了。
    CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(
    1,//IDR_GTRTYPE
       以下不写 了,其第一个参数加载的是菜单资源,这里我将其设为1,设成0不行(还没找到原因)
     1、    在下面红色地方加上语句
    CMainFrame* pMainFrame = new CMainFrame;
    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    return FALSE;
    m_pMainWnd = pMainFrame;
    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;
    // The main window has been initialized, so show and update it.
    pMainFrame->ShowWindow(m_nCmdShow);
    pMainFrame->UpdateWindow();
    m_pMainWnd->SetMenu(NULL);
    2.在文档类中改
    BOOL CGtrDoc::OnNewDocument()
    {
    if (!CDocument::OnNewDocument())
    return FALSE; // TODO: add reinitialization code here
    // (SDI documents will reuse this document)
    CMainFrame *pMain = (CMainFrame*)AfxGetApp()->m_pMainWnd; 
    pMain->SetMenu(NULL);// 

    return TRUE;
    }
    因为每次新建文档都会调用这个函数,所以在这里改也行