Xtreme toolkitpro instance 2 -- browsedialog (implement folder selection)
IDescription
This section describes how to use the folder selection dialog box (in Visual Studio. the folderbrowserdialog component is added to net to select folders. In vs6.0, browseinfo is mainly used. Interested readers can search the folder on the Internet ).
In the Xtreme toolkitpro implementation folder selection dialog box, the class is cxtbrowsedialog class, inherited from browseinfo, and some common operations are packaged to facilitate programming. For example, the setselpath function is used to specify a selected folder during dialog box initialization (generally the last operation ); getselpath is used to obtain the folder selected for the current operation (usually called when the OK button is clicked ).
IIEncoding
1. Create an Xtreme-based dialog box program. The properties of the dialog box are changed from dialog frame to resizing.
2. Add the cstatic, cedti, and cbutton controls in the dialog box, and add the cstring variable m_strdirectory associated with the cedit control.
3. Modify the parent class of the dialog box: changed from cdialog to cxtresizedialog.
4. Modify the message ing table begin_message_map in the dialog box
Set cdialog
Change to cxtresizedialog.
5. dodataexchange function in the modify dialog box
Convert cdialog: dodataexchange (PDX );
Change to cxtresizedialog: dodataexchange (PDX );
6. onsyscommand function in the modify dialog box
Set cdialog: onsyscommand (NID, lparam );
Change to cxtresizedialog: onsyscommand (NID, lparam );
7. constructor in the modify dialog box
Change the parent class cdialog In the constructor to cxtresizedialog.
8. onpaint function in the modify dialog box
Set cdialog: onpaint ();
Change to cxtresizedialog: onpaint ();
9. wm_destroy message Response Function in the Add dialog box
// Save the size and position of the current dialog box when the program exits
Void cbrowsedialog_vc80dlg: ondestroy ()
{
// Cdialog: ondestroy ();
// Todo: add your message handler code here
Saveplacement (_ T ("cbrowsedialogdlg "));
Cxtresizedialog: ondestroy ();
}
10. oninitdialog () function in the modify dialog box
Set cdialog: oninitdialog ();
Change to cxtresizedialog: oninitdialog ();
When the dialog box is changed, set the control behavior
// Set control resizing.
Setresize (idc_edt_dir, sz_top_left, sz_top_right );
Setresize (idc_btn_browse, sz_top_right, sz_top_right );
Setresize (idcancel, sz_bottom_right, sz_bottom_right );
How to change the dialog box size
// Prevent vertical resizing.
Setflag (xtresizenovertical );
When the program starts, the dialog box is initialized based on the position and size of the last launch.
// Load window placement
Loadplacement (_ T ("cbrowsedialogdlg "));
11 Add a response function for the Browse... button
If (updatedata (true ))
{
Cxtbrowsedialog DLG;
DLG. settitle (_ T ("select your directory "));
If (! M_strdirectory.isempty ())
{
// Initialize the folder Selection Based on the set value
Tchar path [_ max_path];
Strcpy_s (path, _ max_path, m_strdirectory );
DLG. setselpath (PATH );
}
If (DLG. domodal () = idok)
{
M_strdirectory = DLG. getselpath ();
Updatedata (false );
}
}