[ Pobierz całość w formacie PDF ]
.When the user selects a new folder, the OnChange event handler of theShellTreeView control refreshes the dataset.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c18.qxd 7/2/01 4:40 PM Page 814814 Chapter 18 " Writing Database ComponentsFI GURE 18.7:The output of the DirDemoexample, which uses arather unusual dataset,showing directory data.procedure TForm1.ShellTreeView1Change(Sender: TObject; Node: TTreeNode);beginMdDirDataset1.Close;MdDirDataset1.Directory := ShellTreeView1.Path + \*.* ;MdDirDataset1.Open;end;What s Next?In this chapter we ve delved inside Delphi s database architecture, by first examining thedevelopment of data-aware controls and then studying the internals of the TDataSet class towrite a couple of custom dataset components.With this information, and all the other ideaspresented in this part devoted to database programming, you should probably be able tochoose the architecture of your database applications, depending on your needs.NOTEI ve actually extended the list-based dataset to build an object-based version, hosting the busi-ness logic of an application and mapped to a relational database.Refer to my Web site(www.marcocantu.com) or contact me for the availability of this code.Database programming is certainly a core element of Delphi, the reason for devoting sev-eral chapters of the book to this topic.We ll get back to this topic when focusing on present-ing database data over the Web, in Chapters 21 and 22.For the moment, though, we have to introduce another important element of Windowsapplications, COM and OLE Automation, covered in the next two chapters.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c19.qxd 7/2/01 4:41 PM Page 815PARTIVBeyond Delphi:Connecting with theWorldChapter 19: COM ProgrammingChapter 20: From Automation to COM+Chapter 21: Internet Programming: Sockets and IndyComponentsChapter 22: Web Programming with WebBroker andWebSnapChapter 23: XML and SOAPCopyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c19.qxd 7/2/01 4:41 PM Page 817CHAPTER 19COM ProgrammingWhat are OLE and COM?COM, GUIDs, and class factoriesDelphi interfaces and COMThe VCL COM-support classesWindows shell interfacesCopyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c19.qxd 7/2/01 4:41 PM Page 818818 Chapter 19 " COM ProgrammingFor about 10 years, starting soon after the release of Windows 3.0, Microsoft has keptpromising that its operating system and their API would be based on a real object modelinstead of functions.According to the speculations, Windows 95 (and later Windows 2000)should have been based on this revolutionary approach.Nothing like this happened, butMicrosoft kept pushing COM (Component Object Model), built the Windows 95 shell ontop of it, pushed applications integration with COM and derivative technologies (such asAutomation), and reached the peak by introducing COM+ with Windows 2000.Now, soon after the release of the complete foundation required for high-level COM pro-gramming, Microsoft has decided to switch to a new core technology, part of the dotNet (or.Net, if you prefer) initiative.My impression is that COM wasn t really suited for the integra-tion of fine-grained objects, though it succeeded in providing an architecture for integratingapplications or large objects.NOTEdotNet is a mix of interesting new technologies and pure marketing hype, and this bookdoesn t discuss it in detail.Even if it were possible to predict how dotNet will affect program-mers using Microsoft development tools, it is far from clear how it will affect Delphi pro-grammers.dotNet, in fact, is based on a class library very similar to Delphi s VCL, and it isunclear what the advantage will be of switching to it.If Borland could bundle the VCL withan operating system, along with its core run-time packages, you d have a situation very simi-lar to dotNet, as far as the library is concerned.Instead, if you are looking for a virtualmachine and portable code, you can certainly consider Java and the portability between Win-dows and Linux possible with the CLX library of Delphi 6 and Kylix.Having said this, I m notunderestimating dotNet, but this is a book on Delphi programming.In any case, we ll getback to many core elements of dotNet in the final chapters, discussing XML and SOAP.Finally, the system can expose dotNet objects as COM objects, so after you learn COM you llalso have a chance to interact with dotNet.In this chapter, we ll build our first COM object and integrate COM objects with theWindows shell [ Pobierz caÅ‚ość w formacie PDF ]