?? 改變vc++應(yīng)用程序窗口的標(biāo)題.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0056)http://luwan.shtvu.edu.cn/lwyd/jslw/saomiao2/sm/sm16.htm -->
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD><TITLE>改變VC++應(yīng)用程序窗口的標(biāo)題</TITLE>
<META content="text/html; charset=GB2312" http-equiv=Content-Type>
<META content=FrontPage.Editor.Document name=ProgId>
<META content="MSHTML 5.00.3700.6699" name=GENERATOR>
<META content="Microsoft Word 9" name=Originator><LINK
href="./sm16.files/filelist.xml" rel=File-List><!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>feng</o:Author>
<o:LastAuthor>feng</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>90</o:TotalTime>
<o:Created>2003-01-15T06:57:00Z</o:Created>
<o:LastSaved>2003-01-15T06:57:00Z</o:LastSaved>
<o:Pages>2</o:Pages>
<o:Words>285</o:Words>
<o:Characters>1627</o:Characters>
<o:Company>zhao jiang</o:Company>
<o:Version>9.2812</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:DoNotHyphenateCaps/>
<w:PunctuationKerning/>
<w:DrawingGridHorizontalSpacing>6 磅</w:DrawingGridHorizontalSpacing>
<w:DrawingGridVerticalSpacing>6 磅</w:DrawingGridVerticalSpacing>
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
<w:DisplayVerticalDrawingGridEvery>3</w:DisplayVerticalDrawingGridEvery>
<w:UseMarginsForDrawingGridOrigin/>
<w:DoNotShadeFormData/>
<w:Compatibility>
<w:SpaceForUL/>
<w:BalanceSingleByteDoubleByteWidth/>
<w:DoNotLeaveBackslashAlone/>
<w:ULTrailSpace/>
<w:DoNotExpandShiftReturn/>
<w:FootnoteLayoutLikeWW8/>
<w:ShapeLayoutLikeWW8/>
<w:AlignTablesRowByRow/>
<w:ForgetLastTabAlignment/>
<w:AdjustLineHeightInTable/>
<w:LayoutRawTableWidth/>
<w:LayoutTableRowsApart/>
<w:UseFELayout/>
</w:Compatibility>
</w:WordDocument>
</xml><![endif]-->
<STYLE>@font-face {
font-family: 宋體;
}
@font-face {
font-family: \@宋體;
}
P.MsoNormal {
FONT-FAMILY: 宋體; FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-style-parent: ""; mso-layout-grid-align: none; mso-hansi-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"
}
LI.MsoNormal {
FONT-FAMILY: 宋體; FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-style-parent: ""; mso-layout-grid-align: none; mso-hansi-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"
}
DIV.MsoNormal {
FONT-FAMILY: 宋體; FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-style-parent: ""; mso-layout-grid-align: none; mso-hansi-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"
}
DIV.Section1 {
page: Section1
}
</STYLE>
</HEAD>
<BODY lang=ZH-CN style="TEXT-JUSTIFY-TRIM: punctuation; tab-interval: 36.0pt">
<DIV class=Section1>
<P align=center class=MsoNormal
style="LINE-HEIGHT: 13.9pt; TEXT-ALIGN: center; mso-line-height-rule: exactly; mso-pagination: widow-orphan"><B><SPAN
style="FONT-SIZE: 16pt">改變<SPAN
lang=EN-US>VC++應(yīng)用程序窗口的標(biāo)題<o:p></o:p></SPAN></SPAN></B></P>
<P align=center class=MsoNormal
style="LINE-HEIGHT: 13.9pt; TEXT-ALIGN: center; mso-line-height-rule: exactly; mso-pagination: widow-orphan">上海盧灣區(qū)業(yè)余大學(xué)<SPAN
lang=EN-US><SPAN style="mso-spacerun: yes">
</SPAN>邵祖銘</SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 15.1pt; TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">摘<SPAN lang=EN-US><SPAN
style="mso-spacerun: yes">
</SPAN>要:討論基于MFC類庫的Windows應(yīng)用程序設(shè)計(jì)中,應(yīng)用程序各種標(biāo)題的改變方法。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">關(guān)鍵詞<SPAN lang=EN-US>:MFC Windows編程標(biāo)題Visual
C++<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="mso-pagination: widow-orphan"><B><SPAN lang=EN-US
style="FONT-SIZE: 10.5pt">0 引言<o:p></o:p></SPAN></B></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">有一個(gè)演示<SPAN
lang=EN-US>VC++中的消息處理的單文檔應(yīng)用程序。該程序開始運(yùn)行的情況如下:<o:p></o:p></SPAN></SPAN></P>
<P align=center class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><IMG
border=0 height=200 src="改變VC++應(yīng)用程序窗口的標(biāo)題.files/~LWF00023.jpg" width=485></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">窗口中的初始文檔標(biāo)題競顯示為<SPAN
lang=EN-US>Untitled,實(shí)在不盡人意。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">有些時(shí)候<SPAN
lang=EN-US>,確實(shí)需要改變自編Windows應(yīng)用程序窗口的標(biāo)題。比如,想編一個(gè)標(biāo)題名為"Communication
soft的軟件。雖然在Windows95或Windows NT下,Visual C++(以下簡稱VC)可以生成以"Communication
soft為名的工程,但該工程下的C++類的名稱也要帶上這么多的字符,給編程帶來不便。可以采用的方法是生成以"CS為名的工程,再把程序的標(biāo)題改成"Communication
Soft。再比如,在多文檔應(yīng)用程序中,希望每個(gè)子窗口的標(biāo)題并不是"主窗口標(biāo)題t、"主窗口標(biāo)題2</SPAN></SPAN><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'; FONT-SIZE: 10.5pt; mso-ascii-font-family: 宋體">”</SPAN><SPAN
style="FONT-SIZE: 10.5pt">……這種類型<SPAN
lang=EN-US>,而是象"COM1速率"、"LPT并行口"……,即子窗口標(biāo)題與主窗口標(biāo)題無關(guān)。這時(shí)都需要改變各種窗口標(biāo)題。下面介紹一下改變窗口標(biāo)題所用的方法,所用的開發(fā)平臺是usual
C++5.0。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="mso-pagination: widow-orphan"><B><SPAN lang=EN-US
style="FONT-SIZE: 10.5pt">1 單又擋接口(SDI)典型窗口標(biāo)題的改變<o:p></o:p></SPAN></B></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">首先<SPAN lang=EN-US>,來看看Windows
SD!類型窗口標(biāo)題欄的結(jié)構(gòu)形式。用VC的AppWizard創(chuàng)建一個(gè)名為"Exam9的單文檔類型的工程。開始運(yùn)行時(shí),程序主窗口標(biāo)題形式如下:<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 1.9pt; TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">Untitled-Exam9<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">其中<SPAN
lang=EN-US>"Untitied"為文檔標(biāo)題,"Exam9"為主窗口標(biāo)題。當(dāng)用"File-Open</SPAN></SPAN><SPAN
lang=EN-US
style="FONT-FAMILY: 'Times New Roman'; FONT-SIZE: 10.5pt; mso-ascii-font-family: 宋體">”</SPAN><SPAN
style="FONT-SIZE: 10.5pt">打開<SPAN
lang=EN-US>"wd1.exm"文襠以后,文檔標(biāo)題變?yōu)?quot;wd1.exm"。</SPAN></SPAN></P>
<P align=center class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><IMG
border=0 height=240 src="改變VC++應(yīng)用程序窗口的標(biāo)題.files/~LWF00024.jpg" width=487></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US>所以程序主窗口標(biāo)題欄的一般形式為:<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">文襠標(biāo)題<SPAN
lang=EN-US>----主窗口標(biāo)題<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="mso-pagination: widow-orphan"><B><SPAN lang=EN-US
style="FONT-SIZE: 10.5pt">1.1 又檔標(biāo)題的改變<o:p></o:p></SPAN></B></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">既然文檔標(biāo)題是由工程中相應(yīng)的文檔類所控制的<SPAN
lang=EN-US>,了解這一點(diǎn),就可在相應(yīng)的文檔類中,利用SetTitle()函數(shù)來改變文檔標(biāo)題。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="mso-pagination: widow-orphan"><SPAN
style="FONT-SIZE: 10.5pt">例:改變<SPAN
lang=EN-US>CExam9Doc::onNewDocument()函數(shù)為:<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 1.4pt; TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">BOOL
CExam9Doc::OnNewDocument()<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 1.4pt; TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">{<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 1.4pt; TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US
style="FONT-SIZE: 10.5pt">if(!CDocument::OnNewDocument())<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 1.4pt; TEXT-INDENT: 42pt; mso-pagination: widow-orphan; mso-char-indent-count: 4.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">return FALSE-<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">SetTitle("文檔標(biāo)題");<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">return TRUE;<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="mso-pagination: widow-orphan"><SPAN
style="FONT-SIZE: 10.5pt">運(yùn)行程序<SPAN
lang=EN-US>,則每次選擇選單中的"文件"的"新建"選項(xiàng)時(shí),標(biāo)題就變成"文檔標(biāo)題-Exam9</SPAN></SPAN><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'; FONT-SIZE: 10.5pt; mso-ascii-font-family: 宋體">”</SPAN><SPAN
lang=EN-US style="FONT-SIZE: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN-TOP: 2.4pt; mso-pagination: widow-orphan"><B><SPAN lang=EN-US
style="FONT-SIZE: 10.5pt">1.2 主窗口標(biāo)題的改變<o:p></o:p></SPAN></B></P>
<P class=MsoNormal
style="TEXT-INDENT: 21pt; mso-pagination: widow-orphan; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN
style="FONT-SIZE: 10.5pt">主窗口的標(biāo)題默認(rèn)是工程的文件名<SPAN
lang=EN-US>,正如前面Appvvazied生成的Exam9工程執(zhí)行后,標(biāo)題欄的形式總為"文檔標(biāo)題-Exam9。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="mso-pagination: widow-orphan"><SPAN
style="FONT-SIZE: 10.5pt">改變主窗口的標(biāo)題方法有兩種<SPAN
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -