亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产成人精品在线看| 国产情人综合久久777777| 亚洲综合图片区| 欧美日韩免费视频| 首页国产丝袜综合| 欧美v日韩v国产v| 国产大片一区二区| 最新欧美精品一区二区三区| 91黄色小视频| 蜜桃av一区二区在线观看| 国产日韩欧美亚洲| 色偷偷一区二区三区| 亚洲va欧美va人人爽午夜| 欧美大片日本大片免费观看| 国产精品77777| 一个色综合网站| 精品国产乱子伦一区| av亚洲精华国产精华| 亚洲福利电影网| 久久精品免费在线观看| 色88888久久久久久影院按摩| 日韩二区在线观看| 国产欧美一区二区精品性| 色999日韩国产欧美一区二区| 久久se这里有精品| 自拍视频在线观看一区二区| 宅男噜噜噜66一区二区66| 成人丝袜高跟foot| 日本中文一区二区三区| 中文av字幕一区| 69成人精品免费视频| 91在线国内视频| 麻豆国产欧美日韩综合精品二区| 国产精品久久国产精麻豆99网站| 538prom精品视频线放| 97精品国产露脸对白| 久久99热这里只有精品| 一区二区在线看| 国产丝袜欧美中文另类| 日韩一区二区三区电影| 色婷婷久久久综合中文字幕 | 日韩和欧美的一区| 国产精品午夜免费| 日韩欧美激情四射| 欧美日韩国产高清一区二区三区| 不卡视频免费播放| 国产真实精品久久二三区| 五月激情六月综合| 一二三区精品视频| 亚洲欧美日韩国产手机在线 | 久久蜜臀精品av| 777久久久精品| 日本电影欧美片| 99精品视频在线播放观看| 国产乱码字幕精品高清av| 日本视频在线一区| 亚洲成a人片综合在线| 亚洲免费观看视频| 国产精品美女视频| 久久久久99精品国产片| 日韩亚洲欧美在线观看| 欧美喷潮久久久xxxxx| 日本精品一区二区三区高清 | 亚洲黄一区二区三区| 国产精品久久久久aaaa| 国产精品三级久久久久三级| 久久久www成人免费毛片麻豆| 精品国产在天天线2019| 精品国产伦一区二区三区观看体验 | 国产精品毛片久久久久久| 精品美女一区二区三区| 欧美变态口味重另类| 日韩欧美电影一二三| 欧美v国产在线一区二区三区| 日韩一级免费观看| 精品久久国产97色综合| 精品国产髙清在线看国产毛片| 欧美一级生活片| 日韩美女在线视频| 久久新电视剧免费观看| 久久精品在线免费观看| 国产精品美女久久久久高潮| 中文字幕佐山爱一区二区免费| 亚洲色图一区二区三区| 一区二区三区不卡视频在线观看 | 久久99国产精品成人| 久久精品国产精品青草| 国产自产视频一区二区三区| 国产成人一级电影| 色偷偷久久一区二区三区| 欧美亚洲动漫另类| 日韩欧美激情一区| 国产色产综合色产在线视频| 成人免费一区二区三区视频| 一区二区三区成人| 久久国产夜色精品鲁鲁99| 国产高清成人在线| 色噜噜夜夜夜综合网| 制服丝袜在线91| 日本一区二区三区四区| 亚洲制服欧美中文字幕中文字幕| 青青草国产精品亚洲专区无| 国产老肥熟一区二区三区| 99国产欧美久久久精品| 欧美日韩国产天堂| 精品久久久久香蕉网| 最新中文字幕一区二区三区| 日韩av不卡在线观看| 高清不卡一区二区在线| 欧洲中文字幕精品| 精品国产污污免费网站入口| 国产精品精品国产色婷婷| 午夜精品久久久久久| 国产成人综合精品三级| 欧美日韩国产美女| 欧美激情一区二区三区全黄| 亚洲国产中文字幕在线视频综合| 久久国产精品99精品国产| 99久久精品99国产精品| 欧美成人伊人久久综合网| 亚洲色图在线看| 国内精品国产成人国产三级粉色| 日本精品视频一区二区三区| 欧美精品一区二| 亚洲成人午夜电影| 不卡一区在线观看| 欧美一级片在线看| 夜夜嗨av一区二区三区中文字幕 | 亚洲国产精品一区二区www在线| 国产美女久久久久| 91精品国产aⅴ一区二区| 亚洲天堂中文字幕| 国产成人日日夜夜| 日韩午夜三级在线| 一个色在线综合| 94-欧美-setu| 欧美激情一区在线观看| 日韩精品一卡二卡三卡四卡无卡| 97久久精品人人做人人爽| 久久久久久久免费视频了| 麻豆91免费看| 欧美一区二区三区视频在线| 亚洲激情网站免费观看| 成人av电影免费观看| 国产亚洲精品中文字幕| 精品一区二区三区蜜桃| 欧美日本一区二区在线观看| 一区二区三区自拍| 9i在线看片成人免费| 久久久噜噜噜久噜久久综合| 久久国产精品免费| 91精品国产一区二区三区蜜臀| 一区二区三区.www| 91丨porny丨蝌蚪视频| 亚洲欧洲国产日韩| av成人老司机| 成人欧美一区二区三区黑人麻豆 | 日本伊人色综合网| 在线不卡免费欧美| 日韩国产精品久久久久久亚洲| 欧美日韩国产一级| 婷婷中文字幕一区三区| 欧美专区在线观看一区| 亚洲一区二区三区在线| 欧美三级在线视频| 视频在线观看一区二区三区| 欧美精品欧美精品系列| 亚洲线精品一区二区三区| 欧美日韩性生活| 日韩av电影天堂| 亚洲精品在线一区二区| 国产一区二区三区日韩 | 日韩视频在线你懂得| 蜜臀av一区二区在线免费观看| 日韩欧美中文字幕公布| 极品少妇xxxx偷拍精品少妇| 26uuuu精品一区二区| 国产精品一二三| 成人欧美一区二区三区黑人麻豆| 色呦呦一区二区三区| 亚洲综合一区二区| 这里只有精品电影| 国产精品中文字幕一区二区三区| 中文字幕第一页久久| 91丝袜高跟美女视频| 午夜av一区二区| 精品人伦一区二区色婷婷| 国产精品77777| 一区二区三区波多野结衣在线观看| 欧美日韩国产高清一区二区三区| 美日韩一区二区三区| 欧美激情一二三区| 在线观看国产一区二区| 久久av老司机精品网站导航| 中文乱码免费一区二区| 欧美片网站yy| 成人网页在线观看| 日韩—二三区免费观看av| 亚洲国产精品ⅴa在线观看| 欧美色图免费看|