一个对话框的程序,如何在 InitInstance()中的dlg.DoModal()之前修改应用程序窗口的标题

解决方案 »

  1.   

    在OnInitDialog中
    SetWindowText(...)
      

  2.   

    BOOL CxxxDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here
    SetWindowText("Your title");
    return TRUE;  // return TRUE unless you set the focus to a control
                 }
      

  3.   

    在Domodal之前,让程序做一些事,你会发现有一个看不见窗口存在,在任务栏上还有它的标题,我想要改的就是这个标题,setwindowstext没用
      

  4.   

    InitInstance()中的dlg.DoModal()之前修改对话框标题是不行的,因为
    dlg.DoModal()之前dlg的句柄为空,无法SetWindowText,可以在OnInitDialog中
    SetWindowText(...)
      

  5.   

    上面两位没看懂我的意思,是在
    CXXAPP::Initinstance()
    {//在这儿修改标题,在oModal之前
    dlg.DoModal();
    }
      

  6.   

    应用程序标题可以查看:
    AfxMessageBox(AfxGetApp()->m_pszAppName);
    AfxMessageBox(AfxGetApp()->m_pszExeName);
    但修改好象不行,
    以下是微软MFC 的APPINI.CPP的97-106行在对m_pszAppName赋值时的说明:
    // m_pszAppName is the name used to present to the user
    if (m_pszAppName == NULL)
    {
    BOOL bEnable = AfxEnableMemoryTracking(FALSE);
    if (AfxLoadString(AFX_IDS_APP_TITLE, szTitle) != 0)
    m_pszAppName = _tcsdup(szTitle);    // human readable title
    else
    m_pszAppName = _tcsdup(m_pszExeName);   // same as EXE
    AfxEnableMemoryTracking(bEnable);
    }