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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ch03.htm

?? 24小時(shí)精通VC
?? HTM
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
<P>The simple Windows program provided in Listing 3.3 might seem large, but it'sactually about half the size of a similar program written in C. Using the MFC classlibrary enables you to use a large amount of source code that has already been writtenfor you. There is a lot of strange-looking code in Listing 3.3, so don't try to understandit all right now.<H3><FONT COLOR="#000077"><B>Building the HelloWin Example</B></FONT></H3><P>To build the program, create an MFC Windows project named HelloWin. Begin by selectingFile | New from the Visual C++ main menu; select the Projects tab in the New dialogbox. Next, select Win32 Application as the project type. You must also specify aname and location for your project, just as you did for the projects in the firsttwo hours.</P><P>After the project has been created, open a new C++ source file document and enterthe contents of Listing 3.3 exactly as they are shown. Save the file as <TT>HelloWin.cpp</TT>and add it to the project. (If necessary, refer to Hour 1, &quot;Introducing VisualC++ 5,&quot; for specific instructions.)</P><P>Set the linking options for the project by selecting Project | Settings from themain menu. On the tab marked General is an item labeled Microsoft Foundation Classes.It will have the value <TT>Not Using MFC</TT>. Change the selection to <TT>Use MFCin a Shared Dll</TT>. You can do this by clicking on the down arrow beside the NotUsing MFC selection. This opens a box where you can then make the appropriate selection.</P><P>Compile the HelloWin project by selecting Build | Build HelloWin.exe from themain menu (or Press F7).</P><P>To start the HelloWin program, select Build | Start Debug | Go from the main menu(or Press F5). Figure 3.3 shows an example of HelloWin running.</P><P><A NAME="03"></A><A HREF="03.htm"><B>Figure 3.3.</B></A> <I><BR>The HelloWin program displaying its message in a window.</I><H2><FONT COLOR="#000077"><B>The Common Elements of a Windows Program</B></FONT></H2><P>Two elements are found in almost every Windows program; each of these elementscan be found in the HelloWin program that you just compiled and ran:<UL>	<LI>Windows are used for visible parts of an application<BR>	<BR>		<LI>Messages are used to control the interaction between an application and the Windows	operating system</UL><H3><FONT COLOR="#000077"><B>Windows Are Everywhere</B></FONT></H3><P>One of the fundamental concepts in Windows programming is that everything yousee is a window. Some examples of windows are<UL>	<LI>Controls such as pushbuttons, list boxes, and text edit controls<BR>	<BR>		<LI>Dialog boxes and property pages<BR>	<BR>		<LI>Toolbars and menu bars<BR>	<BR>		<LI>The Windows 95 taskbar<BR>	<BR>		<LI>The DOS command box that is used for console-mode applications</UL><P>All windows have a common set of operations that can be applied to them. Theyare all re-sized, moved, enabled, disabled, hidden, and displayed in the same way.<H3><FONT COLOR="#000077"><B>The Client and Non-Client Areas</B></FONT></H3><P>A window is divided into two main areas, as shown in Figure 3.4:<UL>	<LI>The non-client area, which contains the border, menus, and caption area for the	window<BR>	<BR>		<LI>The client area, which is the area that is left over, also known as the &quot;main&quot;	part of the window</UL><P><A NAME="04"></A><A HREF="04.htm"><B>Figure 3.4.</B></A> <I><BR>Client and non-client areas of a window.</I></P><P>The non-client area of a window is normally maintained by Windows; your applicationswill normally be concerned only with the client area.<H3><FONT COLOR="#000077"><B>Messages and Functions</B></FONT></H3><P>When Windows needs to communicate with an application, it sends it a message.A message is similar to a function call--in fact, the MFC library will route mostmessages as function calls into your application. For example, in an AppWizard application,the MFC library calls the <TT>OnDraw</TT> function whenever Windows sends a <TT>WM_PAINT</TT>message.</P><P>When your application communicates with a window, it will usually send it a message.To enable or disable a control, you must send the control a <TT>WM_ENABLE</TT> message.When using C, this process is very tedious and error prone. MFC simplifies thingsby providing functions that you can call and then handling the message sending foryou.<H2><FONT COLOR="#000077"><B>What Are Statements and Expressions?</B></FONT></H2><P>Statements and expressions are the elements defined by the C++ language that areconverted into machine code by the compiler to build your C++ programs. Seems likea textbook-type definition, doesn't it? In reality, though, it is very hard to defineexactly what they are. When talking about a building, we can say that it is madeof bricks, boards, and other things; we can define the brick or board very easily.In the case of the C++ programming language, it is much more difficult. Here we aredealing with abstract concepts. The difference between a statement and expressionis very subtle, as you will soon see. Although it appears to be confusing at first,the language will become understandable with practice. Eventually the C++ languagewill become as natural to you as your native language.</P><P>Just like the simple Hello programs, all C++ programs are made up of statementsand expressions. Expressions and statements range from the simple statements thatwere shown in the Hello programs to very complex expressions that stretch acrossseveral lines.<H3><FONT COLOR="#000077"><B>Statements</B></FONT></H3><P>All statements end with semicolons. In fact, the simplest statement is calledthe null statement, and it consists of only a single semicolon, as follows:</P><PRE><FONT COLOR="#0066FF"><TT>;</TT></FONT></PRE><P>The null statement isn't used often; it's used only in situations in which theC++ syntax requires a statement, but no real work needs to be done.</P><P>You use a statement to tell the compiler to perform some type of specific action.For example, you know from the console mode programs you created that the followingstatement will cause the characters <TT>Hello World!</TT> to be displayed on yourscreen:</P><PRE><FONT COLOR="#0066FF"><TT>cout &lt;&lt; &quot;Hello World!&quot; &lt;&lt; endl;</TT></FONT></PRE><H3><FONT COLOR="#000077"><B>Declarations</B></FONT></H3><P>A declaration is another type of statement. As discussed earlier, declarationsintroduce a variable to the compiler. The following line is an example of a simpledeclaration:</P><PRE><FONT COLOR="#0066FF"><TT>int myAge;</TT></FONT></PRE><P>This tells the compiler that <TT>myAge</TT> is an integer.<H3><FONT COLOR="#000077"><B>Assignment</B></FONT></H3><P>An assignment expression is used to assign a value to a variable, using the assignmentoperator, <TT>=</TT>, as follows:</P><PRE><FONT COLOR="#0066FF"><TT>int     myAge;</TT><TT>myAge = 135;</TT></FONT></PRE><P>Every expression has a value. The value of an assignment expression is the valueof the assignment. This means that the following statement assigns the value <TT>42</TT>to the variables <TT>yourAge</TT> and <TT>myAge</TT>:</P><PRE><FONT COLOR="#0066FF"><TT>myAge = yourAge = 42;</TT></FONT></PRE><P>The program in Listing 3.4 demonstrates how to assign a value to a variable.<H4><FONT COLOR="#000077">TYPE: Listing 3.4. A C++ program that assigns a value toa variable.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>#include &lt;iostream&gt;</TT><TT>using namespace std;</TT><TT>int main()</TT><TT>{</TT><TT>    int myAge;</TT><TT>    myAge = 42;</TT><TT>    cout &lt;&lt; &quot;Hello&quot; &lt;&lt; endl;</TT><TT>    cout &lt;&lt; &quot;My age is &quot; &lt;&lt; myAge &lt;&lt; endl;</TT><TT>    return 0;</TT><TT>}</TT></FONT></PRE><P>The assignment operator is just one example of the operators available in C++.More operators are discussed in the next section.<H3><FONT COLOR="#000077"><B>Other Common Expressions and Operators</B></FONT></H3><P>The C++ language contains operators that you can use to write addition, subtraction,multiplication, and other expressions. Some common math operators are shown in Table3.1.<H4><FONT COLOR="#000077">Table 3.1. Some common math operators used in C++.</FONT></H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><B>Operator</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Description</B></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>+</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">Addition</TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>-</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">Subtraction</TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>/</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">Division</TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>*</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">Multiplication</TD>	</TR></TABLE></P><P>All math operators group from left to right. The multiplication and division operatorshave a higher precedence than the addition and subtraction operators. This meansthat the following expressions are equivalent: a + 5 * 3 a + 15 You can use parenthesesto force an expression to be evaluated in a preferred order. Note the grouping ofthe following expression: (a + 5) * 3 This expression adds 5 to the value storedin a and then multiplies that value by 3. The math operators can also be combinedwith an assignment operator, as follows:</P><PRE><FONT COLOR="#0066FF"><TT>int myAge;</TT><TT>    myAge = 40 + 2;</TT></FONT></PRE><P>The expression <TT>40 + 2</TT> has a value of <TT>42</TT>. After that value iscalculated, the value of the expression is stored in the <TT>myAge</TT> variable.<H2><FONT COLOR="#000077"><B>Rectangles and Regions</B></FONT></H2><P>The rectangle is a fundamental component of most Windows programs. Because mostwindows and controls are rectangular, it isn't surprising that one of the most commonlyused data structures in Windows programming is used to represent a rectangle.</P><P>Rectangles are often used to represent the position or size of all types of windows:main windows as well as controls, toolbars and dialog boxes. There are two basictypes of rectangle coordinates:<UL>	<LI>Screen rectangle coordinates, which place a rectangle in relationship to the	entire screen	<LI>Client rectangle coordinates, which always have their top and left values set	to zero and provide the size of a rectangle that represents a window's client area</UL><P>Screen rectangle coordinates are often used when moving a window in relation tothe entire screen. Client rectangles are most commonly used when positioning controlsor drawing inside a control or other window.</P><P>When requesting the dimensions of a rectangle, you must pass a <TT>CRect</TT>variable to one of the Windows rectangle functions. The following two lines of codedeclare an instance of <TT>CRect</TT> as a variable and pass it to the <TT>GetClientRect</TT>function:</P><PRE><FONT COLOR="#0066FF"><TT>CRect rcClient;</TT><TT>GetClientRect(rcClient);</TT></FONT></PRE><P>The next example uses a client area rectangle to display a message to the user,just like the HelloMFC program in the first hour. The new example will draw the messagein the center of the client area; if the window is resized, the message will be redrawnin the center of the new rectangle.</P><P>Create an MFC AppWizard application named HelloRect, following the steps presentedin the first hour. Modify the <TT>OnDraw</TT> function found in the <TT>CHelloRectView</TT>class so that it looks like the function shown in Listing 3.5.<H4><FONT COLOR="#000077">TYPE: Listing 3.5. Using a rectangle to center a messagein a window.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CHelloRectView::OnDraw(CDC* pDC)</TT><TT>{</TT><TT>    CRect       rcClient;</TT><TT>    GetClientRect(rcClient);</TT><TT>    pDC-&gt;DrawText(&quot;Hello Client Rectangle!&quot;, -1, rcClient,</TT><TT>                 DT_SINGLELINE | DT_CENTER | DT_VCENTER );</TT><TT>}</TT></FONT></PRE><P>Build the HelloRect application, and run it from Developer Studio. Note that ifyou resize the window, the message is redrawn so that it remains in the center ofthe client area.<H2><FONT COLOR="#000077"><B>Summary</B></FONT></H2><P>In this hour, you have learned about some of the more advanced building blocksthat make up C++ programs: functions, structures, and classes. You also looked atsome basic information about the MFC class library and built an MFC application withoutusing ClassWizard.<H2><FONT COLOR="#000077"><B>Q&amp;A</B></FONT></H2><DL>	<DD><B>Q What is the difference between a rectangle that uses screen coordinates	and a rectangle that uses client coordinates?</B><BR>	<BR>	<B>A</B> Every window in a Windows application can be represented by a rectangle;	this rectangle will typically use either screen or client coordinates. The rectangle	that results from these coordinates is always the same, the difference is only in	the point of reference that is used to measure the rectangle.<BR>	<BR>	<B>Q Can a structure have member functions?</B><BR>	<BR>	<B>A</B> Absolutely. A class and a structure are exactly the same, except that all	members of a structure are accessible by default, while class members are private	(not accessible) by default. You will learn more about access restrictions in the	next hour.<BR>	<BR>	<B>Q Why is no function prototype required for <TT>main()</TT>?</B><BR>	<BR>	<B>A</B> The short answer: because the C++ standard says you don't need one. The	purpose of function prototypes is to introduce new functions to the compiler; because	every C++ program is required to have a main function, no function is necessary.</DL><H2><FONT COLOR="#000077"><B>Workshop</B></FONT></H2><P>The Workshop is designed to help you anticipate possible questions, review whatyou've learned, and begin thinking ahead to putting your knowledge into practice.The answers to the quiz are in Appendix B, &quot;Quiz Answers.&quot;<H3><FONT COLOR="#000077"><B>Quiz</B></FONT></H3><DL>	<DD>1. What are some examples of the different types of windows found in a Windows	application?<BR>	<BR>	2. What is a function?<BR>	<BR>	3. What are the four parts of a function definition?<BR>	<BR>	4. How are classes different from structures?<BR>	<BR>	5. What function is called when an instance of a class is created?<BR>	<BR>	6. What function is called when an instance of a class is destroyed?<BR>	<BR>	7. What is the difference between the client and non-client areas?<BR>	<BR>	8. What is the value of the expression <TT>a = 42</TT>?<BR>	<BR>	9. What symbol is used for multiplication?<BR>	<BR>	10. What symbol is used for division?</DL><H3><FONT COLOR="#000077"><B>Exercises</B></FONT></H3><DL>	<DD>1. Write a console-mode program that asks for a distance in miles and converts	the distance into feet. There are 5,280 feet in a mile.<BR>	<BR>	2. Modify the HelloWin program to display different messages in different parts of	the main window.</DL><CENTER><P><HR><A HREF="../ch02/ch02.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch04/ch04.htm"><IMGSRC="../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> <BR><BR><BR><IMG SRC="../button/corp.gif" WIDTH="284" HEIGHT="45" ALIGN="BOTTOM" ALT="Macmillan Computer Publishing USA"BORDER="0"></P><P>&#169; <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久 天天综合| 777久久久精品| 成人午夜视频免费看| 经典一区二区三区| 理论电影国产精品| 看片的网站亚洲| 久久99精品国产.久久久久久 | 亚洲制服丝袜在线| 亚洲免费在线电影| 亚洲精品中文字幕乱码三区| 亚洲免费在线视频一区 二区| 亚洲男女一区二区三区| 一区二区三区四区在线免费观看 | 黑人巨大精品欧美一区| 九色|91porny| 国产不卡视频一区二区三区| 懂色一区二区三区免费观看| 国产成人免费高清| 99久久免费国产| 欧美亚洲动漫制服丝袜| 7777精品久久久大香线蕉| 日韩一级片网站| 久久精品这里都是精品| 中文字幕一区二区三区视频| 亚洲欧洲中文日韩久久av乱码| 一区二区视频在线| 日韩精品一级中文字幕精品视频免费观看| 日本成人在线不卡视频| 国产原创一区二区三区| jlzzjlzz亚洲女人18| 欧美影视一区在线| 精品久久久网站| 亚洲欧洲无码一区二区三区| 亚洲综合一区二区精品导航| 免费成人深夜小野草| 懂色av一区二区三区免费观看| 91网址在线看| 91精品国产综合久久精品| 久久精品人人做| 亚洲一区二区精品久久av| 久久电影网站中文字幕 | 欧美一卡二卡在线| 国产欧美一区二区精品忘忧草| 自拍偷在线精品自拍偷无码专区 | 99久久综合精品| 豆国产96在线|亚洲| 欧美日韩一区在线观看| 欧美一区二区性放荡片| 国产精品丝袜在线| 亚洲一区二区三区影院| 狠狠色狠狠色综合| 99这里只有久久精品视频| 91精品久久久久久久99蜜桃| 日韩精品一区二区三区在线| 中文字幕亚洲综合久久菠萝蜜| 亚洲综合小说图片| 成人免费电影视频| 欧美中文字幕一区二区三区亚洲| 26uuu久久天堂性欧美| 亚洲色欲色欲www在线观看| 最新不卡av在线| 精品一区二区免费在线观看| 91日韩在线专区| 久久一区二区三区四区| 亚洲精品一二三| 国产精品69毛片高清亚洲| 在线观看欧美精品| 国产精品女主播av| 日韩福利电影在线观看| 在线视频你懂得一区| 久久一夜天堂av一区二区三区| 亚洲一区二区精品视频| 国产1区2区3区精品美女| 欧美一区二区二区| 一区二区三区在线观看欧美| 成人免费毛片app| 日韩欧美自拍偷拍| 天天综合天天做天天综合| 成人午夜激情在线| 国产午夜亚洲精品理论片色戒 | 国产精品欧美一级免费| 狠狠狠色丁香婷婷综合久久五月| 成人国产在线观看| 久久久欧美精品sm网站| 日韩高清欧美激情| 4hu四虎永久在线影院成人| 日韩一区在线看| 成人免费高清视频在线观看| 欧美va亚洲va香蕉在线| 日韩高清在线电影| 欧美日韩国产高清一区二区| 亚洲国产成人tv| 91网上在线视频| 亚洲精品国产第一综合99久久| 国产成人高清在线| 国产欧美精品一区| 国产精品一区二区男女羞羞无遮挡 | 26uuuu精品一区二区| 偷拍日韩校园综合在线| 欧美日韩国产影片| 一区二区国产盗摄色噜噜| 91在线一区二区三区| 国产精品麻豆欧美日韩ww| 国产成人高清视频| 久久天堂av综合合色蜜桃网| 精一区二区三区| 欧美一级日韩一级| 中文字幕av一区二区三区高| 成人午夜免费av| 久久伊人中文字幕| 成人国产一区二区三区精品| 精品久久久网站| 国产不卡在线一区| 欧美一级在线视频| 国产精选一区二区三区| 久久久一区二区三区捆绑**| 国产91丝袜在线播放九色| 久久久精品国产免费观看同学| 国产精品一区二区不卡| 久久久亚洲高清| 91在线观看视频| 亚洲精品水蜜桃| 欧美老年两性高潮| 日本视频免费一区| 欧美一级艳片视频免费观看| 久久91精品国产91久久小草| 久久久精品综合| 波多野结衣亚洲一区| 亚洲国产另类av| 6080国产精品一区二区| 国产精品一区2区| 国产精品久久久久久久久免费丝袜| 91毛片在线观看| 亚洲成a人片在线不卡一二三区 | 综合欧美一区二区三区| 欧美亚洲国产bt| 日本vs亚洲vs韩国一区三区二区| 久久久国产综合精品女国产盗摄| 国产成人免费网站| 亚洲第一成年网| 日韩欧美另类在线| 99视频一区二区三区| 亚洲va韩国va欧美va| 精品国产凹凸成av人导航| 黑人精品欧美一区二区蜜桃 | 蜜桃av一区二区| 久久精品一区二区三区av| 91麻豆产精品久久久久久| 亚洲444eee在线观看| 久久综合国产精品| a级精品国产片在线观看| 日本午夜精品视频在线观看 | 亚洲精品乱码久久久久久日本蜜臀| 欧美日本在线视频| 国产成人精品亚洲午夜麻豆| 亚洲一区二区3| 久久久久久免费网| 欧美日韩国产综合视频在线观看| 激情图区综合网| 亚洲一区二区三区视频在线播放 | 在线不卡中文字幕| 亚洲3atv精品一区二区三区| 日韩三级电影网址| 色综合婷婷久久| 精品一区中文字幕| 一区二区三区日韩欧美精品| 欧美大白屁股肥臀xxxxxx| 不卡的电视剧免费网站有什么| 午夜私人影院久久久久| 欧美精品一区二区三区一线天视频| 不卡免费追剧大全电视剧网站| 蜜桃视频免费观看一区| 玉足女爽爽91| 中文久久乱码一区二区| 欧美高清精品3d| 色哟哟一区二区在线观看 | 成人动漫一区二区在线| 日韩av在线发布| 日韩欧美www| 欧美日韩黄色影视| 福利一区二区在线观看| 久久精品国产久精国产爱| 最新高清无码专区| 国产精品麻豆一区二区| 欧美精品丝袜久久久中文字幕| 色婷婷av一区二区三区之一色屋| 美女性感视频久久| 日韩精品福利网| 国产精品九色蝌蚪自拍| 91精品在线观看入口| 91啦中文在线观看| 99视频在线精品| 成人免费视频app| 国产精品18久久久| 国产精品综合av一区二区国产馆| 亚洲成人久久影院| 日韩成人一区二区三区在线观看| 亚洲女同一区二区| 亚洲女子a中天字幕| 国产精品成人免费在线|