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

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

?? ch02.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁 / 共 3 頁
字號(hào):
a CDialog function named OnInitDialog() is called. Although the full explanation
of what you are about to do will have to wait until Chapter 3, "Messages and
Commands,&quot; follow the upcoming steps to add the function to your class.</P>
<P>In ClassView, right-click CSdiDialog and choose Add Windows Message Handler. The
New Windows Message and Event Handlers dialog box shown in Figure 2.13 appears. Choose
WM_INITDIALOG from the list and click Add Handler. The message name disappears from
the left list and appears in the right list. Click it and then click Edit Existing
to see the code.</P>
<P><A HREF="javascript:popUp('02uvc13.gif')"><B>FIG. 2.13</B></A><B> </B><I>The New
Windows Message and Event Handlers dialog box helps you override OnInitDialog().</I></P>

<P>Remove the TODO comment and add calls to the member functions of the list box
so that the function is as shown in Listing 2.2.</P>
<P>
<H4>Listing 2.2&#160;&#160;SDIDIALOG.CPP--CSdiDialog::OnInitDialog()</H4>
<PRE>BOOL CSdiDialog::OnInitDialog()
{
     CDialog::OnInitDialog();
    
     m_listbox.AddString(&quot;First String&quot;);
     m_listbox.AddString(&quot;Second String&quot;);
     m_listbox.AddString(&quot;Yet Another String&quot;);
     m_listbox.AddString(&quot;String Number Four&quot;);
     m_listbox.SetCurSel(2);
    
     return TRUE;  // return TRUE unless you set the focus to a control
                   // EXCEPTION: OCX Property Pages should return FALSE
</PRE>
<PRE>}
</PRE>
<P>This function starts by calling the base class version of OnInitDialog() to do
whatever behind-the-scenes work MFC does when dialog boxes are initialized. Then
it calls the list box member function AddString() which, as you can probably guess,
adds a string to the list box. The strings will be displayed to the user in the order
that they were added with AddString(). The final call is to SetCurSel(), which sets
the current selection. As you see when you run this program, the index you pass to
SetCurSel() is zero based, which means that item 2 is the third in the list, counting
0, 1, 2.</P>


<BLOCKQUOTE>
	<P>
<HR>
<strong>NOTE:</strong> Usually, the strings of a list box are not hardcoded like this. To
	set them from elsewhere in your program, you have to add a CStringArray member variable
	to the dialog box class and a function to add strings to that array. The OnInitDialog()
	would use the array to fill the list box. Alternatively, you can use another one
	of MFC's collection classes or even fill the list box from a database. For more about
	CStringArray and other MFC collection classes, consult Appendix F. Database programming
	is covered in Chapter 22, &quot;Database Access.&quot;&#160;
<HR>


</BLOCKQUOTE>

<P>In order to have the message box display some indication of what was selected
in the list box, you have to add another member variable to the dialog box class.
This member variable will be set as the dialog box closes and can be accessed after
it is closed. In ClassView, right-click CSdiDialog and choose Add Member Variable.
Fill in the dialog box, as shown in Figure 2.14, and then click OK. This adds the
declaration of the CString called m_selected to the header file for you. (If the
list box allowed multiple selections, you would have to use a CStringArray to hold
the list of selected items.) Strictly speaking, the variable should be private, and
you should either add a public accessor function or make CSdiApp::InitInstance()
a friend function to CSdiDialog in order to be truly object oriented. Here you take
an excusable shortcut. The general rule still holds: Member variables should be private.</P>
<P><A HREF="javascript:popUp('02uvc14.gif')"><B>FIG. 2.14</B></A><B> </B><I>Add a
CString to your class to hold the string that was selected in the list box.</I></P>

<P><I></I>


<BLOCKQUOTE>
	<P>
<HR>
<strong>TIP:</strong> Object-oriented concepts (such as accessor functions), friend functions,
	and the reasoning behind private member variables are discussed in Appendix A, &quot;C++
	Review and Object-Oriented Concepts.&quot;
<HR>


</BLOCKQUOTE>

<P>This new member variable is used to hold the string that the user selected. It
is set when the user clicks OK or Cancel. To add a function that is called when the
user clicks OK, follow these steps:</P>
<P>

<DL>
	<DT></DT>
	<DD><B>1. </B>Right-click CSdiDialog in the ClassView, and choose Add Windows Message
	Handler.
	<P>
	<DT></DT>
	<DD><B>2. </B>In the New Windows Message and Event Handlers dialog box, shown in
	Figure 2.15, highlight ID_OK in the list box at the lower right, labeled Class or
	Object to Handle.
	<P>
</DL>

<P><A HREF="javascript:popUp('02uvc15.gif')"><B>FIG. 2.15</B></A><B> </B><I>Add a
function to handle the user's clicking OK on your dialog box.</I></P>

<P><I></I>

<DL>
	<DD><B>3. </B>In the far right list box, select BN_CLICKED. You are adding a function
	to handle the user's clicking the OK button once.
	<P>
	<DT></DT>
	<DD><B>4. </B>Click the Add Handler button. The Add Member Function dialog box shown
	in Figure 2.16 appears.
	<P>
</DL>

<P><A HREF="javascript:popUp('02uvc16.gif')"><B>FIG. 2.16</B></A><B> </B><I>ClassWizard
suggests a very good name for this event handler: Do not change it.</I></P>

<P><I></I>

<DL>
	<DT><I></I></DT>
	<DD><B>5. </B>Accept the suggested name, OnOK(), by clicking OK.
	<P>
	<DT></DT>
	<DD><B>6. </B>Click the Edit Existing button to edit the code, and add lines as shown
	in Listing 2.3.
	<P>
</DL>

<H4>Listing 2.3&#160;&#160;SDIDIALOG.CPP--CSdiDialog::OnOK()</H4>
<PRE>void CSdiDialog::OnOK()
{
     int index = m_listbox.GetCurSel();
     if (index != LB_ERR)
     {
          m_listbox.GetText(index, m_selected);
     }
     else
     {
          m_selected = &quot;&quot;;
     }
     CDialog::OnOK();
</PRE>
<PRE>}
</PRE>
<P>This code calls the list box member function GetCurSel(), which returns a constant
represented by LB_ERR if there is no selection or if more than one string has been
selected. Otherwise, it returns the zero-based index of the selected string. The
GetText() member function fills m_selected with the string at position index. After
filling this member variable, this function calls the base class OnOK() function
to do the other processing required.</P>
<P>In a moment you will add lines to CSdiApp::InitInstance() to mention the selected
string in the message box. Those lines will execute whether the user clicks OK or
Cancel, so you need to add a function to handle the user's clicking Cancel. Simply
follow the numbered steps for adding OnOK, except that you choose ID_CANCEL from
the top-right box and agree to call the function OnCancel. The code, as shown in
Listing 2.4, resets m_selected because the user canceled the dialog box.</P>
<P>
<H4>Listing 2.4&#160;&#160;SDIDIALOG.CPP--CSdiDialog::OnCancel()</H4>
<PRE>void CSdiDialog::OnCancel()
{
     m_selected = &quot;&quot;;
     CDialog::OnCancel();
</PRE>
<PRE>}
</PRE>
<P>Add these lines to CSdiApp::InitInstance() just before the call to AfxMessageBox():</P>
<P>
<PRE>     msg += &quot;. List Selection: &quot;;
     msg += dlg.m_selected;
</PRE>
<P>Build the application, run it, and test it. Does it work as you expect? Does it
resemble Figure 2.17?</P>
<P><A HREF="javascript:popUp('02uvc17.gif')"><B>FIG. 2.17</B></A><B> </B><I>Your
application now displays strings in the list box.</I></P>

<P><I></I>
<H3><A NAME="Heading10"></A>Using Radio Buttons</H3>
<P>You may have already noticed that when the dialog box first appears onscreen,
none of the radio buttons are selected. You can arrange for one of them to be selected
by default: Simply add two lines to CSdiDialog::OnInitDialog(). These lines set the
second radio button and save the change to the dialog box:</P>
<P>
<PRE>m_radio = 1;
UpdateData(FALSE);
</PRE>
<P>You may recall that m_radio is the member variable to which the group of radio
buttons is connected. It is a zero-based index into the group of buttons, indicating
which one is selected. Button 1 is the second button. The call to UpdateData() refreshes
the dialog box controls with the member variable values. The parameter indicates
the direction of transfer: UpdateData(TRUE) would refresh the member variables with
the control values, wiping out the setting of m_radio you just made.</P>
<P>Unlike list boxes, a group of radio buttons can be accessed after the dialog box
is no longer onscreen, so you won't need to add code to OnOK() or OnCancel(). However,
you have a problem: how to convert the integer selection into a string to tack on
the end of msg. There are lots of approaches, including the Format() function of
CString, but in this case, because there are not many possible selections, a switch
statement is readable and quick. At the end of CSdiApp::InitInstance(), add the lines
in Listing 2.5 just before the call to AfxMessageBox().</P>
<P>
<H4>Listing 2.5&#160;&#160;SDIDIALOG.CPP--Lines to Add to CSdiApp::InitInstance()</H4>
<PRE>     msg += &quot;\r\n&quot;;
     msg += &quot;Radio Selection: &quot;;
     switch (dlg.m_radio)
     {
     case 0:
          msg += &quot;0&quot;;
          break;
     case 1:
          msg += &quot;1&quot;;
          break;
     case 2:
          msg += &quot;2&quot;;
          break;
     default:
          msg += &quot;none&quot;;
          break;
</PRE>
<PRE>     }
</PRE>
<P>The first new line adds two special characters to the message. <I>Return</I>,
represented by \r, and <I>new line</I>, represented by \n, combine to form the Windows
end-of-line marker. This adds a line break after the part of the message you have
built so far. The rest of msg will appear on the second line of the message box.
The switch statement is an ordinary piece of C++ code, which was also present in
C. It executes one of the case statements, depending on the value of dlg.m_radio.</P>
<P>Once again, build and test the application. Any surprises? It should resemble
Figure 2.18. You are going to be building and using dialog boxes throughout this
book, so take the time to understand how this application works and what it does.
You may want to step through it with the debugger and watch it in action. You can
read all about debugging in Chapter 24, &quot;Improving Your Application's Performance,&quot;
and in Appendix D, &quot;Debugging.&quot;</P>

<P><A HREF="javascript:popUp('02uvc18.gif')"><B>FIG. 2.18</B></A><B> </B><I>Your
application now selects Button Two by default.</I></P>
<H1></H1>
<CENTER>
<P>
<HR>
<A HREF="../ch01/ch01.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch03/ch03.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> <BR>
<BR>
</P>

<P>&#169; <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. All
rights reserved.
</CENTER>


</BODY>

</HTML>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久| 欧美丝袜自拍制服另类| 久久av资源站| 久久av资源站| 国产精品1区2区| 国产精品一色哟哟哟| 丁香网亚洲国际| 97久久精品人人澡人人爽| 成人免费观看av| 在线观看亚洲一区| 欧洲精品中文字幕| 91精品欧美福利在线观看| 日韩美女一区二区三区四区| 欧美成人福利视频| 国产精品乱人伦| 亚洲mv大片欧洲mv大片精品| 亚洲一区二区精品视频| 青青草国产精品亚洲专区无| 黑人巨大精品欧美一区| 成人晚上爱看视频| 91丝袜呻吟高潮美腿白嫩在线观看| 色欲综合视频天天天| 欧美揉bbbbb揉bbbbb| 精品区一区二区| 国产精品久久久久三级| 日本不卡一区二区| 国产一区二区三区在线观看精品 | 在线成人av影院| 欧美大片在线观看一区二区| 国产视频一区二区三区在线观看| 午夜精品免费在线| 99综合影院在线| 亚洲高清在线视频| 亚洲视频电影在线| 免费观看在线综合| 成人av动漫网站| 5566中文字幕一区二区电影| 国产欧美精品一区二区色综合朱莉| 一区二区高清免费观看影视大全| 免费在线欧美视频| 成人免费视频一区| 日韩精品中文字幕在线一区| 亚洲免费在线播放| 精品无人码麻豆乱码1区2区| 一本色道久久综合狠狠躁的推荐| 日韩免费高清av| 亚洲地区一二三色| 国产成人av网站| 欧美不卡123| 丝袜美腿亚洲一区| 色婷婷亚洲综合| 国产精品无人区| 精品亚洲国内自在自线福利| 欧美日韩中文一区| 亚洲精品久久7777| 成人免费观看视频| 国产欧美日韩三级| 国产精品综合视频| 日韩一级精品视频在线观看| 亚洲免费伊人电影| 成人久久久精品乱码一区二区三区| 日韩免费在线观看| 美国十次了思思久久精品导航| 色综合天天做天天爱| 国产欧美日韩三区| 成人美女视频在线看| 久久日一线二线三线suv| 秋霞成人午夜伦在线观看| 欧美最新大片在线看| 亚洲女厕所小便bbb| 91丨porny丨首页| 中文字幕日韩一区二区| 91色婷婷久久久久合中文| 国产精品久久久久久亚洲伦| 成人免费高清在线观看| 国产精品伦理在线| 色综合久久综合网欧美综合网| 国产精品久久三区| 一本到不卡免费一区二区| 一区二区三区中文在线观看| 91在线视频18| 亚洲va韩国va欧美va精品| 欧美精品在欧美一区二区少妇| 亚洲国产cao| 欧美一级欧美三级| 国精产品一区一区三区mba桃花| 亚洲精品在线一区二区| 成人毛片老司机大片| 亚洲精品乱码久久久久久黑人| 色国产综合视频| 日韩av午夜在线观看| 精品国产91乱码一区二区三区| 久久国产麻豆精品| 中文字幕国产精品一区二区| 91在线播放网址| 亚洲va欧美va人人爽午夜| 91精品国产欧美一区二区18| 国产一区二区三区在线看麻豆| 久久久亚洲午夜电影| av在线播放成人| 香蕉久久一区二区不卡无毒影院| 欧美一区二区女人| 国产mv日韩mv欧美| 亚洲午夜成aⅴ人片| 精品久久久久久久一区二区蜜臀| 成人免费观看视频| 亚洲成a人v欧美综合天堂下载| 精品国产123| 色94色欧美sute亚洲线路二| 日本亚洲视频在线| 一区在线观看视频| 欧美成人女星排行榜| 成人高清免费在线播放| 天天影视色香欲综合网老头| 国产欧美一区二区精品忘忧草 | 全部av―极品视觉盛宴亚洲| 国产女同性恋一区二区| 欧美四级电影网| 国产成人夜色高潮福利影视| 五月天一区二区| 亚洲色图.com| 欧美哺乳videos| 欧美电影在线免费观看| 99久久综合色| 国产老女人精品毛片久久| 婷婷丁香激情综合| 亚洲日本免费电影| 国产农村妇女毛片精品久久麻豆 | 欧美国产1区2区| 欧美一区二区视频免费观看| 91丨九色丨蝌蚪丨老版| 国产高清在线精品| 久久成人精品无人区| 亚洲高清免费视频| 亚洲综合视频在线观看| 综合电影一区二区三区 | 91免费视频观看| 国产精品一区2区| 日本三级亚洲精品| 午夜精品成人在线| 亚洲综合av网| 亚洲天堂网中文字| 亚洲精品视频免费观看| 亚洲色图都市小说| 综合自拍亚洲综合图不卡区| 久久久精品国产免费观看同学| 欧美va亚洲va在线观看蝴蝶网| 欧美日韩一区二区三区免费看| 色999日韩国产欧美一区二区| 波多野结衣在线一区| 国产成人av影院| www.亚洲激情.com| 色综合久久中文字幕综合网| 99国产精品一区| 91蜜桃在线观看| 欧美亚洲动漫另类| 欧美日韩激情一区二区| 欧美日韩久久不卡| 精品乱人伦一区二区三区| 欧美成人精品1314www| 久久综合五月天婷婷伊人| 久久精品视频在线免费观看| 久久免费的精品国产v∧| 国产免费成人在线视频| 国产精品乱码久久久久久| 国产精品久久久久影院| 亚洲精品国产成人久久av盗摄 | 久久久久亚洲蜜桃| 国产精品福利影院| 亚洲国产一区二区三区青草影视| 日韩电影一区二区三区四区| 国产真实乱子伦精品视频| 国产精品小仙女| 欧美亚洲日本国产| 欧美一区二区三区免费视频| 精品国产免费久久| 国产精品美女一区二区在线观看| 亚洲免费av网站| 久久99国产精品免费网站| 成人福利视频在线看| 欧美天天综合网| 精品国产乱码久久久久久图片| 国产精品久久久久久久蜜臀| 亚洲成a人片综合在线| 国产一区二区三区四区在线观看| 91老师片黄在线观看| 日韩欧美一区中文| 亚洲同性gay激情无套| 久久国产精品99精品国产| 99久久免费视频.com| 欧美一区二区三区在线电影| 国产三级精品三级| 日本大胆欧美人术艺术动态| 国产aⅴ综合色| 91精品国产综合久久婷婷香蕉| 久久精品欧美日韩精品| 三级亚洲高清视频| 91视频观看视频| 国产亚洲成av人在线观看导航| 亚洲国产精品精华液网站|