📄 ch02.htm
字号:
<!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">
<!-- Spidersoft WebZIP Ad Banner Insert -->
<TABLE width=100% border="0" cellpadding="0" cellspacing="0">
<TR>
<TD>
<ILAYER id=ad1 visibility=hidden height=60></ILAYER>
<NOLAYER>
<IFRAME SRC="http://www.spidersoft.com/ads/bwz468_60.htm" width="100%" height="60" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no></IFRAME>
</NOLAYER>
</TD>
</TR>
</TABLE>
<!-- End of Spidersoft WebZIP Ad Banner Insert-->
';
zhtm += '<IMG SRC="' + fullPath + pPage + '">';
zhtm += '<P><B>' + pPage + '</B>';
zhtm += '
<layer src="http://www.spidersoft.com/ads/bwz468_60.htm" visibility=hidden id=a1 width=600 onload="moveToAbsolute(ad1.pageX,ad1.pageY); a1.clip.height=60;visibility='show';"></layer>
</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 -- Ch 2 -- Using Controls in Your Application</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="../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>
<HR>
</CENTER>
<H1 ALIGN="CENTER">- 2 -<BR>
Using Controls in Your Application</H1>
<H1></H1>
<UL>
<LI><A HREF="#Heading1">The Basic Windows Controls</A>
<UL>
<LI><A HREF="#Heading2">The Static Text Control</A>
<LI><A HREF="#Heading3">The Edit Box Control</A>
<LI><A HREF="#Heading4">The Command Button Control</A>
<LI><A HREF="#Heading5">The Check Box Control</A>
<LI><A HREF="#Heading6">The Radio Button Control</A>
<LI><A HREF="#Heading7">The Drop-Down List Box Control</A>
</UL>
<LI><A HREF="#Heading8">Adding Controls to Your Window</A>
<UL>
<LI><A HREF="#Heading9">Creating the Application Shell and Dialog Layout</A>
<LI><A HREF="#Heading10">Specifying the Control Tab Order</A>
</UL>
<LI><A HREF="#Heading11">Attaching Variables to Your Controls</A>
<LI><A HREF="#Heading12">Attaching Functionality to the Controls</A>
<UL>
<LI><A HREF="#Heading13">Closing the Application</A>
<LI><A HREF="#Heading14">Showing the User's Message</A>
<LI><A HREF="#Heading15">Clearing the User's Message</A>
<LI><A HREF="#Heading16">Disabling and Hiding the Message Controls</A>
<LI><A HREF="#Heading17">Running Another Application</A>
</UL>
<LI><A HREF="#Heading18">Summary</A>
<LI><A HREF="#Heading19">Q&A</A>
<LI><A HREF="#Heading20">Workshop</A>
<UL>
<LI><A HREF="#Heading21">Quiz</A>
<LI><A HREF="#Heading22">Exercises</A>
</UL>
</UL>
<P>
<HR SIZE="4">
<BR>
Some of the things that you will find in just about every Windows application are
buttons, check boxes, text fields, and drop-down list boxes. These are known as controls,
and many of these controls are built into the operating system itself. With Visual
C++, using these common controls is as easy as placing them on a dialog window with
a drag-and-drop window design method. Today you are going to learn</P>
<UL>
<LI>What the basic controls in Visual C++ are
<P>
<LI>How to declare and attach variables to a controls
<P>
<LI>How to synchronize the values between a control and a variable
<P>
<LI>How to specify the order users navigate around your application windows
<P>
<LI>How to trigger actions with controls
<P>
<LI>How to manipulate and alter the appearance of controls (while your application
is running)
</UL>
<H2><A NAME="Heading1"></A>The Basic Windows Controls</H2>
<P>Several standard controls are built into the Windows operating system, including
such things as sliders, tree and list controls, progress bars, and so on. However,
today you will work with a half dozen controls that appear in just about every Windows
application:</P>
<UL>
<LI>Static text
<P>
<LI>Edit box
<P>
<LI>Command button
<P>
<LI>Check box
<P>
<LI>Radio button
<P>
<LI>Drop-down list box (also known as a combo box)
</UL>
<P>These and other controls are readily available for use in Visual C++ applications.
They can be found on the controls palette in the Dialog Painter editor in the Developer
Studio, as shown in Figure 2.1.</P>
<P><A HREF="javascript
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -