Introduction to Microsoft Windows Common Dialog Boxes |
|
Description |
A common dialog box is a window that is used to perform a specific but common type of user-driven operation. Examples of such operations include opening a file, saving a file, printing, selecting a color, etc. These objects are referred to as common dialog boxes, not because they have anything in common (in most cases they don't), but because they are available as standard objects in all versions of Microsoft Windows. |
To set a mutual foundation to all common dialog boxes, the VCL provides a class named TCommonDialog. The TCommonDialog class is derived from TComponent.
|
The common dialog boxes used in the VCL are customized versions of their Win32 part. To help give a transition to their parent, the TCommonDialog class is equipped with Handle property: __property HWND__ * Handle = {read=FHandle}; As we will see, after creating a common dialog box, you must present it to the user. To make this possible, the TCommonDialog class provides a method named Execute. It is available in two versions whose syntaxes are: virtual bool __fastcall Execute(void); virtual bool __fastcall Execute(HWND__ * ParentWnd); To display the dialog box, you can call this method without passing an argument. When this method is called, the dialog box fires an OnShow event that is of type TNotifyEvent: __property TNotifyEvent OnShow; When it comes up, a common dialog box presents, among other options, a default button (sometimes labels Print, Save, Open, or else) and a Cancel button. After using the dialog box, if the user clicks the default button or presses Enter, you must collect the necessary information, validate, and take appropriate actions. On the other hand, the user can click Cancel or press Esc to ignore whatever was done on the dialog box (in some cases, there are exceptions; for example, if the user creates a folder using the Save or the Open dialog box, if the user clicks Cancel, the folder that was created will still exist). Ether way, when the dialog box closes, the object fires an OnClose event that is of type TNotifyEvent.
|
|
||
Home | Copyright © 2010-2016, FunctionX | |
|