Modify the title of the SDI Main Window

Source: Internet
Author: User

Generally,
SDI
The title of the main window is
:"
Document title
-
Main Window title
"
.

See
Winfrm. cpp
Code:

Void cframewnd: onupdateframetitle (bool
Baddtotitle)

{

...

Updateframetitlefordocument (pdocument-> gettitle ());

...

}

 


Void cframewnd: updateframetitlefordocument (lpctstr
Lpszdocname)

{

Cstring windowtext;

 


If (getstyle () & fws_prefixtitle)

{


//
Get name of currently active View

 

Windowtext + = lpszdocname + _ T ("-") + m_strtitle;

}

Else

{

 

Windowtext + = m_strtitle + _ T ("-") + lpszdocname;

}

Afxsetwindowtext (m_hwnd, (lpctstr)
Windowtext );

}

We can see that
,
The
Title
Is composed of the document block name and the title of the main window. Modifying the document title or the title of the main window can affect the final result.

 


 


You can modify the main window in the following ways:
Title
Method:

 


Method 1: document title change

 

Cdocument: settitle ()



For example
Onnewdocument ()
You can use
Settitle ()
Modify document title

 


 


Method 2: Change the title of the Main Window



The title of the main window is the project file name by default.


2.1

Exploitation
Resourceview
Open project resources and modify
String table
In
Idr_mainframe
Value


2.2

In
Cmainframe: precreatewindow ()
Modify
Cmainframe: m_strtitle



The preceding method can only modify the main window.
Title

Does not completely change the Main Window
Title
Form

 


 


Method 3:
Cxxxapp: initinstance ()
Direct Modification
Main Window
Title

 

M_pmainwnd-> setwindowtext (_ T ("
Main Window
Title "));

 

 

M_pmainwnd-> updatewindow ();



This method can completely modify the main window.
Title
, But once
Updatewindow
, Main Window
Title
It will be set back.

 


 


Method 4: Improve and modify method 2
M_strtitle
And later
Ws_overlappedwindow

Bool
Cmainframe: precreatewindow (createstruct & CS)

{

M_strtitle = _ T ("
Main Window
Title"
);

CS. Style = ws_overlappedwindow;

}



This ensures the Main Window
Title
Always unchanged.

 


Method 5: Process
Wm_settext
Message

This is the ultimate solution. If you want to dynamically set the main window
Title
Only this method is used.

 

More ........

Http://www.360watcher.net/html/60-5/5230.htm


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.