我的单文档程序的那个标题内容总是“无标题—**”怎么改一下。

解决方案 »

  1.   

    主框架的SetWindowText()就可以了.
      

  2.   

    ::OnNewDocument()
    {
    if (!CDocument::OnNewDocument())
    return FALSE;
    // TODO: add reinitialization code here
    // (SDI documents will reuse this document)
    SetTitle("你的标题啦");
    return TRUE;
      

  3.   

    这个要再inistance里面改。
    AfxGetApp->GetMainWnd()->SetWindowText(string);
      

  4.   

    可以直接SetWindowText
    或者CDoc::SetTitle还有一种办法
    不让它自动新建文档
    BOOL CXApp::InitInstance()
    {
    ...
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    ...
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    ...
    }
      

  5.   

    在precreatewindow中去掉FWS_ADDTOTITLE风格
    然后用SetWindowText就可以了
      

  6.   

    其实标题栏由两部分组成
    同时更改可以在框架类中直接使用SetWindowText("NewName");
    分开更改如下:一部分是更改资源里字符串IDR_MAINFRAME
    另一部分是文档名 使用SetTitle ()如在SDI中
    BOOL CYourDoc::OnNewDocument() 
    {
    if (!CDocument::OnNewDocument())
       return FALSE;
    SetTitle ("你想要的标题");
    return true;
    }
      

  7.   

    在主框架类CMainFrame中的PreCreateWindow中加入"cs.style=WS_OVERLAPPED|WS_SYSMENU|WS_BORDER;
    return CFrameWnd::PreCreateWindow(cs);
    这样绝对可以。  把原来的此函数中的代码都删除。
      

  8.   

    想要动态的改的话,要先读入你的字符然后SetWindowText(string);
      

  9.   


    去掉在主窗口标题上显示"Untitled - MyApp."
    方法一:重载CDocument的虚函数"SetTitle":
    void CMyDoc::SetTitle(LPCTSTR lpszTitle) 
    {
    CDocument::SetTitle("MyTitle");
    }
    *这个方法是将标题改为"MyTitle - MyApp"
    方法二:在程序中的任何位置调用下面的函数:
    (AfxGetMainWnd( ))->SetWindowText("MyApp");
    *这个方法是将标题改为"MyApp",但是每当一个文档对象被创建时,MFC就会加上文档名
    方法三:重载CFrameWnd的虚函数"OnUpdateFrameTitle"
    void CMainFrame::OnUpdateFrameTitle(BOOL Nada) 
    {
    // get app name from string table resource
    //----------------------------------------
    CString csAppName;
    csAppName.Format(AFX_IDS_APP_TITLE); 
    // Set caption of main frame window
    //---------------------------------
    SetWindowText(csAppName);
    }
    *注意,在微软的联机帮助中是找不到这个函数的,在新的版本中也可能不支持这个函数,所以要慎用
    方法四:最好的和最安全的方法,就是改写窗口的属性
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    cs.style &= ~(LONG) FWS_ADDTOTITLE;return CFrameWnd::PreCreateWindow(cs);
    }
      

  10.   

    void CMainFrame::OnUpdateFrameTitle(BOOL Nada) 
    {
    }
    CMainFrame::OnUpdateFrameTitle(BOOL Nada)重载为空(这样标题不会自动变化)然后随便在什么地方SetWindowText都行