<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<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 += '</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">
<META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1.1">
<TITLE>Teach Yourself Visual C++ 6 in 21 Days -- Appendix B -- Answers</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
<H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"
BORDER="0"><BR>
Teach Yourself Visual C++ 6 in 21 Days</H1>
<CENTER>
<P><A HREF="../apa/apa.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apc/apc.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>
<H1 ALIGN="CENTER">- B -<BR>
Answers</H1>
<UL>
<LI><A HREF="#Heading1">Day 1</A>
<LI><A HREF="#Heading4">Day 2</A>
<LI><A HREF="#Heading7">Day 3</A>
<LI><A HREF="#Heading10">Day 4</A>
<LI><A HREF="#Heading12">Exercise</A>
<LI><A HREF="#Heading13">Day 5</A>
<LI><A HREF="#Heading16">Day 6</A>
<LI><A HREF="#Heading19">Day 7</A>
<LI><A HREF="#Heading22">Day 8</A>
<LI><A HREF="#Heading25">Day 9</A>
<LI><A HREF="#Heading28">Day 10</A>
<LI><A HREF="#Heading31">Day 11</A>
<LI><A HREF="#Heading34">Day 12</A>
<LI><A HREF="#Heading37">Day 13</A>
<LI><A HREF="#Heading40">Day 14</A>
<LI><A HREF="#Heading43">Day 15</A>
<LI><A HREF="#Heading46">Day 16</A>
<LI><A HREF="#Heading49">Day 17</A>
<LI><A HREF="#Heading52">Day 18</A>
<LI><A HREF="#Heading55">Day 19</A>
<LI><A HREF="#Heading58">Day 20</A>
<LI><A HREF="#Heading61">Day 21</A>
</UL>
<P>
<HR SIZE="4">
<BR>
This appendix provides the answers to the quiz questions and exercises at the end
of each chapter.</P>
<P>
<H2><A NAME="Heading1"></A>Day 1</H2>
<H2>Quiz</H2>
<DL>
<DT></DT>
<DD><B>1. </B>How do you change the caption on a button?
<P>
<DT></DT>
<DD>In the window layout editor, select the button to be changed. Right-click the
mouse and select Properties from the pop-up menu. Change the value in the Caption
field.
<P>
<DT></DT>
<DD><B>2. </B>What can you do with the Visual C++ AppWizard?
<P>
<DT></DT>
<DD>You can use it to build a shell for your application, based on the type of application
and the functionality needs of the application. The shell will have support for the
desired functionality already built in.
<P>
<DT></DT>
<DD><B>3. </B>How do you attach functionality to the click of a button?
<P>
<DT></DT>
<DD>By using the Class Wizard, you can create a function and attach it to an object
for handling a specific Windows message. The Class Wizard creates the function and
can take you right to the spot in the function's code where you need to begin adding
your own code.
<P>
</DL>
<H3>Exercise</H3>
<P>Add a second button to the About window in your application. Have the button display
a different message from the one on the first window.</P>
<DL>
<DT></DT>
<DD><B>1. </B>In the workspace pane, select the Resource View tab.
<P>
<DT></DT>
<DD><B>2. </B>Expand the dialog tree branch and double-click the IDD_ABOUTBOX dialog,
bringing it into the Developer Studio editor.
<P>
<DT></DT>
<DD><B>3. </B>Click the button control on the toolbar.
<P>
<DT></DT>
<DD><B>4. </B>Click and drag the mouse on the window where you want the button to
be placed.
<P>
<DT></DT>
<DD><B>5. </B>Open the properties dialog for the new button, changing the ID and
caption to describe the message to be displayed by the button. Close the properties
dialog.
<P>
<DT></DT>
<DD><B>6. </B>Open the Class Wizard and add a new function for the clicked message
for your new button.
<P>
<DT></DT>
<DD><B>7. </B>Click the Edit Code button in the Class Wizard to take you to the spot
in your code where your new function is.
<P>
<DT></DT>
<DD><B>8. </B>Add the MessageBox function to display a message to the user.
<P>
<DT></DT>
<DD><B>9. </B>Compile and run your application to test your new button.
<P>
</DL>
<H2><A NAME="Heading4"></A>Day 2</H2>
<H3>Quiz</H3>
<DL>
<DT></DT>
<DD><B>1. </B>Why do you need to specify the tab order of the controls on your application
windows?
<P>
<DT></DT>
<DD>By specifying the tab order of the controls on your application windows, you
can control the order in which the user navigates the application window. If the
user is using the keyboard to navigate around the application window, then the two
primary means of navigating between controls are the tab key and mnemonics that jump
directly to specific controls. The tab order helps provide the user with a consistent
and predictable experience when using your application.
<P>
<DT></DT>
<DD><B>2. </B>How can you include a mnemonic in a static text field that will take
the user to the edit box or combo box beside the text control?
<P>
<DT></DT>
<DD>If you place a mnemonic in a static text control and then make sure that the
static text control is just before the edit control associated with the static text,
the user can select the mnemonic in the static text control to jump directly to the
edit box control.
<P>
<DT></DT>
<DD><B>3. </B>Why do you need to give unique object IDs to the static text fields
in front of the edit box and combo boxes?
<P>
<DT></DT>
<DD>The unique object IDs on the two static text controls were necessary because
you need to manipulate those two controls with the check boxes that enable or disable
and show or hide sets of controls.
<P>
<DT></DT>
<DD><B>4. </B>Why do you need to call the UpdateData function before checking the
value of one of the controls?
<P>
<DT></DT>
<DD>If the user has changed the value of the control on the screen, the UpdateData
function must be called, passing it TRUE as the function argument, to copy the values
from the controls on the window to the variables that are associated with those controls.
If UpdateData is not called, then the values of the variables may not correctly reflect
what the user has changed on the screen.
<P>
</DL>
<H3>Exercises</H3>
<DL>
<DT></DT>
<DD><B>1. </B>Add code to the Default Message button to reset the edit box to say
Enter a message here.
<P>
<DT></DT>
<DD>Using the Class Wizard, add a function to the Default Message button's clicked
event. In this function, add the code in Listing B.1.
<P>
</DL>
<H4>LISTING B.1. DAY2DLG.CPP--THE CODE TO PLACE A DEFAULT MESSAGE IN THE EDIT BOX.</H4>
<PRE> 1: void CDay2Dlg::OnDfltmsg()
2: {
3: // TODO: Add your control notification handler code here
4:
5: ///////////////////////
6: // MY CODE STARTS HERE
7: ///////////////////////
8:
9: // Set the message to a default message
10: m_strMessage = "Enter a message here";
11:
12: // Update the screen
13: UpdateData(FALSE);
14:
15: ///////////////////////
16: // MY CODE ENDS HERE
17: ///////////////////////
</PRE>
<PRE>18: }</PRE>
<DL>
<DT></DT>
<DD><B>2. </B>Add code to enable or disable and
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
v002.rar (35个子文件)
Visual C++ 6.0 21天自学教程
ch09
ch09.htm 9KB
ch08
ch08.htm 69KB
ch16
ch16.htm 15KB
ch01
ch01.htm 12KB
ch12
ch12.htm 41KB
ch19
ch19.htm 0B
ch07
ch07.htm 51KB
ch13
ch13.htm 73KB
apc
apc.htm 52KB
ch15
ch15.htm 41KB
ch06
ch06.htm 11KB
ch04
ch04.htm 33KB
使用说明.htm 5KB
ch02
ch02.htm 49KB
fm
fm.htm 13KB
apa
apa.htm 65KB
中华电脑书库.url 79B
apb
apb.htm 101KB
ch14
ch14.htm 61KB
ch17
ch17.htm 9KB
ch21
ch21.htm 1KB
ch10
ch10.htm 0B
apd
apd.htm 37KB
copy.htm 2KB
apf
apf.htm 80KB
ch11
ch11.htm 24KB
ch03
ch03.htm 42KB
index.htm 5KB
ch20
ch20.htm 57KB
ape
ape.htm 47KB
ch05
ch05.htm 50KB
button
sams.gif 1KB
previous.gif 615B
next.gif 577B
contents.gif 514B
共 35 条
- 1
资源评论
beasonshu
- 粉丝: 0
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功