Programming

311 downloads 512 Views 4MB Size Report
editions in pilnt! Programming. lG++. Fifth Edition. I. I. David J. Kruglinski,. George Shepherd, ... PROGRAI\,1MING MICROSOFT VISUAL C++. Enabf ing the ...
.':';Z7Fl"

Halfa millioncopies of previous editions in pilnt!

M cr o s o l t ' WindovrsM' W ndowsSS

nw CDROIM lncuded

Programming

lG++ Edition

Fifth

I

I

DavidJ. Kruglinski, GeorgeShepherd, and ScotWingo

Cot:*: ?a-u; 016

Program Microsoft"

Visual G++' FifthEdition

gm3 Dnvid.J. IQ,uglinski, ScotWingo,nnd.George Shepherd

MICROSOFTVISUAL C++ PROGRAI\,1MING

Enabfing the DiagnosticMacros.. . .. . Headers . Precompiled Understanding TwoWaysto Run a Program

44 .

"""" '

'

"44 46

CHAPTEBFOUR

t a n d l i n gM, a p p i n gM o d e sa, n d B a s i cE v e nH View 4z a Scrolling GettingUserInput-MessageMap Functions M a p p i nM g o d e s . . . . . .. . A ScrollingViewWindow OtherWindowsMessages

"""

""

4| 60 67 73

CHAPTERFIVE

Colors,and Fonts 75

CHAPTER SIX

TheModalDialogandWindowsCommonControlst03 . Modalvs. ModelessDialogs . ,' Resourcesand Controls " Programminga ModalDialog Example " The DialogThat Ate Cincinnati-The EX06A . .. Program Enhancingthe Dialog . ldentityingControls:CWndPointersand ControllDs Settingthe Colorfor the DialogBackgroundand lor Controls " Paintinglnsidethe DialogWindow Runtime at AddingDialogControls " UsingOtherControlFeatures windows CommonControls The EX06BExample

103 ]04 l04 106 123 127 l2T 129 129 130 131 134

TABLEOF CONTENTS

CHAPTEB SEVEN

DialogandWindows TheModeless Dialogsr*z Common . 147 ModelessDialogs.............. The CFormViewclass-A ModelessDialogAlternative.. .. . .. 156 . . ... 156 TheWindowsCommonDialogs............. CHAPTEREIGH.r

UsingActiveXControls165 ActivexConlrolsvs. OrdinaryWindowsControls. ..... . . .... 166 . . . .. . . . . . ..... . 168 InstallingActivex Controls TheCalendarControl............... ............... 169 . . 171 .. Activex ControlContainerProgramming . . .176 Dialog Container The EX08AExample-An Activex Control . .. . 186 ActivexControlsin HTMLFi|es.......,............ .. . .. .186 . . . CreatingAclivex Controlsat Runtime Example-TheWeb BrowserActivex Control . . ., .,. 187 The EXOSB web Browser.. 191 Example-A CompleieDual-Window The EXOSC .. .... . .. .192 P i c t u r eP r o p e r i i e s . . . . . . . . . . . . . . . . . . . . . , . . . . .. .. . 193 BindableProperties-ChangeNotifications . .. . . .. .. . .. . ..,..194 OtherActivexContro|s............. C}IAPTEB NINE

4 CommonControls195 InternetExplorer An Introductionto the NewlnternetExplorer4 CommonControls . 195 .... ... .. 199 T h eE X O 9 E Axample CHAPIERTEN

Win32MemoryManagemenl217 . . .. . .217 and MemorySpace.....,,.......... Processes .220 . . . . . . . . . . . W o r k s Mfe m o r y H o wV i r t u a l.he VirtualAttocFunction-Committed and ReservedMemory. 223 TheWindowsHeapand the GlobalA ocFunctionFamily . . .. .. 224 The Small-BlockHeap,the C++ new and derefeOperators' ...225 ....... a n d- h e a p m i n ..... . . .226 M e m o r y - M a p pFei lde s . . . . . . . . , . , . . . . . . . . . . ..... .228 AccessingResources

VISUALC++ I.4ICROSOFT PROGRAMMING

. .. . ..228 ........... DynamicMemory.............. SomeTipsfor Managing . . .229 Optimizing Storagefor ConstantData.................................. CHAPTERELEVEN

Bitmaps 231 t a p .s. . . . . . . . . . . . . . . . . . .2 3 1 s n d D e v i c e - l n d e p e n dBei tnm G D fB i t m a p a ....................232 U s i n gG D IB i t m a p s .237 UsingBitmapsto lmprovethe ScreenDisplay............................... ...........243 DlBsand the CDibClass . . . . . . . 258 ....... GoingFurtherwith DlBs.............. . . 261 ................. PuttingBitmapson Pushbuttons C}IAPTERTWELVE

andMultithreaded Processing Windows Message z6z Programming WindowsMessageProcessing O n - f d fP e r o c e s s i n g . . . . . .......... . . . M u l t i t h r e a dP ed rogramming

. .. .. 267 . . . . . . . ... .. . . . . . . 2 7 3 . . . . . . . . ..... . . . . . . 2 7 3

P A R r r r r ! T H ED O C U M E N T - V I EAWR C H I T E C T U R E CHAPIER THIRTEEN

the RichEditControl, Accelerators, Menus,Keyboard and PropertySheets 287 . . .287 Classes.................... The MainFrameWindowand Document . . .. . . 2 8 8 WindowM s enus................ . . .289 .... KeyboardAccelerators .... . 290 CommandProcessing........ . . . . . .293 Built-lnMenultems........ Framework's The Application ..........294 MFCTextEditingOptions .... . . . ..295 The EX13AExample ...........301 P r o p e r tSy h e e l s. . . . . . . . . . . . . . . . . . . . ..............303 T h eE X 1 3 AE x a m p l R e evisited............ . . . . . . . . . . . . . . . . .3. .I.8. . . . . . . T h eC M e n uC | a s s. . . . . . . . . . . . . . . . . . . . . . . . . . .......................... 3 19 CreatingFloatingPop-UpMenus ... . .. .320 ........... Extended CommandProcessing

TABLEOF CONTENTS

CHAPTER FOURTEEI{

CHAPIER FIFTEEN

A ReusableFrameWindowBaseClass o+g

' 349 " Why ReusableBase ClassesAre Difficult to Write " '350 lh; cPercistentFrcmeClass " Function 350 The CFramewndGlassand the ActivateFrameMember 351 The Pre1reatewindowMemberFunction 352 "" " The Windows Registry 354 Using the Cslring Class 356 " The Positionof a MaximizedWindow 357 Control Bar Status and the Registry 357 Static Data Members 358 . The DefaultWindowRectangle 358 " The EX15AExample 365 PersistentFramesin MDI Applications CHAPTERSIXTEEN

the Documentfrom lts View 367 Separating Document-ViewInteractionFunctions The Simplest Document-view Applicalion The CFormViewClass. The C}biectclass. ... " "" DiagnosticDumping. The EX16AExample A More AdvancedDocument-Viewlnteraction Function The CDocument::Detete?ontents The CObListCollectionClass

367 " 370 371 . " "" " 372 " "" " 372 378 ' 386 347 "" " 387 .

vii

VISUAL C++ PROGRAMMINGIVIICROSOFT

,.,.....623 An MFCAutomation ClientProgram............. An AutomationClientProgramUsinglhe Compiler's 626 ..,.................... ..... ................. ..,. #importDirective ...........................627 T h eV A R I A NTTy p e. . . . . . . . . . . . . . . . . . . . . . . ..........................629 T h e C o l e v a r i a nCtl a s s . . . . . . . . . . . . . . . . . . ................633 Automation Examples . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . 6 8 1 V B AE a r l yB i n d i n g. . . . . . . . . . . . . . CHAPTERTWENTY-SIX

Transfer and OLE UniformDataTransfer-Clipboard Dragand Drop eez ..........................687 Interface............. The lDataobiect ......................,........689 Structures The FORMATETC and STGMEDIUM .....................692 Data Transler Support MFCUniform ......,..,.,..696 The MFCCRectTracker Class.................. Clipboard...............................698 The EX26AExample-A DataObiect ....................708 M F CD r a ga n dD r o p Drop.................... ................... 7 11 The EX26BExample-OlE Dragand 714 and Dragand Drop-Dobjview................... WindowsApplications . . . . . . . . . . .....715 . . . . . ... C o n cuf s i o n . . . . . . . . CHAPTERTWEI{TY-SEVEI{

Storage z'lz Structured ................................,,.717 C o m p o u nFd i f e s . . . . . . . . . . . . . . . . . . . , .....................718 Storages andthe rstorageInterface ...........722 Streamsandthe rsfreamInterface............. .........,.................723 T h e l L o c k B y t eI ns t e r t a c e . . . . . . . . . . . . . ..........724 The EX27AExample-StructuredStorage COMObiects............,.....,,.........729 Structured Storageand Persistent ......................732 DLLComponent The EX27BExample-APersistent 737 The EX27CExample-A PersistentStorageClientProgram.......... C o m p o u nF d i f eF r a g m e n t a t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4 2 O t h e rC o m p o u nFd i l eA d v a n t a g e. .s. . . . . . . . . . . . . , . ., ., . . . . . . . . . . . , . . . . . . . , . , . . 7 4 3 CIIAPTERTWENTY-EIGHT

and Containers745 OLEEmbeddedComponents Activation(VisualEditing)........................746 Embedding vs. In-Place ...................747 Mini-Servers vs. FullServers(Components)-Linking

TABLEOF CONTENTS

" " ' The DarkSideot visual Editing "" " "" WindowsMetafilesand EmbeddedObiects Programs "" The MFCOLEArchitecturetor Component Mini-Server " ln-Place-Activated MFC The EX28AExample-An Interactions Container-Component . .. . .. . .. ComponentStates An lnterfaceSummary " OLEHelperFunctions...... An OLEEmbeddingContainerApplication The EX28BExample-An EmbeddingContainer" The EX28CExample-An OLEEmbeddedComponent

747 748 749 750 756 760 763 765 766 768 791

CHAPTER'WENTY.NINE

Library 799 theActiveTemplate Introducing RevisitingCOM. . . .. .. .. . WritingCOMCode... .. . . . .' The COM lnfrastructure The ATL Roadmap Client-SideATL Programming ATL Programming" Server-Side Concfusion.......

"

799 " 803 805 807 ' S09 821 " 847 "" ""

CHAPTERTHIRTY

Controls 449

PART V: DATABASEMANAGEMENT C}IAPTERTHIRTY-O E

with MicrosoftODBC 897 DatabaseManagement " The Advantagesol DatabaseManagement Language Structured Query " The ODBCStandard The MFCODBCClasses- CRecordsetand CDatabase " "" " " The Student RegistrationDatabase

S9S 899 899 9o2 905

XI

PROGRAIVIMING IV]ICROSOFT VISUAL C++

TABLEOF CONTENTS

PA RT V I:

FORTHE INTERNET PROGRAMMING

CHAPTER THIRTY-FOUR

andWinlnet 985 Winsock, TCP/IP, .. .. . . . . .. . . .. . ., 985 To COMor Notto COM........ ..986 P tr i m e r lnterne ". ...... . . . .. .. . .997 ....,.,....... BuildYourown $99Intranet ..........999 Winsock ........ . .... 1013 BuildingaWebServerwith CHttpBlockingsocket . .1017 Buifding a Web Client with CHttpBlockingsocket. . . . .. . . , , , , . . . . . . . . . .1, .0. 1 . .8. . . . W i n l n e.t. . . . . . . . . . . . . .. .. 1024 Buildinga WebClientwith the MFCWinlnetC|asses... . . . ,.,., . . ...... . . . 1026 AsynchronousMonikerFiles CHAPTERTHIRTY.FIVE

InternetInformation the Microsoft Programming Server lo29 ...,.,.. ..1029 l l sA l t e r n a t i v e s . 1029 Microsoft lls " .. . . 1033 . . . . . . . ., ISAPIServerExtensions.,....... ... .... . .. ., . 1038 ISAPIServerExtension-ex3sa.dl| A Practical .1045 . . .. .. .. . . .. . Access.....,,,...... ISAPIDatabase U s i n g H T T P C o o k i e s t o L i n k T r a n s a c t i o. .n,s... . . . , . . . . .. . . , 1 0 4 5 . .... . ..,.1047 , .n. . . . . . . . . . . . . . . . W W WA u t h e n t i c a t i o ......,.. ,.1049 I S A PFI i l t e r s . . . . . . 1051 I i l t e r - e x 3 5 b . del lx,3 s c . e x e . ., . . . . . . . . . . . A S a m p l eI S A P F CHAPTERIHIBTY-SIX

Serversandthe Internetlo55 ActiveXDocument ...,.....,..1055 ActiveXDocumentTheory........... . . . . . A c t i v e x D o c u m e n t S e r v e r E x a m p l e E X 3 6 A . . . . . , . . .. . . 1 0 6 1 e X 3 6 B, . . . . . . . . . . . . . . . . 1 0 6 4 r x a m p lE A c t i v e xD o c u m e nSt e r v e E . .1073 Servers. . ... Document GoingFurtherwith Activex CIIAPTERTHIBTY'SEVEN

DynamicHTML ro75 Introducing The DHTMLObiectModel VisualC++and DHTML

. .. 1076 . . . .,.1080

PROGRAI!1MJNG I\,lICROSOFT VISUAL C++

CHAPTER THIRTY.EIGHT

V i s u aCl + +f o rW i n d o wC s E rogt WindowsCE Devices.. ..... VisualC++for WindowsCE . . For MoreInformationon WindowsCE...

. . . . . . . . I. 0. .9 2 . . . . . . . . . . . . . . .1. .0. 9 . .6. . . . . . . . . . ............ 1110

APPENDIX A

Me.lsage Map Functions in the Microsoft Foundation u t a s sL t D r a r y1 l 1 l APPENDIX B

M F CL i b r a r yR u n t i mC e l a s sl d e n t i f i c a t iaonndD y n a m i c UojecU t r e a t , o nl t 1 9 Gettingan Obiect'sClassNameat Runtime The MFCCRuntimectassStructureand the BUNTIME_CLASS Macro......... DynamicCreation

.

19

.. . . . . . . . .1. 1. .2. .0

1125

Suggest Documents