Podobne
- Strona startowa
- Steven Rosefielde, D. Quinn Mil Masters of Illusion, American L
- Masterton Graham Wojownicy Nocy t.1 (SCAN dal 90
- Masterton Graham Nocna Plaga (SCAN dal 1062)
- Sarah Masters Voices 1 Sugar Strands
- Masterton Graham Manitou (SCAN dal 826)
- Masterton Graham Zwierciadlo piekiel
- McNaught Judith Raj
- Eddings Dav
- Microsoft Office Excel 2003 Inside Out
- 2. Aronson Elliot Psychologia Spoleczna
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- btobpoland.keep.pl
Cytat
Do celu tam się wysiada. Lec Stanisław Jerzy (pierw. de Tusch-Letz, 1909-1966)
A bogowie grają w kości i nie pytają wcale czy chcesz przyłączyć się do gry (. . . ) Bogowie kpią sobie z twojego poukładanego życia (. . . ) nie przejmują się zbytnio ani naszymi planami na przyszłość ani oczekiwaniami. Gdzieś we wszechświecie rzucają kości i przypadkiem wypada twoja kolej. I odtąd zwyciężyć lub przegrać - to tylko kwestia szczęścia. Borys Pasternak
Idąc po kurzych jajach nie podskakuj. Przysłowie szkockie
I Herkules nie poradzi przeciwko wielu.
Dialog półinteligentów równa się monologowi ćwierćinteligenta. Stanisław Jerzy Lec (pierw. de Tusch - Letz, 1909-1966)
[ Pobierz całość w formacie PDF ]
.Button2Click(Sender: TObject);varProjectFile: string;beginProjectFile := ChangeFileExt (ParamStr (0), .dpr );SHAddToRecentDocs (SHARD_PATH, PChar(ProjectFile));end;Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c19.qxd 7/2/01 4:42 PM Page 839Windows Shell Programming 839This has very little to do with COM, and I ve added it to the example only to highlightthat there is a very large number of shell-related APIs, available in the ShlObj unit, besidesthe original and more limited ShellApi unit.Another example, available in the source code for this chapter and called FindFolders,highlights the use of another plain (non-COM) shell function, SHBrowseForFolder.In theexample you can see the following code:procedure TForm1.btnBrowseClick(Sender: TObject);varbi: TBrowseInfo;pidl: pItemIdList;strpath, displayname: string;beginSetLength (displayname, 100);bi.hwndOwner := Handle;bi.pidlRoot := nil;bi.pszDisplayName := pChar (displayname);bi.lpszTitle := Select a folder ;bi.ulFlags := bif_StatusText;bi.lpfn := nil;bi.lParam := 0;pidl := SHBrowseForFolder (bi);SetLength (strPath, 100);SHGetPathFromIdList (pidl, PChar(strPath));Edit1.Text := strPath;end;The FindFolders example even shows some Delphi-specific APIs to interact with files andfolders (available also on Linux) including SelectDirectory, which has the same effect ofSHBrowseForFolderbut a different user interface.The example also uses the DirectoryExistsand ForceDirectoriesfunctions, available in the FileCtrl unit.You can see how they are usedby looking in the source code of the example.NOTENotice that in Delphi 6, some of the Shell API is also encapsulated in the sample ShellListView,ShellTreeView, and ShellComboBox controls.I ve used these controls in a few examplesthroughout the book, including the DirDemo example of Chapter 18, Writing DatabaseComponents.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c19.qxd 7/2/01 4:42 PM Page 840840 Chapter 19 " COM ProgrammingThe To-Do File ApplicationAs a second example of integrating a Delphi program with the system shell, I ve tried to writea simple real-world application that uses file dragging and a context menu handler.I ll startwith the file dragging first, because this will actually introduce some of the techniques usedby the context menu handler.As I mentioned, this application is actually useful; you can use it to create a sort of to-dolist. It is based on a Paradox table that stores filenames and notes about the files.The formof the application has a DBGrid component showing only a single column containing thefilenames and a memo control hosting the notes related to the current file.You can see thisform at design time in Figure 19.6.FI GURE 19.6:The form of the ToDoFileexample at design timeTIPUsing a single-column DBGrid is the only way in Delphi to show a list of the available records ina list-box format.The alternative, of course, is to fill a list box with custom code and then man-ually navigate in the database table when the selection in the list box changes.This manualapproach is, of course, less efficient when we have many records, because the program needsto scan them all to fill the list box, while the DBGrid loads only the record it currently displays.Notice that the navigator component has no New Record button, and the DBGrid is setup as a read-only component.In fact, users should not be able to create new records exceptby dragging a file onto the form, and they re not allowed to change the filename field in anyway (except by deleting it).All the user can do is edit the notes field, entering a description ofthe operations to be done on the file.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c19.qxd 7/2/01 4:42 PM Page 841Windows Shell Programming 841Creating the DatabaseTo create the database table for this example, I ve used the FieldDefs property to define thestructure and set the StoreDefs property to True to save the table definition along with theform DFM file.The table has two fields, a string field called Filename and a memo fieldcalled Notes.Of course, you can also create the table at design time, using the table compo-nent s local menu.The program, however, calls the CreateTable method in the OnCreateevent handler, unless this has already been done:procedure TToDoFileForm.FormCreate(Sender: TObject);begin// eventually create the tableif not Table1.Exists thenTable1.CreateTable;// activate the tableTable1
[ Pobierz całość w formacie PDF ]