Scalabium Software |
|
Knowledge for your independence'. | |
Home Delphi and C++Builder tips |
#131: How can I use extended Windows dialogs? |
|
Today I want to show a few samples how you can use the extended dialogs from MS Windows (Find Files, Find Computer, Select Icon etc) in own code. Usually the MessageDlg is most used from standard dialogs but inside of Windows you'll find a lot of other useful dialogs too. The any such dialog is declared in the Shell32.dll library and you can use it so: 1. Select an icon Declaration: 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: Example: begin SHFindComputer(nil, nil); end; 3. Find Files Declaration: 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: 4. Shutdown dialog Declaration: Example: begin ExitWindowsDialog(0) end;
5. RestartDialog Declaration: Example: begin if RestartDialog(0, 'I want to call a RestartDialog ', EW_RESTARTWINDOWS) = IDYES then ShowMessage('succesfully started') end; You can define any reason of restarting (second parameter - additionally to default text or nil for default only) and use the another flag (one from the next available): EWX_LOGOFF This dialog is very useful for application which have embedded install procedure. 6. OutOfSpace Declaration: Example: begin SHHandleDiskFull(0, 2); end; Note that second parameter is Drive number where 0 is A:, 1 is B:, 2 is C: etc Of course, in the Shell32.dll you'll find other dialogs too (Object Properties, Map Network Drive, Browse For Folder etc) and you can use these dialogs without any problems. IMPORTANT:
|
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |