Forum
Grundkurs
»Introduktion
»Snabbguide
»Komponenter
»Händelser
»Strängar
»Räkna med Delphi »Egna
typer
»Selektion
»Iteration
»Menyer
»Funktioner
»Arraystrukturer
Tips & Tricks
»Nya tips
»Blandat
»Databaser
»Filer
»Forms
»Grafik
»Internet
»Komponenter
»Matematik
»Multimedia
»Objekt/ActiveX
»Skrivare
»Strängar
»System
»Mest lästa tips
Artiklar
»Delphi och ADO
»Bygga en DLL
»Skapa en enkel rapport
»Hantera registret
»Enheter, units
»Klassen TCanvas
»Använd LookUp Controls
Nya
tips
Lägg
till tips
Delphilänkar
Gästbok
|
|
|
|
Använd utökade dialogrutor i Windows
|
Kategori: System
Inlagt: 2005-10-20
Läst: 1385
Inlagt av: Staffan Berg
|
Beskrivning |
Här följer några exempel på hur du använder de utökade dialogrutorna som finns gömda i Windows.
|
Kod |
function PickIconDlgA(OwnerWnd: HWND; lpstrFile: PAnsiChar; var nMaxFile: LongInt; var lpdwIconIndex: LongInt): LongBool; stdcall; external 'SHELL32.DLL' index 62; //Example (icon of current application will be changed!): procedure TForm1.Button4Click(Sender: TObject); var FileName: array[0..MAX_PATH - 1] of Char; Size, Index: LongInt; begin Size := MAX_PATH; FileName := 'c:\windows\system\shell32.dll'; if PickIconDlgA(0, FileName, Size, Index) then begin if (Index <> -1) then Application.Icon.Handle := ExtractIcon(hInstance, FileName, Index); end; end; //Of course, you can define any other file and in the dialog you'll see available icons of this executable file. //2. Find Computer //Declaration: function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean; stdcall; external 'Shell32.dll' index 91; //Example: begin SHFindComputer(nil, nil); end; //3. Find Files //Declaration: function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean; stdcall; external 'Shell32.dll' index 90; //Example: begin SHFindFiles(nil,nil); end; //Here the first parameter is a folder where you want to begin a search (nil is a Desktop). The second parameter allow to define a previous saved state of search process. //IMPORTANT: //Note that SHFindFiles and SHFindComputer are not modal dialogs (these dialogs will be started in separated thread) so the result of function will be True if dialog is created succesfully. //4. Shutdown dialog //Declaration: procedure ExitWindowsDialog(ParentWnd: HWND); stdcall; external 'Shell32.dll' index 60; //Example: begin ExitWindowsDialog(0) end;
|
|
|