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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch02.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<P>A member variable in the new dialog box class can be connected to a control's
value or to the control. This sample demonstrates both kinds of connection. For IDC_CHECK1,
fill in the variable name as <B>m_check</B>, and make sure that the Category drop-down
box has Value selected. If you open the Variable Type drop-down box, you will see
that the only possible choice is BOOL. Because a check box can be either selected
or not selected, it can be connected only to a BOOL variable, which holds the value
TRUE or FALSE. Click OK to complete the connection.</P>
<P><A HREF="javascript:popUp('02uvc08.gif')"><B>FIG. 2.8</B></A><B> </B><I>You choose
the name for the member variable associated with each control.</I></P>

<P>Here are the data types that go with each control type:</P>
<P>

<UL>
	<LI><I>Edit box.</I> Usually a string but also can be other data types, including
	int, float, and long
	<P>
	<LI><I>Check box.</I> int
	<P>
	<LI><I>Radio button.</I> int
	<P>
	<LI><I>List box.</I> String
	<P>
	<LI><I>Combo box.</I> String
	<P>
	<LI><I>Scrollbar.</I> int
</UL>

<P>Connect IDC_EDIT1 in the same way, to a member variable called m_edit of type
CString as a Value. Connect IDC_LIST1 as a Control to a member variable called m_listbox
of type CListBox. Connect IDC_RADIO_1, the first of the group of radio buttons, as
a Value to an int member variable called m_radio.</P>
<P>After you click OK to add the variable, ClassWizard offers, for some kinds of
variables, the capability to validate the user's data entry. For example, when an
edit control is selected, a field under the variables list allows you to set the
maximum number of characters the user can enter into the edit box (see Figure 2.9).
Set it to 10 for m_edit. If the edit box is connected to a number (int or float),
this area of ClassWizard is used to specify minimum or maximum values for the number
entered by the user. The error messages asking the user to try again are generated
automatically by MFC with no work on your part.</P>
<P><A HREF="javascript:popUp('02uvc09.gif')"><B>FIG. 2.9</B></A><B> </B><I>Enter
a number in the Maximum Characters field to limit the length of a user's entry.</I></P>

<P><I></I>
<H2><A NAME="Heading6"></A>Using the Dialog Box Class</H2>
<P>Now that you have your dialog box resource built and your dialog box class written,
you can create objects of that class within your program and display the associated
dialog box element. The first step is to decide what will cause the dialog box to
display. Typically, it is a menu choice, but because adding menu items and connecting
them to code are not covered until Chapter 8, &quot;Building a Complete Application:
ShowString,&quot; you can simply have the dialog box display when the application
starts running. To display the dialog box, you call the DoModal() member function
of the dialog box class.</P>


<BLOCKQUOTE>
	<P>
<HR>
<B>Modeless Dialog Boxes</B><BR>
	</P>

	<P>Most of the dialog boxes you will code will be modal dialog boxes. A modal dialog
	box is on top of all the other windows in the application: The user must deal with
	the dialog box and then close it before going on to other work. An example of this
	is the dialog box that comes up when the user chooses File, Open in any Windows application.<BR>
	</P>

	<P>A modeless dialog box enables the user to click the underlying application and
	do some other work and then return to the dialog box. An example of this is the dialog
	box that comes up when the user chooses Edit, Find in many Windows applications.<BR>
	</P>

	<P>Displaying a modeless dialog box is more difficult than displaying a modal one.
	The dialog box object, the instance of the dialog box class, must be managed carefully.
	Typically, it is created with new and destroyed with delete when the user closes
	the dialog box with Cancel or OK. You have to override a number of functions within
	the dialog box class. In short, you should be familiar and comfortable with modal
	dialog boxes before you attempt to use a modeless dialog box. When you're ready,
	look at the Visual C++ sample called MODELESS that comes with Developer Studio. The
	fastest way to open this sample is by searching for MODELESS in InfoViewer. Searching
	in InfoViewer is covered in Appendix C, &quot;The Visual Studio User Interface, Menus,
	and Toolbars.&quot;
<HR>


</BLOCKQUOTE>

<H3><A NAME="Heading7"></A>Arranging to Display the Dialog Box</H3>
<P>Select the ClassView in the project workspace pane, expand the SDI Classes item,
and then expand CSdiApp. Double-click the InitInstance() member function. This function
is called whenever the application starts. Scroll to the top of the file, and after
the other #include statements, add this directive:</P>
<P>
<PRE>#include &quot;sdidialog.h&quot;
</PRE>
<P>This ensures that the compiler knows what a CSdiDialog class is when it compiles
this file.</P>
<P>Double-click InitInstance() in the ClassView again to bring the cursor to the
beginning of the function. Scroll down to the end of the function, and just before
the return at the end of the function, add the lines in Listing 2.1.</P>
<P>
<H4>Listing 2.1&#160;&#160;SDI.CPP--Lines to Add at the End of CSdiApp::InitInstance()</H4>
<PRE>     CSdiDialog dlg;
     dlg.m_check = TRUE;
     dlg.m_edit = &quot;hi there&quot;;
     CString msg;
     if (dlg.DoModal() == IDOK)
     {
          msg = &quot;You clicked OK. &quot;;
     }
     else
     {
          msg = &quot;You cancelled. &quot;;
     }
     msg += &quot;Edit box is: &quot;;
     msg += dlg.m_edit;
</PRE>
<PRE>     AfxMessageBox (msg);
</PRE>


<BLOCKQUOTE>
	<P>
<HR>
<B>Entering Code</B><BR>
	</P>

	<P>As you enter code into this file, you may want to take advantage of a feature
	that makes its debut in this version of Visual C++: Autocompletion. Covered in more
	detail in Appendix C, Autocompletion saves you the trouble of remembering all the
	member variables and functions of a class. If you type dlg. and then pause, a window
	will appear, listing all the member variables and functions of the class CSdiDialog,
	including those it inherited from its base class. If you start to type the variable
	you want--for example, typing m_--the list will scroll to variables starting with
	m_. Use the arrow keys to select the one you want, and press Space to select it and
	continue typing code. You are sure to find this feature a great time saver. If the
	occasional pause as you type bothers you, Autocompletion can be turned off by choosing
	Tools, Options and clicking the Editor tab. Deselect the parts of Autocompletion
	you no longer want.
<HR>


</BLOCKQUOTE>

<P>This code first creates an instance of the dialog box class. It sets the check
box and edit box to simple default values. (The list box and radio buttons are a
little more complex and are added later in this chapter, in &quot;Using a List Box
Control&quot; and &quot;Using Radio Buttons.&quot;) The dialog box displays onscreen
by calling its DoModal() function, which returns a number represented by IDOK if
the user clicks OK and IDCANCEL if the user clicks Cancel. The code then builds a
message and displays it with the AfxMessageBox function.</P>


<BLOCKQUOTE>
	<P>
<HR>
<strong>NOTE:</strong> The CString class has a number of useful member functions and operator
	overloads. As you see here, the += operator tacks characters onto the end of a string.
	For more about the CString class, consult Appendix F, &quot;Useful Classes.&quot;
<HR>


</BLOCKQUOTE>

<P>Build the project by choosing Build, Build or by clicking the Build button on
the Build toolbar. Run the application by choosing Build, Execute or by clicking
the Execute Program button on the Build toolbar. You will see that the dialog box
displays with the default values you just coded, as shown in Figure 2.10. Change
them, and click OK. You should get a message box telling you what you did, such as
the one in Figure 2.11. Now the program sits there, ready to go, but because there
is no more for it to do, you can close it by choosing File, Exit or by clicking the
- in the top-right corner.</P>

<P><A HREF="javascript:popUp('02uvc10.gif')"><B>FIG. 2.10</B></A><B> </B><I>Your
application displays the dialog box when it first runs.</I></P>

<P><A HREF="javascript:popUp('02uvc11.gif')"><B>FIG. 2.11</B></A><B> </B><I>After
you click OK, the application echoes the contents of the edit control.</I></P>

<P>Run it again, change the contents of the edit box, and this time click Cancel
on the dialog box. Notice in Figure 2.12 that the edit box is reported as still hi
there. This is because MFC does not copy the control values into the member variables
when the user clicks Cancel. Again, just close the application after the dialog box
is gone.</P>

<P><A HREF="javascript:popUp('02uvc12.gif')"><B>FIG. 2.12</B></A><B> </B><I>When
you click Cancel, the application ignores any changes you made.</I></P>

<P>Be sure to try entering more characters into the edit box than the 10 you specified
with ClassWizard. You will find you cannot type more than 10 characters--the system
just beeps at you. If you try to paste in something longer than 10 characters, only
the first 10 characters appear in the edit box.</P>

<P>
<H3><A NAME="Heading8"></A>Behind the Scenes</H3>
<P>You may be wondering what's going on here. When you click OK on the dialog box,
MFC arranges for a function called OnOK() to be called. This function is inherited
from CDialog, the base class for CSdiDialog. Among other things, it calls a function
called DoDataExchange(), which ClassWizard wrote for you. Here's how it looks at
the moment:</P>
<P>
<PRE>void CSdiDialog::DoDataExchange(CDataExchange* pDX)
{
     CDialog::DoDataExchange(pDX);
     //{{AFX_DATA_MAP(CSdiDialog)
     DDX_Control(pDX, IDC_LIST1, m_listbox);
     DDX_Check(pDX, IDC_CHECK1, m_check);
     DDX_Text(pDX, IDC_EDIT1, m_edit);
     DDV_MaxChars(pDX, m_edit, 10);
     DDX_Radio(pDX, IDC_RADIO1, m_radio);
     //}}AFX_DATA_MAP
}
</PRE>
<P>The functions with names that start with DDX all perform data exchange: Their
second parameter is the resource ID of a control, and the third parameter is a member
variable in this class. This is the way that ClassWizard connected the controls to
member variables--by generating this code for you. Remember that ClassWizard also
added these variables to the dialog box class by generating code in the header file
that declares them.</P>
<P>There are 34 functions whose names begin with DDX: one for each type of data that
might be exchanged between a dialog box and a class. Each has the type in its name.
For example, DDX_Check is used to connect a check box to a BOOL member variable.
DDX_Text is used to connect an edit box to a CString member variable. ClassWizard
chooses the right function name when you make the connection.</P>


<BLOCKQUOTE>
	<P>
<HR>
<strong>NOTE:</strong> Some DDX functions are not generated by ClassWizard. For example,
	when you connect a list box as a Value, your only choice for type is CString. Choosing
	that causes ClassWizard to generate a call to DDX_LBString(), which connects the
	selected string in the list box to a CString member variable. There are cases when
	the integer index into the list box might be more useful, and there is a DDX_LBIndex()
	function that performs that exchange. You can add code to DoDataExchange(), outside
	the special ClassWizard comments, to make this connection. If you do so, remember
	to add the member variable to the class yourself. You can find the full list of DDX
	functions in the online documentation.&#160;n
<HR>


</BLOCKQUOTE>

<P>Functions with names that start with DDV perform data validation. ClassWizard
adds a call to DDV_MaxChars right after the call to DDX_Text that filled m_edit with
the contents of IDC_EDIT1. The second parameter of the call is the member variable
name, and the third is the limit: how many characters can be in the string. If a
user ever managed to get extra characters into a length-validated string, the DDV_MaxChars()
function contains code that puts up a warning box and gets the user to try again.
You can just set the limit and count on its being enforced.</P>
<P>
<H3><A NAME="Heading9"></A>Using a List Box Control</H3>
<P>Dealing with the list box is more difficult because only while the dialog box
is onscreen is the list box control a real window. You cannot call a member function
of the list box control class unless the dialog box is onscreen. (This is true of
any control that you access as a control rather than as a value.) This means that
you must initialize the list box (fill it with strings) and use it (determine which
string is selected) in functions that are called by MFC while the dialog box is onscreen.</P>
<P>When it is time to initialize the dialog box, just before it displays onscreen,

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
激情六月婷婷综合| 国产精品亲子乱子伦xxxx裸| 亚洲免费视频中文字幕| 国产盗摄女厕一区二区三区 | 国产原创一区二区| 精品999在线播放| 成人午夜精品在线| 一区二区视频在线看| 欧美日韩国产一级| 狠狠网亚洲精品| 国产精品久久免费看| 91久久精品国产91性色tv| 亚洲成人动漫在线免费观看| 精品国产精品一区二区夜夜嗨| 成人丝袜18视频在线观看| 亚洲精品中文在线观看| 欧美二区三区的天堂| 国产成人啪免费观看软件 | 亚洲国产人成综合网站| 日韩一区二区麻豆国产| 国产91对白在线观看九色| 亚洲一区二区不卡免费| 精品久久久久一区二区国产| 91尤物视频在线观看| 日韩精品一区第一页| 国产亚洲欧美日韩俺去了| 色就色 综合激情| 精品一区二区三区香蕉蜜桃| 日本一区二区成人在线| 欧美日韩国产一级| 成人黄页在线观看| 免费久久99精品国产| 亚洲女与黑人做爰| 亚洲一卡二卡三卡四卡 | 欧美日韩的一区二区| 国产成人综合自拍| 日本美女一区二区三区视频| 国产精品嫩草影院com| 日韩欧美国产成人一区二区| 色吧成人激情小说| 国产69精品久久99不卡| 裸体一区二区三区| 亚洲最新视频在线观看| 久久日一线二线三线suv| 日本电影亚洲天堂一区| 懂色av中文字幕一区二区三区| 日本欧美大码aⅴ在线播放| 一区二区三区四区亚洲| 国产欧美精品在线观看| 精品成人一区二区三区四区| 欧美日韩高清一区二区不卡| 99久久综合国产精品| 国产在线精品视频| 日韩精品一级二级| 亚洲一区二三区| 国产精品乱人伦| 久久精品视频网| 日韩久久久精品| 欧美一区二区三区影视| 在线观看视频欧美| 色哟哟一区二区三区| 成人天堂资源www在线| 国产一区中文字幕| 国产麻豆视频一区| 国产一区二区三区蝌蚪| 国产在线一区观看| 国产在线精品不卡| 国产一区二区三区免费播放| 国产乱人伦偷精品视频不卡 | 日韩欧美123| 欧美一区二区在线免费播放| 欧美日韩亚洲不卡| 91福利在线导航| 欧美三级在线看| 欧美日韩在线综合| 欧美卡1卡2卡| 欧美精品在欧美一区二区少妇| 欧美日韩视频在线一区二区| 欧美日韩免费观看一区三区| 欧美精品日韩综合在线| 69堂成人精品免费视频| 91精品国产一区二区三区香蕉| 欧美一区二区三区视频免费| 精品国产伦一区二区三区观看体验| 欧美一级片在线| 精品国产免费久久| 亚洲国产电影在线观看| 亚洲桃色在线一区| 亚洲.国产.中文慕字在线| 奇米精品一区二区三区在线观看 | 国产亚洲精品bt天堂精选| 精品少妇一区二区三区在线视频 | 欧美激情在线免费观看| 日本一二三不卡| 亚洲美女屁股眼交3| 婷婷国产v国产偷v亚洲高清| 美女任你摸久久| 国产成人自拍高清视频在线免费播放| 成人国产视频在线观看| 欧洲精品在线观看| 欧美成va人片在线观看| 久久久久国产精品人| 国产精品系列在线| 亚洲一卡二卡三卡四卡| 久草中文综合在线| 波多野结衣在线aⅴ中文字幕不卡| 日本高清无吗v一区| 日韩精品资源二区在线| 亚洲同性同志一二三专区| 婷婷久久综合九色国产成人| 国产成人h网站| 欧美性做爰猛烈叫床潮| 久久这里都是精品| 亚洲欧美日韩精品久久久久| 蜜桃一区二区三区四区| 9l国产精品久久久久麻豆| 欧美一区二区久久久| 一区免费观看视频| 麻豆精品国产91久久久久久| 91色.com| 日本一区二区三级电影在线观看 | 日韩精品国产欧美| 丁香六月综合激情| 91.xcao| 国产精品久久夜| 久久精品久久精品| 欧美综合视频在线观看| 中文字幕精品一区二区精品绿巨人 | 激情av综合网| 欧美亚洲禁片免费| 国产精品久久看| 国产在线播放一区三区四| 欧美日韩一区高清| 国产精品欧美一级免费| 精品一区二区三区影院在线午夜| 欧美在线影院一区二区| 国产精品国产三级国产aⅴ中文| 美日韩黄色大片| 欧美日韩aaa| 亚洲男人的天堂网| 成人黄色免费短视频| 久久午夜免费电影| 人人爽香蕉精品| 欧美日韩精品欧美日韩精品一综合| 中文字幕一区二区三区不卡在线 | 亚洲欧洲av另类| 国产成人av一区二区| 日韩精品一区二区在线观看| 日韩国产一二三区| 欧美性色黄大片| 亚洲自拍欧美精品| 日本道在线观看一区二区| 中文字幕一区二区三区av| 粉嫩在线一区二区三区视频| 久久久精品影视| 国产伦精品一区二区三区视频青涩| 欧美成人午夜电影| 欧美综合一区二区三区| 亚洲乱码精品一二三四区日韩在线| 成人动漫视频在线| 欧美国产国产综合| 99这里都是精品| 亚洲色欲色欲www| 91老师片黄在线观看| 亚洲精品国产第一综合99久久| 色综合天天综合网国产成人综合天| 中文字幕第一区第二区| 成人激情动漫在线观看| 亚洲欧美自拍偷拍色图| 色综合久久66| 午夜天堂影视香蕉久久| 欧美精品一二三| 激情五月婷婷综合网| 精品国产一二三| 国产成人av电影在线观看| 中文欧美字幕免费| 色悠久久久久综合欧美99| 亚洲一区二区三区四区五区中文| 欧美色图片你懂的| 青青草原综合久久大伊人精品优势| 91精品免费在线| 国产中文字幕精品| 国产精品超碰97尤物18| 欧洲一区在线电影| 日韩精品乱码免费| 国产亚洲综合色| 色综合中文字幕国产| 亚洲视频一二三| 欧美日韩成人综合天天影院| 青青草国产精品亚洲专区无| 国产欧美一区二区精品久导航| 91在线免费看| 青娱乐精品视频| 国产精品你懂的在线欣赏| 欧美四级电影在线观看| 国产美女在线精品| 一区二区三区日本| 久久香蕉国产线看观看99| 99国产精品久| 蜜桃久久精品一区二区|