Example 1 Open
This example shows how to use the ImgAdmin Open dialog box to display a file in the Image Edit and the Thumbnail controls.
void CAdmin1Dlg::OnFileopen()
{
// Initialize Image property in order to check for Cancel
// pressed. After the dialog box is shown, check for a value
// in the image property.
ImgAdmin1.SetImage ("" );
// Specify a dialog title and a list filter rather than using
// the defaults.
ImgAdmin1.SetDialogTitle ("Select Image for Display");
ImgAdmin1.SetFilter ("All Image Files |*.bmp; *.jpg; *.tif|
Bitmap Files (*.bmp)|*. bmp|JPG Files (*.jpg)|*.jpg|
TIFF Files (*.tif)|*.tif|All Files (*.*)|*.*|");
// Default filter will be TIFF (fourth item).
ImgAdmin1.SetFilterIndex (4);
// Set the InitDir property to the preferred directory.
ImgAdmin1.SetInitDir ("C:\\images");
ImgAdmin1.SetCancelError (FALSE);
// Note: if you have Server Access software installed this
// will automatically be enabled in the Open dialog box after
// the user authenticates.
VARIANT vhWnd; V_VT(&vhWnd) = VT_I4;
V_I4(&vhWnd) = (long)m_hWnd;
ImgAdmin1.ShowFileDialog (0,vhWnd); // OpenDlg
// Determine if a file was selected or cancel was pressed
if (ImgAdmin1.GetImage() =="")
return;
// Set the image properties in the ImgEdit and Thumbnail control
// to the name of the file selected in the dialog box.
ImgEdit1.SetImage (ImgAdmin1.GetImage());
ImgThumbnail1.SetImage (ImgAdmin1.GetImage());
// Display the image in the ImgEdit and Thumbnail control.
ImgEdit1.Display();
}
Example 2 SaveAs
This example saves the displayed image with a new filename using the Admin Save dialog and the Image Edit control SaveAs method.
void CAdmin1Dlg::OnSaveas()
{
VARIANT vhWnd; V_VT(&vhWnd) = VT_I4;
V_I4(&vhWnd) = (long)m_hWnd;
ImgAdmin1.ShowFileDialog (1,vhWnd); // OpenDlg
VARIANT evt;
evt.vt = VT_ERROR; // set to error for optional parameter
ImgEdit1.SaveAs (ImgAdmin1.GetImage(), evt, evt, evt, evt, evt);
}