{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% osCommerce Product Manager for Windows (oscpmwin). Copyright ©2003,2004,2005 by Mario A. Valdez-Ramirez. You can contact Mario A. Valdez-Ramirez by email at mario@mariovaldez.org or paper mail at Olmos 809, San Nicolas, NL. 66495, Mexico. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} unit openpicdlg; interface USES Dialogs, StdCtrls, ExtCtrls, Classes, Graphics; TYPE opmT_OpenPictureDialog = CLASS (TOpenDialog) PRIVATE opm_Panel_OPD_Preview : TPanel; opm_Panel_OPD_CtrlPreview : TPanel; opm_Panel_OPD_ImgPreview : TPanel; opm_Label_OPD_PictureData1 : TLabel; opm_Image_OPD_Preview : TImage; opm_CheckBox_OPD_AllowPreview : TCheckBox; opm_OPD_Filename : STRING; opm_OPD_AllowPreview : BOOLEAN; PROTECTED PROCEDURE AllowPreviewClick (Sender: TObject); VIRTUAL; PROCEDURE DoSelectionChange; OVERRIDE; PROCEDURE DoShow; OVERRIDE; PROPERTY ImageCtrl: TImage READ opm_Image_OPD_Preview; PROPERTY PictureData1: TLabel READ opm_Label_OPD_PictureData1; PUBLISHED PROPERTY Filter; PUBLIC CONSTRUCTOR Create(AOwner: TComponent); OVERRIDE; FUNCTION Execute: Boolean; OVERRIDE; END; implementation uses Math, Forms, Controls, SysUtils, Windows; {$R OPENPICDLG.RES} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} CONSTRUCTOR opmT_OpenPictureDialog.Create (AOwner: TComponent); BEGIN INHERITED Create (AOwner); Filter := GraphicFilter (TGraphic); opm_OPD_AllowPreview := TRUE; opm_Panel_OPD_Preview := TPanel.Create (SELF); opm_Panel_OPD_Preview.Name := 'opm_Panel_OPD_Preview'; opm_Panel_OPD_Preview.Caption := ''; opm_Panel_OPD_Preview.BorderStyle := bsNone; opm_Panel_OPD_Preview.BevelInner := bvNone; opm_Panel_OPD_Preview.BevelOuter := bvNone; opm_Panel_OPD_Preview.SetBounds (204, 5, 169, 200); opm_Panel_OPD_Preview.Align := alClient; opm_Panel_OPD_CtrlPreview := TPanel.Create (SELF); opm_Panel_OPD_CtrlPreview.Name := 'opm_Panel_OPD_CtrlPreview'; opm_Panel_OPD_CtrlPreview.Caption := ''; opm_Panel_OPD_CtrlPreview.BorderStyle := bsNone; opm_Panel_OPD_CtrlPreview.BevelInner := bvRaised; opm_Panel_OPD_CtrlPreview.BevelOuter := bvLowered; opm_Panel_OPD_CtrlPreview.SetBounds (0, 0, 160, 80); opm_Panel_OPD_CtrlPreview.Align := alTop; opm_Panel_OPD_CtrlPreview.Parent := opm_Panel_OPD_Preview; opm_Panel_OPD_ImgPreview := TPanel.Create (SELF); opm_Panel_OPD_ImgPreview.Name := 'opm_Panel_OPD_ImgPreview'; opm_Panel_OPD_ImgPreview.Caption := ''; opm_Panel_OPD_ImgPreview.BorderStyle := bsNone; opm_Panel_OPD_ImgPreview.BevelInner := bvRaised; opm_Panel_OPD_ImgPreview.BevelOuter := bvLowered; opm_Panel_OPD_ImgPreview.SetBounds (0, 80, 160, 20); opm_Panel_OPD_ImgPreview.Align := alClient; opm_Panel_OPD_ImgPreview.Parent := opm_Panel_OPD_Preview; opm_Label_OPD_PictureData1 := TLabel.Create (SELF); opm_Label_OPD_PictureData1.Name := 'opm_Label_OPD_PictureData1'; opm_Label_OPD_PictureData1.Caption := ''; opm_Label_OPD_PictureData1.SetBounds (5, 5, 154, 60); opm_Label_OPD_PictureData1.AutoSize := FALSE; opm_Label_OPD_PictureData1.WordWrap := TRUE; opm_Label_OPD_PictureData1.Parent := opm_Panel_OPD_CtrlPreview; opm_CheckBox_OPD_AllowPreview := TCheckBox.Create (SELF); opm_CheckBox_OPD_AllowPreview.Caption := 'Preview'; opm_CheckBox_OPD_AllowPreview.Checked := TRUE; opm_CheckBox_OPD_AllowPreview.SetBounds (5, 60, 154, 18); opm_CheckBox_OPD_AllowPreview.OnClick := AllowPreviewClick; opm_CheckBox_OPD_AllowPreview.Parent := opm_Panel_OPD_CtrlPreview; opm_Image_OPD_Preview := TImage.Create (SELF); opm_Image_OPD_Preview.Name := 'opm_Image_OPD_Preview'; opm_Image_OPD_Preview.Align := alClient; opm_Image_OPD_Preview.Proportional := TRUE; opm_Image_OPD_Preview.Stretch := TRUE; opm_Image_OPD_Preview.Center := TRUE; opm_Image_OPD_Preview.IncrementalDisplay := TRUE; opm_Image_OPD_Preview.ShowHint := FALSE; opm_Image_OPD_Preview.Parent := opm_Panel_OPD_ImgPreview; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE opmT_OpenPictureDialog.DoSelectionChange; VAR FileRecord : TSearchRec; BEGIN Application.HideHint; IF (Filename <> opm_OPD_Filename) THEN BEGIN opm_OPD_Filename := Filename; opm_Image_OPD_Preview.Picture := NIL; opm_Label_OPD_PictureData1.Caption := ''; IF (FileExists (opm_OPD_Filename) AND (GetFileAttributes (PCHAR (opm_OPD_Filename)) <> $FFFFFFFF)) THEN TRY IF (opm_OPD_AllowPreview = TRUE) THEN BEGIN opm_Image_OPD_Preview.Picture.LoadFromFile (opm_OPD_Filename); opm_Label_OPD_PictureData1.Caption := INTTOSTR (opm_Image_OPD_Preview.Picture.Width) + ' x ' + INTTOSTR (opm_Image_OPD_Preview.Picture.Height) + #13#10; END; IF (SysUtils.FINDFIRST (opm_OPD_Filename, faAnyFile, FileRecord) = 0) THEN BEGIN opm_Label_OPD_PictureData1.Caption := opm_Label_OPD_PictureData1.Caption + FLOATTOSTR (ROUNDTO ((FileRecord.Size / 1024), -1)) + ' kb' + #13#10 + FileRecord.Name; SysUtils.FINDCLOSE (FileRecord); END; EXCEPT opm_Image_OPD_Preview.Picture := NIL; opm_Label_OPD_PictureData1.Caption := ''; END; END; INHERITED DoSelectionChange; end; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE opmT_OpenPictureDialog.AllowPreviewClick (Sender: TObject); BEGIN opm_Image_OPD_Preview.Picture := NIL; opm_OPD_AllowPreview := opm_CheckBox_OPD_AllowPreview.Checked; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE opmT_OpenPictureDialog.DoShow; VAR PreviewRect, StaticRect: TRect; BEGIN GetClientRect (Handle, PreviewRect); StaticRect := GetStaticRect; PreviewRect.Left := StaticRect.Left + (StaticRect.Right - StaticRect.Left); INC (PreviewRect.Top, 3); INC (PreviewRect.Left, 3); DEC (PreviewRect.Bottom, 18); DEC (PreviewRect.Right, 3); opm_Panel_OPD_Preview.BoundsRect := PreviewRect; opm_Panel_OPD_Preview.ParentWindow := Handle; opm_Image_OPD_Preview.Picture := NIL; opm_Label_OPD_PictureData1.Caption := ''; opm_OPD_Filename := ''; inherited DoShow; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} FUNCTION opmT_OpenPictureDialog.Execute; BEGIN Template := 'OPMOPENPICDLG'; Execute := INHERITED Execute; END; end.