Source code of file oscpmwin_v0.4.1.745/openpicdlg.pas from the
osCommerce Product Manager for Windows.


0000:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001:   osCommerce Product Manager for Windows (oscpmwin).
0002:   Copyright �2003-2006 by Mario A. Valdez-Ramirez.
0003:   
0004:   You can contact Mario A. Valdez-Ramirez
0005:   by email at mario@mariovaldez.org or paper mail at
0006:   Olmos 809, San Nicolas, NL. 66495, Mexico.
0007:   
0008:   This program is free software; you can redistribute it and/or modify
0009:   it under the terms of the GNU General Public License as published by
0010:   the Free Software Foundation; either version 2 of the License, or (at
0011:   your option) any later version.
0012:   
0013:   This program is distributed in the hope that it will be useful, but
0014:   WITHOUT ANY WARRANTY; without even the implied warranty of
0015:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0016:   General Public License for more details.
0017:   
0018:   You should have received a copy of the GNU General Public License
0019:   along with this program; if not, write to the Free Software
0020:   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021:   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0022:   unit openpicdlg;
0023:   
0024:   interface
0025:   
0026:   USES
0027:     Dialogs, StdCtrls, ExtCtrls, Classes, Graphics;
0028:   
0029:   TYPE
0030:   
0031:   opmT_OpenPictureDialog = CLASS (TOpenDialog)
0032:     PRIVATE
0033:       opm_Panel_OPD_Preview : TPanel;
0034:       opm_Panel_OPD_CtrlPreview : TPanel;
0035:       opm_Panel_OPD_ImgPreview : TPanel;
0036:       opm_Label_OPD_PictureData1 : TLabel;
0037:       opm_Image_OPD_Preview : TImage;
0038:       opm_CheckBox_OPD_AllowPreview : TCheckBox;
0039:       opm_OPD_Filename : STRING;
0040:       opm_OPD_AllowPreview : BOOLEAN;
0041:     PROTECTED
0042:       PROCEDURE AllowPreviewClick (Sender: TObject); VIRTUAL;
0043:       PROCEDURE DoSelectionChange; OVERRIDE;
0044:       PROCEDURE DoShow; OVERRIDE;
0045:       PROPERTY ImageCtrl: TImage READ opm_Image_OPD_Preview;
0046:       PROPERTY PictureData1: TLabel READ opm_Label_OPD_PictureData1;
0047:     PUBLISHED
0048:       PROPERTY Filter;
0049:     PUBLIC
0050:       CONSTRUCTOR Create(AOwner: TComponent); OVERRIDE;
0051:       FUNCTION Execute: Boolean; OVERRIDE;
0052:     END;
0053:   
0054:   implementation
0055:   
0056:   uses Math, Forms, Controls, SysUtils, Windows;
0057:   
0058:   {$R OPENPICDLG.RES}
0059:   
0060:   
0061:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0062:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0063:   CONSTRUCTOR opmT_OpenPictureDialog.Create (AOwner: TComponent);
0064:   BEGIN
0065:     INHERITED Create (AOwner);
0066:     Filter := GraphicFilter (TGraphic);
0067:     opm_OPD_AllowPreview := TRUE;
0068:   
0069:     opm_Panel_OPD_Preview := TPanel.Create (SELF);
0070:     opm_Panel_OPD_Preview.Name := 'opm_Panel_OPD_Preview';
0071:     opm_Panel_OPD_Preview.Caption := '';
0072:     opm_Panel_OPD_Preview.BorderStyle := bsNone;
0073:     opm_Panel_OPD_Preview.BevelInner := bvNone;
0074:     opm_Panel_OPD_Preview.BevelOuter := bvNone;
0075:     opm_Panel_OPD_Preview.SetBounds (204, 5, 169, 200);
0076:     opm_Panel_OPD_Preview.Align := alClient;
0077:   
0078:     opm_Panel_OPD_CtrlPreview := TPanel.Create (SELF);
0079:     opm_Panel_OPD_CtrlPreview.Name := 'opm_Panel_OPD_CtrlPreview';
0080:     opm_Panel_OPD_CtrlPreview.Caption := '';
0081:     opm_Panel_OPD_CtrlPreview.BorderStyle := bsNone;
0082:     opm_Panel_OPD_CtrlPreview.BevelInner := bvRaised;
0083:     opm_Panel_OPD_CtrlPreview.BevelOuter := bvLowered;
0084:     opm_Panel_OPD_CtrlPreview.SetBounds (0, 0, 160, 80);
0085:     opm_Panel_OPD_CtrlPreview.Align := alTop;
0086:     opm_Panel_OPD_CtrlPreview.Parent := opm_Panel_OPD_Preview;
0087:   
0088:     opm_Panel_OPD_ImgPreview := TPanel.Create (SELF);
0089:     opm_Panel_OPD_ImgPreview.Name := 'opm_Panel_OPD_ImgPreview';
0090:     opm_Panel_OPD_ImgPreview.Caption := '';
0091:     opm_Panel_OPD_ImgPreview.BorderStyle := bsNone;
0092:     opm_Panel_OPD_ImgPreview.BevelInner := bvRaised;
0093:     opm_Panel_OPD_ImgPreview.BevelOuter := bvLowered;
0094:     opm_Panel_OPD_ImgPreview.SetBounds (0, 80, 160, 20);
0095:     opm_Panel_OPD_ImgPreview.Align := alClient;
0096:     opm_Panel_OPD_ImgPreview.Parent := opm_Panel_OPD_Preview;
0097:   
0098:     opm_Label_OPD_PictureData1 := TLabel.Create (SELF);
0099:     opm_Label_OPD_PictureData1.Name := 'opm_Label_OPD_PictureData1';
0100:     opm_Label_OPD_PictureData1.Caption := '';
0101:     opm_Label_OPD_PictureData1.SetBounds (5, 5, 154, 60);
0102:     opm_Label_OPD_PictureData1.AutoSize := FALSE;
0103:     opm_Label_OPD_PictureData1.WordWrap := TRUE;
0104:     opm_Label_OPD_PictureData1.Parent := opm_Panel_OPD_CtrlPreview;
0105:   
0106:     opm_CheckBox_OPD_AllowPreview := TCheckBox.Create (SELF);
0107:     opm_CheckBox_OPD_AllowPreview.Caption := 'Preview';
0108:     opm_CheckBox_OPD_AllowPreview.Checked := TRUE;
0109:     opm_CheckBox_OPD_AllowPreview.SetBounds (5, 60, 154, 18);
0110:     opm_CheckBox_OPD_AllowPreview.OnClick := AllowPreviewClick;
0111:     opm_CheckBox_OPD_AllowPreview.Parent := opm_Panel_OPD_CtrlPreview;
0112:   
0113:     opm_Image_OPD_Preview := TImage.Create (SELF);
0114:     opm_Image_OPD_Preview.Name := 'opm_Image_OPD_Preview';
0115:     opm_Image_OPD_Preview.Align := alClient;
0116:     opm_Image_OPD_Preview.Proportional := TRUE;
0117:     opm_Image_OPD_Preview.Stretch := TRUE;
0118:     opm_Image_OPD_Preview.Center := TRUE;
0119:     opm_Image_OPD_Preview.IncrementalDisplay := TRUE;
0120:     opm_Image_OPD_Preview.ShowHint := FALSE;
0121:     opm_Image_OPD_Preview.Parent := opm_Panel_OPD_ImgPreview;
0122:   END;
0123:   
0124:   
0125:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0126:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0127:   PROCEDURE opmT_OpenPictureDialog.DoSelectionChange;
0128:   VAR
0129:     FileRecord : TSearchRec;
0130:   BEGIN
0131:     Application.HideHint;
0132:     IF (Filename <> opm_OPD_Filename) THEN
0133:       BEGIN
0134:         opm_OPD_Filename := Filename;
0135:         opm_Image_OPD_Preview.Picture := NIL;
0136:         opm_Label_OPD_PictureData1.Caption := '';
0137:         IF (FileExists (opm_OPD_Filename) AND (GetFileAttributes (PCHAR (opm_OPD_Filename)) <> $FFFFFFFF)) THEN
0138:           TRY
0139:             IF (opm_OPD_AllowPreview = TRUE) THEN
0140:               BEGIN
0141:                 opm_Image_OPD_Preview.Picture.LoadFromFile (opm_OPD_Filename);
0142:                 opm_Label_OPD_PictureData1.Caption := INTTOSTR (opm_Image_OPD_Preview.Picture.Width) + ' x ' +
0143:                                                       INTTOSTR (opm_Image_OPD_Preview.Picture.Height) + #13#10;
0144:               END;
0145:             IF (SysUtils.FINDFIRST (opm_OPD_Filename, faAnyFile, FileRecord) = 0) THEN
0146:               BEGIN
0147:                 opm_Label_OPD_PictureData1.Caption := opm_Label_OPD_PictureData1.Caption +
0148:                                                       FLOATTOSTR (ROUNDTO ((FileRecord.Size / 1024), -1)) + ' kb' +
0149:                                                       #13#10 + FileRecord.Name;
0150:                 SysUtils.FINDCLOSE (FileRecord);
0151:               END;
0152:           EXCEPT
0153:             opm_Image_OPD_Preview.Picture := NIL;
0154:             opm_Label_OPD_PictureData1.Caption := '';
0155:           END;
0156:       END;
0157:     INHERITED DoSelectionChange;
0158:   end;
0159:   
0160:   
0161:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0162:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0163:   PROCEDURE opmT_OpenPictureDialog.AllowPreviewClick (Sender: TObject);
0164:   BEGIN
0165:     opm_Image_OPD_Preview.Picture := NIL;
0166:     opm_OPD_AllowPreview := opm_CheckBox_OPD_AllowPreview.Checked;
0167:   END;
0168:   
0169:   
0170:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0171:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0172:   PROCEDURE opmT_OpenPictureDialog.DoShow;
0173:   VAR
0174:     PreviewRect, StaticRect: TRect;
0175:   BEGIN
0176:     GetClientRect (Handle, PreviewRect);
0177:     StaticRect := GetStaticRect;
0178:     PreviewRect.Left := StaticRect.Left + (StaticRect.Right - StaticRect.Left);
0179:     INC (PreviewRect.Top, 3);
0180:     INC (PreviewRect.Left, 3);
0181:     DEC (PreviewRect.Bottom, 18);
0182:     DEC (PreviewRect.Right, 3);
0183:     opm_Panel_OPD_Preview.BoundsRect := PreviewRect;
0184:     opm_Panel_OPD_Preview.ParentWindow := Handle;
0185:     opm_Image_OPD_Preview.Picture := NIL;
0186:     opm_Label_OPD_PictureData1.Caption := '';
0187:     opm_OPD_Filename := '';
0188:     inherited DoShow;
0189:   END;
0190:   
0191:   
0192:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0193:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0194:   FUNCTION opmT_OpenPictureDialog.Execute : BOOLEAN;
0195:   BEGIN
0196:     Template := 'OPMOPENPICDLG';
0197:     Execute := INHERITED Execute;
0198:   END;
0199:   
0200:   
0201:   end.
 
 
NA fum/lmd: 2007.07.15
Copyright ©1994-2024 by Mario A. Valdez-Ramírez.
no siga este enlace / do not follow this link