亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch08.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
<SCRIPT LANGUAGE="JavaScript">

<!--

function popUp(pPage) {
 var fullURL = document.location;
 var textURL = fullURL.toString();
 var URLlen = textURL.length;
 var lenMinusPage = textURL.lastIndexOf("/");
 lenMinusPage += 1;
 var fullPath = textURL.substring(0,lenMinusPage);
 popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394');
 figDoc= popUpWin.document;
 zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>';
 zhtm += '<link rel="stylesheet" href="/includes/stylesheets/ebooks.css"></head>';
 zhtm += '<BODY bgcolor="#FFFFFF">';
 zhtm += '<IMG SRC="' + fullPath + pPage + '">';
 zhtm += '<P><B>' + pPage + '</B>';
 zhtm += '</BODY></HTML>';
 window.popUpWin.document.write(zhtm);
 window.popUpWin.document.close();
 // Johnny Jackson 4/28/98
 }

//-->
                                                                
</SCRIPT>
<link rel="stylesheet" href="/includes/stylesheets/ebooks.css">

	
	<TITLE>Special Edition Using Visual C++ 6 -- Ch 8 -- Building a Complete Application: ShowString</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<CENTER>
<H1><IMG SRC="../button/que.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
Special Edition Using Visual C++ 6</H1>
</CENTER>
<CENTER>
<P><A HREF="../ch07/ch07.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch09/ch09.htm"><IMG
SRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> 
<HR>

</CENTER>
<CENTER>
<H1>- 8 -</H1>
</CENTER>
<CENTER>
<H1>Building a Complete Application: ShowString</H1>
</CENTER>

<UL>
	<LI><A HREF="#Heading1">Building an Application That Displays a String</A>
	<UL>
		<LI><A HREF="#Heading2">Creating an Empty Shell with AppWizard</A>
		<LI><A HREF="#Heading3">Displaying a String</A>
	</UL>
	<LI><A HREF="#Heading4">Building the ShowString Menus</A>
	<LI><A HREF="#Heading5">Building the ShowString Dialog Boxes</A>
	<UL>
		<LI><A HREF="#Heading6">ShowString's About Dialog Box</A>
		<LI><A HREF="#Heading7">ShowString's Options Dialog Box</A>
	</UL>
	<LI><A HREF="#Heading8">Making the Menu Work</A>
	<UL>
		<LI><A HREF="#Heading9">The Dialog Box Class</A>
		<LI><A HREF="#Heading10">Catching the Message</A>
	</UL>
	<LI><A HREF="#Heading11">Making the Dialog Box Work</A>
	<LI><A HREF="#Heading12">Adding Appearance Options to the Options Dialog Box</A>
	<UL>
		<LI><A HREF="#Heading13">Changing the Options Dialog Box</A>
		<LI><A HREF="#Heading14">Adding Member Variables to the Dialog Box Class</A>
		<LI><A HREF="#Heading15">Adding Member Variables to the Document</A>
		<LI><A HREF="#Heading16">Changing OnToolsOptions()</A>
		<LI><A HREF="#Heading17">Changing OnDraw()</A>
	</UL>
</UL>

<P>
<HR SIZE="4">

<CENTER>
<H1></H1>
</CENTER>
<H2><A NAME="Heading1"></A>Building an Application That Displays a String</H2>
<P>In this chapter you pull together the concepts demonstrated in previous chapters
to create an application that really does something. You add a menu, a menu item,
a dialog box, and persistence to an application that draws output based on user settings.
In subsequent chapters this application serves as a base for more advanced work.</P>
<P>The sample application you will build is very much like the traditional &quot;Hello,
world!&quot; of C programming. It simply displays a text string in the main window.
The <I>document </I>(what you save in a file) contains the string and a few settings.
There is a new menu item to bring up a dialog box to change the string and the settings,
which control the string's appearance. This is a deliberately simple application
so that the concepts of adding menu items and adding dialogs are not obscured by
trying to understand the actual brains of the application. So, bring up Developer
Studio and follow along.</P>
<P>
<H3><A NAME="Heading2"></A>Creating an Empty Shell with AppWizard</H3>
<P>First, use AppWizard to create the starter application. (Chapter 1, &quot;Building
Your First Windows Application,&quot; covers AppWizard and creating starter applications.)
Choose File, New and the Project tab. Select an MFC AppWizard (exe) application,
name the project ShowString so that your classnames will match those shown throughout
this chapter, and click OK.</P>
<P>In Step 1 of AppWizard, it doesn't matter much whether you choose SDI or MDI,
but MDI will enable you to see for yourself how little effort is required to have
multiple documents open at once. So, choose MDI. Choose U.S. English, and then click
Next.</P>
<P>The ShowString application needs no database support and no compound document
support, so click Next on Step 2 and Step 3 without changing anything. In AppWizard's
Step 4 dialog box, select a docking toolbar, initial status bar, printing and print
preview, context-sensitive help, and 3D controls, and then click Next. Choose source
file comments and shared DLL, and then click Next. The classnames and filenames are
all fine, so click Finish. Figure 8.1 shows the final confirmation dialog box. Click
OK.</P>
<P><A HREF="javascript:popUp('08uvc01.gif')"><B>FIG. 8.1</B></A><B> </B><I>AppWizard
summarizes the design choices for ShowString.</I></P>
<P>
<H3><A NAME="Heading3"></A>Displaying a String</H3>
<P>The ShowString application displays a string that will be kept in the document.
You need to add a member variable to the document class, CShowStringDoc, and add
loading and saving code to the Serialize() function. You can initialize the string
by adding code to OnNewDocument() for the document and, in order to actually display
it, override OnDraw() for the view. Documents and views are introduced in Chapter
4, &quot;Documents and Views.&quot;</P>
<P><B>Member Variable and Serialization&#160;&#160;</B>Add a private variable to
the document and a public function to get the value by adding these lines to ShowStringDoc.h:</P>
<P>
<PRE>private:
    CString string;
public:
    CString GetString() {return string;}
</PRE>
<P>The inline function gives other parts of your application a copy of the string
to use whenever necessary but makes it impossible for other parts to change the string.</P>
<P>Next, change the skeleton CShowStringDoc::Serialize() function provided by AppWizard
to look like Listing 8.1. (Expand CShowStringDoc in ClassView and double-click Serialize()
to edit the code.) Because you used the MFC CString class, the archive has operators
&lt;&lt; and &gt;&gt; already defined, so this is a simple function to write. It
fills the archive from the string when you are saving the document and fills the
string from the archive when you are loading the document from a file. Chapter 7,
&quot;Persistence and File I/O,&quot; introduces serialization.</P>
<P>
<H4>Listing 8.1&#160;&#160;SHOWSTRINGDOC.CPP--CShowStringDoc::Serialize()</H4>
<PRE>void CShowStringDoc::Serialize(CArchive&amp; ar)
{
    if (ar.IsStoring())
    {
        ar &lt;&lt; string;
    }
    else
    {
        ar &gt;&gt; string;
    }
</PRE>
<PRE>}
</PRE>
<P><B>Initializing the String&#160;&#160;</B>Whenever a new document is created,
you want your application to initialize string to &quot;Hello, world!&quot;. A new
document is created when the user chooses File, New. This message is caught by CShowStringApp
(the message map is shown in Listing 8.2, you can see it yourself by scrolling toward
the top of ShowString.cpp) and handled by CWinApp::OnFileNew(). (Message maps and
message handlers are discussed in Chapter 3, &quot;Messages and Commands.&quot;)
Starter applications generated by AppWizard call OnFileNew() to create a blank document
when they run. OnFileNew() calls the document's OnNewDocument(), which actually initializes
the member variables of the document.</P>
<P>
<H4>Listing 8.2&#160;&#160;SHOWSTRING.CPP--Message Map</H4>
<PRE>BEGIN_MESSAGE_MAP(CShowStringApp, CWinApp)
     //{{AFX_MSG_MAP(CShowStringApp)
     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
          // NOTE - The ClassWizard will add and remove mapping macros here.
          //    DO NOT EDIT what you see in these blocks of generated code!
     //}}AFX_MSG_MAP
     // Standard file-based document commands
     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
     // Standard print setup command
     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
</PRE>
<PRE>END_MESSAGE_MAP()
</PRE>
<P>AppWizard gives you the simple OnNewDocument() shown in Listing 8.3. To see yours
in the editor, double-click OnNewDocument() in ClassView--you may have to expand
CshowStringDoc first.</P>
<P>
<H4>Listing 8.3&#160;&#160;SHOWSTRINGDOC.CPP--CShowStringDoc::OnNewDocument()</H4>
<PRE>BOOL CShowStringDoc::OnNewDocument()
{
    if (!CDocument::OnNewDocument())
        return FALSE;
    // TODO: add reinitialization code here
    // (SDI documents will reuse this document)
    return TRUE;
</PRE>
<PRE>}
</PRE>
<P>Take away the comments and add this line in their place:</P>
<P>
<PRE>string = &quot;Hello, world!&quot;;
</PRE>
<P>(What else could it say, after all?) Leave the call to CDocument::OnNewDocument()
because that will handle all other work involved in making a new document.</P>
<P><B>Getting the String Onscreen&#160;&#160;</B>As you learned in Chapter 5, &quot;Drawing
on the Screen,&quot; a view's OnDraw() function is called whenever that view needs
to be drawn, such as when your application is first started, resized, or restored
or when a window that had been covering it is taken away. AppWizard has provided
a skeleton, shown in Listing 8.4. To edit this function, expand CShowStringView in
ClassView and then double-click OnDraw().</P>
<P>
<H4>Listing 8.4&#160;&#160;SHOWSTRINGVIEW.CPP--CShowStringView::OnDraw()</H4>
<PRE>void CShowStringView::OnDraw(CDC* pDC)
{
    CShowStringDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
</PRE>
<PRE>}
</PRE>
<P>OnDraw() takes a pointer to a device context, as discussed in Chapter 5. The device
context class, CDC, has a member function called DrawText() that draws text onscreen.
It is declared like this:</P>
<P>
<PRE>int DrawText( const CString&amp; <I>str</I>, LPRECT <I>lpRect</I>, UINT <I>nFormat</I> )
</PRE>


<BLOCKQUOTE>
	<P>
<HR>
<B>See</B> &quot;Understanding Device Contexts,&quot; <A HREF="../ch05/ch05.htm"><B>ch.
	5</B></A> 
<HR>


</BLOCKQUOTE>

<P>The CString to be passed to this function is going to be the string from the document
class, which can be accessed as pDoc-&gt;GetString(). The lpRect is the client rectangle
of the view, returned by GetClientRect(). Finally, nFormat is the way the string
should display; for example, DT_CENTER means that the text should be centered from
left to right within the view. DT_VCENTER means that the text should be centered
up and down, but this works only for single lines of text that are identified with
DT_SINGLELINE. Multiple format flags can be combined with |, so DT_CENTER|DT_VCENTER|DT_SINGLELINE
is the nFormat that you want. The drawing code to be added to CShowStringView::OnDraw()
looks like this:</P>
<P>
<PRE>CRect rect;
GetClientRect(&amp;rect);
pDC-&gt;DrawText(pDoc-&gt;GetString(), &amp;rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
</PRE>
<P>This sets up a CRect and passes its address to GetClientRect(), which sets the
CRect to the client area of the view. DrawText() draws the document's string in the
rectangle, centered vertically and horizontally.</P>
<P>At this point, the application should display the string properly. Build and execute
it, and you will see something like Figure 8.2. You have a lot of functionality--menus,
toolbars, status bar, and so on--but nothing that any other Windows application doesn't
have, yet. Starting with the next section, that changes.</P>
<P><A HREF="javascript:popUp('08uvc02.gif')"><B>FIG. 8.2</B></A><B> </B><I>ShowString
starts simply, with the usual greeting.</I></P>
<P>
<H2><A NAME="Heading4"></A>Building the ShowString Menus</H2>
<P>AppWizard creates two menus for you, shown in the ResourceView window in Figure
8.3. IDR_MAINFRAME is the menu shown when no file is open; IDR_SHOWSTTYPE is the
menu shown when a ShowString document is open. Notice that IDR_MAINFRAME has no Window
menus and that the File menu is much shorter than the one on the IDR_SHOWSTTYPE menu,
with only New, Open, Print Setup, recent files, and Exit items.</P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
黄一区二区三区| 午夜精品一区二区三区三上悠亚 | 久久久久亚洲综合| 国产一区二区三区黄视频| 一区二区三区欧美亚洲| 中文字幕欧美国产| 久久精品一区二区三区不卡| 欧美精品一级二级三级| 色婷婷综合久久久中文字幕| 成人av在线资源网站| 国产在线不卡一卡二卡三卡四卡| 亚洲免费在线电影| 国产精品视频免费看| 2024国产精品| 亚洲精品在线观| 久久新电视剧免费观看| 色综合 综合色| 91视频在线观看免费| 成人黄色免费短视频| 国产.欧美.日韩| 成人福利视频在线| 91美女在线视频| 色天天综合久久久久综合片| 成人理论电影网| 99久久久免费精品国产一区二区| 成人免费毛片片v| 91性感美女视频| 欧美亚洲自拍偷拍| 日本韩国欧美三级| 在线观看网站黄不卡| 欧美日韩一区二区在线观看| 欧美在线啊v一区| 制服.丝袜.亚洲.另类.中文| 日韩精品乱码av一区二区| 日韩高清在线电影| 成人福利视频在线| 欧美电影免费观看高清完整版在| 中文字幕欧美日韩一区| 日本中文在线一区| 一本大道久久精品懂色aⅴ| 欧美va亚洲va国产综合| 成人免费在线播放视频| 久久国产乱子精品免费女| 91麻豆福利精品推荐| 2欧美一区二区三区在线观看视频| 国产精品福利av| 麻豆精品在线视频| 欧美性xxxxxxxx| 国产精品美女一区二区在线观看| 五月天婷婷综合| 不卡电影一区二区三区| 欧美精品一区二区三区在线播放 | 精品久久久久av影院| 亚洲男人电影天堂| 成人免费毛片片v| 久久久久久久久免费| 首页国产欧美日韩丝袜| 91视频在线看| 国产精品色噜噜| 精品一区二区在线免费观看| 欧美三级中文字幕在线观看| 亚洲精品视频在线看| 不卡在线观看av| 国产日韩精品一区二区三区在线| 精品在线观看免费| 日韩精品一区二区三区在线播放 | 欧洲人成人精品| 亚洲日本丝袜连裤袜办公室| 国产91丝袜在线18| 精品国产免费人成在线观看| 日本大胆欧美人术艺术动态| 欧美精品在线观看一区二区| 亚洲第一福利一区| 欧美日韩一区中文字幕| 午夜精品影院在线观看| 91精品久久久久久蜜臀| 日本麻豆一区二区三区视频| 日韩一区二区三区在线观看 | 国产日韩综合av| 国产成人免费视频网站高清观看视频| 欧美sm美女调教| 国产精品资源在线看| 国产日韩欧美a| 97精品国产露脸对白| 一区二区视频在线| 欧美色区777第一页| 日韩av不卡在线观看| 久久久久久久久久久99999| 国产成人精品aa毛片| 亚洲乱码国产乱码精品精小说| 欧洲人成人精品| 久久精品72免费观看| 国产午夜精品福利| 在线观看视频91| 久久99久久精品欧美| 国产精品网曝门| 欧美午夜精品电影| 久久疯狂做爰流白浆xx| 国产精品天天摸av网| 欧美色精品在线视频| 国产精品一区在线| 亚洲免费在线视频一区 二区| 91精品国产一区二区| 国产成人小视频| 视频一区国产视频| 久久久国产午夜精品| 欧美性感一区二区三区| 国产制服丝袜一区| 亚洲人吸女人奶水| 91精品国产综合久久久久久漫画 | 久久婷婷综合激情| 色噜噜狠狠色综合中国| 琪琪一区二区三区| 中文字幕综合网| 久久综合九色综合久久久精品综合| www.一区二区| 久久国产日韩欧美精品| 一区二区三区四区蜜桃| 久久中文字幕电影| 欧美日韩在线播| 99天天综合性| 高清在线成人网| 精品一区二区三区在线播放 | 亚洲国产综合在线| 日本一区免费视频| 日韩精品一区二区三区三区免费| 91麻豆国产福利精品| 国产成人综合在线| 久久99精品国产.久久久久| 亚洲另类色综合网站| 国产午夜一区二区三区| 欧美军同video69gay| 97se亚洲国产综合自在线| 国产91精品免费| 国产河南妇女毛片精品久久久| 免费美女久久99| 午夜精品影院在线观看| 亚洲制服丝袜一区| 一区二区三区国产豹纹内裤在线| 国产人妖乱国产精品人妖| 精品国产精品一区二区夜夜嗨 | 免费国产亚洲视频| 日韩成人午夜电影| 青娱乐精品视频| 五月综合激情婷婷六月色窝| 亚洲国产精品一区二区久久恐怖片| 亚洲欧美另类久久久精品| 国产精品久久久久久久久久免费看| 久久综合资源网| 精品日产卡一卡二卡麻豆| 精品日本一线二线三线不卡| 精品久久久久香蕉网| 精品国产伦一区二区三区免费 | 成人午夜视频免费看| 国产成人在线影院| 成人av网站在线观看免费| www.亚洲在线| 在线观看www91| 欧美一区二区三区在线看| 在线播放欧美女士性生活| 欧美一区二区视频在线观看2020| 欧美日韩日日夜夜| 欧美一区二区视频在线观看| 欧美sm极限捆绑bd| 国产精品女同互慰在线看| 亚洲欧美综合网| 亚洲国产成人精品视频| 日韩国产在线一| 国产成人精品三级| 91一区二区在线观看| 欧美日本韩国一区| 久久久精品tv| 夜夜亚洲天天久久| 美腿丝袜亚洲色图| 粗大黑人巨茎大战欧美成人| 91在线国产福利| 欧美一区二区免费视频| 久久精品一区二区三区av| 一区在线播放视频| 日韩国产在线观看一区| 国产精品一二三| 欧美中文一区二区三区| 日韩精品一区二区三区中文精品 | 午夜免费久久看| 国产精品自拍毛片| 欧美日韩精品一区二区天天拍小说| 日韩欧美国产一区二区在线播放| 欧美激情综合网| 日韩1区2区日韩1区2区| www.亚洲免费av| 欧美tickle裸体挠脚心vk| 亚洲另类在线视频| 国产精品一区一区三区| 欧美日韩精品系列| 国产欧美日韩综合| 美洲天堂一区二卡三卡四卡视频 | 亚洲成av人片一区二区梦乃 | 91搞黄在线观看| 久久人人97超碰com| 亚洲第一久久影院|