Source code of file oscpmwin/pedit.pas from the
osCommerce Product Manager for Windows.


0000:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001:   osCommerce Product Manager for Windows (oscpmwin).
0002:   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 pedit;
0023:   
0024:   interface
0025:   
0026:   uses
0027:     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
0028:     Dialogs, ComCtrls, StdCtrls, Buttons, ExtCtrls,
0029:     ImgList, Menus, ShellAPI, oscpmdata;
0030:   
0031:   CONST
0032:     OPM_AUTODOWNLOADIMG = WM_USER + 1234;
0033:   
0034:   type
0035:     Topm_Form_PEdit = class(TForm)
0036:       opm_BitBtn_PEditOk: TBitBtn;
0037:       opm_BitBtn_PEditCancel: TBitBtn;
0038:       opm_ImageList_PImg: TImageList;
0039:       opm_PageControl_PEdit: TPageControl;
0040:       opm_TabSheet_PEditMain: TTabSheet;
0041:       opm_TabSheet_PEditDesc: TTabSheet;
0042:       opm_ComboBox_PEditCat: TComboBox;
0043:       opm_ComboBox_PEditMan: TComboBox;
0044:       opm_Edit_PEditModel: TEdit;
0045:       opm_Edit_PEditQuantity: TEdit;
0046:       opm_Edit_PEditPrice: TEdit;
0047:       opm_Edit_PEditSpecial: TEdit;
0048:       opm_Edit_PEditWeight: TEdit;
0049:       opm_label_PeditWeight: TLabel;
0050:       opm_label_PeditSpecial: TLabel;
0051:       opm_label_PeditPrice: TLabel;
0052:       opm_label_PeditQty: TLabel;
0053:       opm_label_PeditModel: TLabel;
0054:       opm_label_PeditMan: TLabel;
0055:       opm_label_PeditCat: TLabel;
0056:       opm_CheckBox_PEditAvailable: TCheckBox;
0057:       opm_TabControl_PEdit: TTabControl;
0058:       opm_label_PeditName: TLabel;
0059:       opm_label_PeditDesc: TLabel;
0060:       opm_label_PeditURL: TLabel;
0061:       opm_Edit_PEditName: TEdit;
0062:       opm_Memo_PEditDescription: TMemo;
0063:       opm_Edit_PEditURL: TEdit;
0064:       opm_ComboBox_PEditTax: TComboBox;
0065:       opm_label_PeditTax: TLabel;
0066:       opm_TabSheet_PEditImg: TTabSheet;
0067:       opm_BitBtn_PEditStopDown: TBitBtn;
0068:       opm_StaticText_PeditImageETA: TStaticText;
0069:       opm_StaticText_PeditImageData: TStaticText;
0070:       opm_StaticText_PeditImageURL: TStaticText;
0071:       opm_BitBtn_PEditDown: TBitBtn;
0072:       opm_BitBtn_PEditDeleteImg: TBitBtn;
0073:       opm_BitBtn_PEditUploadImg: TBitBtn;
0074:       opm_StaticText_PeditCurr1: TStaticText;
0075:       opm_StaticText_PeditCurr2: TStaticText;
0076:       opm_Label_PeditViewed: TLabel;
0077:       opm_StaticText_PeditViewed: TStaticText;
0078:       opm_Memo_UploadDEBUG: TMemo;
0079:       opm_PopupMenu_UploadDebug: TPopupMenu;
0080:       opm_PopMenuItem_HideUploadDebug: TMenuItem;
0081:       opm_BitBtn_PEditSelectImg: TBitBtn;
0082:       opm_BitBtn_PEditStripHTML: TBitBtn;
0083:       opm_DateTimePicker_PEditAvailDate: TDateTimePicker;
0084:       opm_label_PeditAvailDate: TLabel;
0085:       opm_StaticText_PeditCDate: TStaticText;
0086:       opm_StaticText_PeditMDate: TStaticText;
0087:       opm_label_PeditCDate: TLabel;
0088:       opm_label_PeditMDate: TLabel;
0089:       opm_label_PeditPriceTaxed: TLabel;
0090:       opm_Edit_PEditPriceTaxed: TEdit;
0091:       opm_StaticText_PeditCurr3: TStaticText;
0092:       opm_StatusBar_PEdit: TStatusBar;
0093:       opm_Edit_PeditImageURL: TEdit;
0094:       opm_BitBtn_PEditUnlinkImg: TBitBtn;
0095:       opm_ScrollBox_PeditImage: TScrollBox;
0096:       opm_Panel_PeditImage0: TPanel;
0097:       opm_Image_Pedit0: TImage;
0098:       opm_Panel_PeditImage1: TPanel;
0099:       opm_Image_Pedit1: TImage;
0100:       opm_Panel_PeditImage2: TPanel;
0101:       opm_Image_Pedit2: TImage;
0102:       opm_Panel_PeditImage3: TPanel;
0103:       opm_Image_Pedit3: TImage;
0104:       opm_Panel_PeditImage4: TPanel;
0105:       opm_Image_Pedit4: TImage;
0106:       opm_Panel_PeditImage5: TPanel;
0107:       opm_Image_Pedit5: TImage;
0108:       opm_Panel_PeditImage6: TPanel;
0109:       opm_Image_Pedit6: TImage;
0110:       opm_BitBtn_PEditDownAll: TBitBtn;
0111:       opm_SpeedButton_ClearImgCache: TSpeedButton;
0112:       procedure FormShow(Sender: TObject);
0113:       procedure opm_BitBtn_PEditOkClick(Sender: TObject);
0114:       procedure FormCreate(Sender: TObject);
0115:       procedure opm_BitBtn_PEditDownClick(Sender: TObject);
0116:       procedure opm_BitBtn_PEditStopDownClick(Sender: TObject);
0117:       procedure opm_BitBtn_PEditDeleteImgClick(Sender: TObject);
0118:       procedure opm_BitBtn_PEditUploadImgClick(Sender: TObject);
0119:       procedure FormClose(Sender: TObject; var Action: TCloseAction);
0120:       procedure opm_BitBtn_PEditSelectImgClick(Sender: TObject);
0121:       procedure opm_PopMenuItem_HideUploadDebugClick(Sender: TObject);
0122:       procedure opm_TabControl_PEditChange(Sender: TObject);
0123:       procedure opm_TabControl_PEditChanging(Sender: TObject; var AllowChange: Boolean);
0124:       procedure opm_BitBtn_PEditStripHTMLClick(Sender: TObject);
0125:       procedure opm_ComboBox_PEditTaxChange(Sender: TObject);
0126:       procedure opm_Edit_PEditPriceChange(Sender: TObject);
0127:       procedure opm_Edit_PEditPriceTaxedChange(Sender: TObject);
0128:       procedure opm_Edit_PEditPriceTaxedExit(Sender: TObject);
0129:       procedure opm_Edit_PEditPriceTaxedEnter(Sender: TObject);
0130:       procedure opm_Edit_PEditPriceEnter(Sender: TObject);
0131:       procedure opm_Edit_PEditPriceExit(Sender: TObject);
0132:       procedure opm_Edit_PeditImageURLExit(Sender: TObject);
0133:       procedure opm_BitBtn_PEditUnlinkImgClick(Sender: TObject);
0134:       PROCEDURE opm_Control_SetChange (Sender: TObject);
0135:       procedure opm_Image_Pedit0Click(Sender: TObject);
0136:       procedure opm_Image_Pedit1Click(Sender: TObject);
0137:       procedure opm_Image_Pedit2Click(Sender: TObject);
0138:       procedure opm_Image_Pedit3Click(Sender: TObject);
0139:       procedure opm_Image_Pedit4Click(Sender: TObject);
0140:       procedure opm_Image_Pedit5Click(Sender: TObject);
0141:       procedure opm_Image_Pedit6Click(Sender: TObject);
0142:       procedure opm_Image_Pedit0DblClick(Sender: TObject);
0143:       procedure opm_Image_Pedit1DblClick(Sender: TObject);
0144:       procedure opm_Image_Pedit2DblClick(Sender: TObject);
0145:       procedure opm_Image_Pedit3DblClick(Sender: TObject);
0146:       procedure opm_Image_Pedit4DblClick(Sender: TObject);
0147:       procedure opm_Image_Pedit5DblClick(Sender: TObject);
0148:       procedure opm_Image_Pedit6DblClick(Sender: TObject);
0149:       procedure opm_BitBtn_PEditDownAllClick(Sender: TObject);
0150:       procedure opm_Image_Pedit0DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
0151:       procedure opm_Image_Pedit0MouseDown(Sender: TObject;
0152:         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
0153:       procedure opm_Image_Pedit0DragDrop(Sender, Source: TObject; X,
0154:         Y: Integer);
0155:       procedure opm_ScrollBox_PeditImageEnter(Sender: TObject);
0156:       procedure opm_ScrollBox_PeditImageExit(Sender: TObject);
0157:       procedure opm_SpeedButton_ClearImgCacheClick(Sender: TObject);
0158:     private
0159:       PROCEDURE opm_PRDownload_Image (ImgURL : STRING; ImageIdx : WORD);
0160:       PROCEDURE opm_PRSetControls (ImageName : STRING; ImageState : WORD; ClearThumb: BOOLEAN; ImageIdx : WORD);
0161:       PROCEDURE opm_PRPrepareUpload (ImageFile, NewName, ImgSubdir : STRING; ImageJPEG : BOOLEAN);
0162:       FUNCTION opm_FNCleanURL (ProductURL : STRING) : STRING;
0163:       FUNCTION FNopm_GetTax (VAR TaxList : opmT_TaxList; TaxID : LONGINT; SearchBy : INTEGER) : opmR_Tax;
0164:       PROCEDURE opm_PRSetModified (IsModified: BOOLEAN);
0165:       PROCEDURE opm_PRToggle_ImgSel (ImgSel, LastSel : LONGINT);
0166:       procedure opm_AutoDownload (var DownloadMsg: TMessage); message OPM_AUTODOWNLOADIMG;
0167:       procedure opm_GetDropFiles (var DropingMsg: TWMDropFiles); message WM_DROPFILES;
0168:       procedure opm_InterceptKeys (var KeyPressMsg: TCMDialogKey); message CM_DIALOGKEY;
0169:       PROCEDURE opm_PRCenterImage (SelectedPanel : TPanel);
0170:     public
0171:       ProductModified : BOOLEAN;
0172:     end;
0173:   
0174:   var
0175:     opm_Form_PEdit: Topm_Form_PEdit;
0176:     opm_PEdit_CanZoom : ARRAY [0..6] OF BOOLEAN;
0177:     opm_CurrentImage : ARRAY [0..6] OF STRING;
0178:     opm_PEdit_ImageExist : ARRAY [0..6] OF LONGINT;
0179:     opm_CurrentImageIdx : LONGINT;
0180:     opm_PEdit_CanClose : BOOLEAN;
0181:     opm_PEdit_CalcNewTax : BOOLEAN;
0182:     opm_PEdit_CalcTaxed : BOOLEAN;
0183:     opm_PEdit_CalcUnTaxed : BOOLEAN;
0184:     opm_PEdit_CursorPos : opmT_CurPosDescList;
0185:     opm_PEdit_ImageData : ARRAY [0..6] OF STRING;
0186:     opm_PEdit_ImageETA : ARRAY [0..6] OF STRING;
0187:   
0188:   implementation
0189:   
0190:   {$R *.dfm}
0191:   
0192:   uses gnugettext, main, pimgzoom, balloons, dataman, attention, imageman,
0193:        askupload, askuser, regconfig, network, progress;
0194:   
0195:   
0196:   
0197:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0198:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0199:   PROCEDURE Topm_Form_PEdit.opm_PRSetControls (ImageName : STRING; ImageState : WORD; ClearThumb: BOOLEAN; ImageIdx : WORD);
0200:   BEGIN
0201:   {=========================================
0202:   NOTE: Why not use FindComponent?
0203:         These "CASE x OF 1,2,3,4,5,6" statements look ugly but are fast.
0204:         FindComponent looks cool but is very slow.
0205:         Too slow for interactive use.
0206:   ==========================================}
0207:     CASE ImageIdx OF
0208:       0 : opm_Panel_PeditImage0.Caption := ImageName;
0209:       1 : opm_Panel_PeditImage1.Caption := ImageName;
0210:       2 : opm_Panel_PeditImage2.Caption := ImageName;
0211:       3 : opm_Panel_PeditImage3.Caption := ImageName;
0212:       4 : opm_Panel_PeditImage4.Caption := ImageName;
0213:       5 : opm_Panel_PeditImage5.Caption := ImageName;
0214:       6 : opm_Panel_PeditImage6.Caption := ImageName;
0215:     END;
0216:     opm_StaticText_PeditImageURL.Caption := ImageName;
0217:     opm_Edit_PeditImageURL.Text := ImageName;
0218:     IF (ClearThumb = TRUE) THEN
0219:       BEGIN
0220:         CASE ImageIdx OF
0221:           0 : opm_Image_Pedit0.Picture := NIL;
0222:           1 : opm_Image_Pedit1.Picture := NIL;
0223:           2 : opm_Image_Pedit2.Picture := NIL;
0224:           3 : opm_Image_Pedit3.Picture := NIL;
0225:           4 : opm_Image_Pedit4.Picture := NIL;
0226:           5 : opm_Image_Pedit5.Picture := NIL;
0227:           6 : opm_Image_Pedit6.Picture := NIL;
0228:         END;
0229:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := NIL;
0230:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := '';
0231:       END;
0232:     IF (ImageName = '') THEN ImageState := opmC_ImageIsEmpty;
0233:     opm_PEdit_ImageExist[ImageIdx] := ImageState;
0234:     opm_StaticText_PeditImageData.Caption := opm_PEdit_ImageData[ImageIdx];
0235:     opm_StaticText_PeditImageETA.Caption := opm_PEdit_ImageETA[ImageIdx];
0236:     CASE ImageState OF
0237:       opmC_ImageDontExist :
0238:         BEGIN
0239:           opm_PEdit_CanZoom[ImageIdx] := FALSE;
0240:           CASE ImageIdx OF
0241:             0 : BEGIN
0242:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit0.Picture.Bitmap);
0243:                   opm_Image_Pedit0.Cursor := crDefault;
0244:                   opm_Image_Pedit0.Hint := '';
0245:                 END;
0246:             1 : BEGIN
0247:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit1.Picture.Bitmap);
0248:                   opm_Image_Pedit1.Cursor := crDefault;
0249:                   opm_Image_Pedit1.Hint := '';
0250:                 END;
0251:             2 : BEGIN
0252:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit2.Picture.Bitmap);
0253:                   opm_Image_Pedit2.Cursor := crDefault;
0254:                   opm_Image_Pedit2.Hint := '';
0255:                 END;
0256:             3 : BEGIN
0257:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit3.Picture.Bitmap);
0258:                   opm_Image_Pedit3.Cursor := crDefault;
0259:                   opm_Image_Pedit3.Hint := '';
0260:                 END;
0261:             4 : BEGIN
0262:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit4.Picture.Bitmap);
0263:                   opm_Image_Pedit4.Cursor := crDefault;
0264:                   opm_Image_Pedit4.Hint := '';
0265:                 END;
0266:             5 : BEGIN
0267:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit5.Picture.Bitmap);
0268:                   opm_Image_Pedit5.Cursor := crDefault;
0269:                   opm_Image_Pedit5.Hint := '';
0270:                 END;
0271:             6 : BEGIN
0272:                   opm_ImageList_PImg.GetBitmap (2, opm_Image_Pedit6.Picture.Bitmap);
0273:                   opm_Image_Pedit6.Cursor := crDefault;
0274:                   opm_Image_Pedit6.Hint := '';
0275:                 END;
0276:           END;
0277:           opm_BitBtn_PEditDown.Enabled := TRUE;
0278:           opm_BitBtn_PEditDeleteImg.Enabled := TRUE;
0279:           opm_BitBtn_PEditUnlinkImg.Enabled := TRUE;
0280:           opm_BitBtn_PEditUploadImg.Enabled := FALSE;
0281:           opm_BitBtn_PEditSelectImg.Enabled := FALSE;
0282:         END;
0283:       opmC_ImageMayExist :
0284:         BEGIN
0285:           opm_PEdit_CanZoom[ImageIdx] := FALSE;
0286:           CASE ImageIdx OF
0287:             0 : opm_Image_Pedit0.Cursor := crDefault;
0288:             1 : opm_Image_Pedit1.Cursor := crDefault;
0289:             2 : opm_Image_Pedit2.Cursor := crDefault;
0290:             3 : opm_Image_Pedit3.Cursor := crDefault;
0291:             4 : opm_Image_Pedit4.Cursor := crDefault;
0292:             5 : opm_Image_Pedit5.Cursor := crDefault;
0293:             6 : opm_Image_Pedit6.Cursor := crDefault;
0294:           END;
0295:           opm_BitBtn_PEditDown.Enabled := TRUE;
0296:           opm_BitBtn_PEditDeleteImg.Enabled := TRUE;
0297:           opm_BitBtn_PEditUnlinkImg.Enabled := TRUE;
0298:           opm_BitBtn_PEditUploadImg.Enabled := FALSE;
0299:           opm_BitBtn_PEditSelectImg.Enabled := FALSE;
0300:         END;
0301:       opmC_ImageExists :
0302:         BEGIN
0303:           opm_PEdit_CanZoom[ImageIdx] := TRUE;
0304:           CASE ImageIdx OF
0305:             0 : opm_Image_Pedit0.Cursor := crHandPoint;
0306:             1 : opm_Image_Pedit1.Cursor := crHandPoint;
0307:             2 : opm_Image_Pedit2.Cursor := crHandPoint;
0308:             3 : opm_Image_Pedit3.Cursor := crHandPoint;
0309:             4 : opm_Image_Pedit4.Cursor := crHandPoint;
0310:             5 : opm_Image_Pedit5.Cursor := crHandPoint;
0311:             6 : opm_Image_Pedit6.Cursor := crHandPoint;
0312:           END;
0313:           opm_BitBtn_PEditDown.Enabled := TRUE;
0314:           opm_BitBtn_PEditDeleteImg.Enabled := TRUE;
0315:           opm_BitBtn_PEditUnlinkImg.Enabled := TRUE;
0316:           opm_BitBtn_PEditUploadImg.Enabled := FALSE;
0317:           opm_BitBtn_PEditSelectImg.Enabled := FALSE;
0318:         END;
0319:       opmC_ImageIsEmpty :
0320:         BEGIN
0321:           opm_PEdit_CanZoom[ImageIdx] := FALSE;
0322:           CASE ImageIdx OF
0323:             0 : BEGIN
0324:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit0.Picture.Bitmap);
0325:                   opm_Image_Pedit0.Cursor := crDefault;
0326:                   opm_Image_Pedit0.Hint := '';
0327:                 END;
0328:             1 : BEGIN
0329:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit1.Picture.Bitmap);
0330:                   opm_Image_Pedit1.Cursor := crDefault;
0331:                   opm_Image_Pedit1.Hint := '';
0332:                 END;
0333:             2 : BEGIN
0334:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit2.Picture.Bitmap);
0335:                   opm_Image_Pedit2.Cursor := crDefault;
0336:                   opm_Image_Pedit2.Hint := '';
0337:                 END;
0338:             3 : BEGIN
0339:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit3.Picture.Bitmap);
0340:                   opm_Image_Pedit3.Cursor := crDefault;
0341:                   opm_Image_Pedit3.Hint := '';
0342:                 END;
0343:             4 : BEGIN
0344:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit4.Picture.Bitmap);
0345:                   opm_Image_Pedit4.Cursor := crDefault;
0346:                   opm_Image_Pedit4.Hint := '';
0347:                 END;
0348:             5 : BEGIN
0349:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit5.Picture.Bitmap);
0350:                   opm_Image_Pedit5.Cursor := crDefault;
0351:                   opm_Image_Pedit5.Hint := '';
0352:                 END;
0353:             6 : BEGIN
0354:                   opm_ImageList_PImg.GetBitmap (0, opm_Image_Pedit6.Picture.Bitmap);
0355:                   opm_Image_Pedit6.Cursor := crDefault;
0356:                   opm_Image_Pedit6.Hint := '';
0357:                 END;
0358:           END;
0359:           opm_BitBtn_PEditDown.Enabled := FALSE;
0360:           opm_BitBtn_PEditDeleteImg.Enabled := FALSE;
0361:           opm_BitBtn_PEditUnlinkImg.Enabled := FALSE;
0362:           opm_BitBtn_PEditUploadImg.Enabled := TRUE;
0363:           opm_BitBtn_PEditSelectImg.Enabled := TRUE;
0364:         END;
0365:       opmC_ImageIsCorrupt :
0366:         BEGIN
0367:           opm_PEdit_CanZoom[ImageIdx] := FALSE;
0368:           CASE ImageIdx OF
0369:             0 : BEGIN
0370:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit0.Picture.Bitmap);
0371:                   opm_Image_Pedit0.Cursor := crDefault;
0372:                   opm_Image_Pedit0.Hint := '';
0373:                 END;
0374:             1 : BEGIN
0375:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit1.Picture.Bitmap);
0376:                   opm_Image_Pedit1.Cursor := crDefault;
0377:                   opm_Image_Pedit1.Hint := '';
0378:                 END;
0379:             2 : BEGIN
0380:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit2.Picture.Bitmap);
0381:                   opm_Image_Pedit2.Cursor := crDefault;
0382:                   opm_Image_Pedit2.Hint := '';
0383:                 END;
0384:             3 : BEGIN
0385:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit3.Picture.Bitmap);
0386:                   opm_Image_Pedit3.Cursor := crDefault;
0387:                   opm_Image_Pedit3.Hint := '';
0388:                 END;
0389:             4 : BEGIN
0390:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit4.Picture.Bitmap);
0391:                   opm_Image_Pedit4.Cursor := crDefault;
0392:                   opm_Image_Pedit4.Hint := '';
0393:                 END;
0394:             5 : BEGIN
0395:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit5.Picture.Bitmap);
0396:                   opm_Image_Pedit5.Cursor := crDefault;
0397:                   opm_Image_Pedit5.Hint := '';
0398:                 END;
0399:             6 : BEGIN
0400:                   opm_ImageList_PImg.GetBitmap (1, opm_Image_Pedit6.Picture.Bitmap);
0401:                   opm_Image_Pedit6.Cursor := crDefault;
0402:                   opm_Image_Pedit6.Hint := '';
0403:                 END;
0404:           END;
0405:           opm_BitBtn_PEditDown.Enabled := TRUE;
0406:           opm_BitBtn_PEditDeleteImg.Enabled := TRUE;
0407:           opm_BitBtn_PEditUnlinkImg.Enabled := TRUE;
0408:           opm_BitBtn_PEditUploadImg.Enabled := FALSE;
0409:           opm_BitBtn_PEditSelectImg.Enabled := FALSE;
0410:         END;
0411:       opmC_ImageIsBeingProcessed :
0412:         BEGIN
0413:           opm_PEdit_CanZoom[ImageIdx] := FALSE;
0414:           CASE ImageIdx OF
0415:             0 : opm_Image_Pedit0.Cursor := crDefault;
0416:             1 : opm_Image_Pedit1.Cursor := crDefault;
0417:             2 : opm_Image_Pedit2.Cursor := crDefault;
0418:             3 : opm_Image_Pedit3.Cursor := crDefault;
0419:             4 : opm_Image_Pedit4.Cursor := crDefault;
0420:             5 : opm_Image_Pedit5.Cursor := crDefault;
0421:             6 : opm_Image_Pedit6.Cursor := crDefault;
0422:           END;
0423:           opm_BitBtn_PEditDown.Enabled := FALSE;
0424:           opm_BitBtn_PEditDeleteImg.Enabled := FALSE;
0425:           opm_BitBtn_PEditUnlinkImg.Enabled := FALSE;
0426:           opm_BitBtn_PEditUploadImg.Enabled := FALSE;
0427:           opm_BitBtn_PEditSelectImg.Enabled := FALSE;
0428:         END;
0429:     END;
0430:     IF (opmG_WBUploadURL = '') THEN
0431:       BEGIN
0432:         opm_BitBtn_PEditDeleteImg.Enabled := FALSE;
0433:         opm_BitBtn_PEditUploadImg.Enabled := FALSE;
0434:         opm_BitBtn_PEditSelectImg.Enabled := FALSE;
0435:       END;
0436:   END;
0437:   
0438:   
0439:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0440:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0441:   PROCEDURE Topm_Form_PEdit.opm_PRToggle_ImgSel (ImgSel, LastSel : LONGINT);
0442:   BEGIN
0443:   {=========================================
0444:   NOTE: Why not use FindComponent?
0445:         These "CASE x OF 1,2,3,4,5,6" statements look ugly but are fast.
0446:         FindComponent looks cool but is very slow.
0447:         Too slow for interactive use.
0448:   ==========================================}
0449:     IF (opmG_Capa_MorePics6 = TRUE) THEN
0450:       BEGIN
0451:         CASE LastSel OF
0452:           0 : opm_Panel_PeditImage0.Color := clBtnFace;
0453:           1 : opm_Panel_PeditImage1.Color := clBtnFace;
0454:           2 : opm_Panel_PeditImage2.Color := clBtnFace;
0455:           3 : opm_Panel_PeditImage3.Color := clBtnFace;
0456:           4 : opm_Panel_PeditImage4.Color := clBtnFace;
0457:           5 : opm_Panel_PeditImage5.Color := clBtnFace;
0458:           6 : opm_Panel_PeditImage6.Color := clBtnFace;
0459:         END;
0460:         CASE ImgSel OF
0461:           0 : opm_Panel_PeditImage0.Color := clBtnHighlight;
0462:           1 : opm_Panel_PeditImage1.Color := clBtnHighlight;
0463:           2 : opm_Panel_PeditImage2.Color := clBtnHighlight;
0464:           3 : opm_Panel_PeditImage3.Color := clBtnHighlight;
0465:           4 : opm_Panel_PeditImage4.Color := clBtnHighlight;
0466:           5 : opm_Panel_PeditImage5.Color := clBtnHighlight;
0467:           6 : opm_Panel_PeditImage6.Color := clBtnHighlight;
0468:         END;
0469:       END;
0470:   END;
0471:   
0472:   
0473:   
0474:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0475:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0476:   procedure Topm_Form_PEdit.FormShow(Sender: TObject);
0477:   VAR
0478:     CurLang : LONGINT;
0479:     DisplayTabIndex : LONGINT;
0480:     CurCat : opmR_Category;
0481:     CurImg : LONGINT;
0482:   begin
0483:     opm_PEdit_CalcNewTax := FALSE;
0484:     opm_PEdit_CalcTaxed := FALSE;
0485:     opm_PEdit_CalcUnTaxed := FALSE;
0486:     opm_Form_PEdit.Caption := opm_CurrentProdRecord.DisplayName;
0487:     opm_Edit_PEditModel.Text := opm_CurrentProdRecord.Model;
0488:     opm_ComboBox_PEditMan.Items := opmG_ManufacturerBoxList;
0489:     opm_ComboBox_PEditTax.Items := opmG_TaxBoxList;
0490:     opm_CurrentManRecord := opm_Form_Main.FNopm_GetManufacturer (opmG_ManufacturerList, opm_CurrentProdRecord.ManufacturerID, opmC_FindByID);
0491:     opm_ComboBox_PEditMan.ItemIndex := opm_CurrentManRecord.ListIndex;
0492:     opm_CurrentTaxRecord := FNopm_GetTax (opmG_TaxList, opm_CurrentProdRecord.Tax, opmC_FindByID);
0493:     opm_ComboBox_PEditTax.ItemIndex := opm_CurrentTaxRecord.ListIndex;
0494:     opm_ComboBox_PEditCat.Items := opmG_CategoryBoxList;
0495:     CurCat := opm_Form_Main.FNopm_GetCategory (opmG_CategoryList, opm_CurrentProdRecord.CategoryID, opmC_FindByID);
0496:     opm_ComboBox_PEditCat.ItemIndex := CurCat.ListIndex;
0497:     opm_Edit_PEditQuantity.Text := INTTOSTR (opm_CurrentProdRecord.Quantity);
0498:     opm_Edit_PEditPrice.Text := CURRTOSTR (opm_CurrentProdRecord.Price);
0499:     opm_Edit_PEditPriceTaxed.Text := FNopm_AfterTaxPrice (opm_Edit_PEditPrice.Text, opm_CurrentTaxRecord.SumRate);
0500:     opm_Edit_PEditSpecial.Text := CURRTOSTR (opm_CurrentProdRecord.Special);
0501:     opm_Edit_PEditWeight.Text := CURRTOSTR (opm_CurrentProdRecord.Weight);
0502:     IF (opmG_UIAutoDownImg = 0) THEN opm_PageControl_PEdit.ActivePageIndex := 0 ELSE opm_PageControl_PEdit.ActivePageIndex := (opm_PageControl_PEdit.PageCount - 1);
0503:     opm_TabControl_PEdit.Tabs.Clear;
0504:     opm_TabControl_PEdit.Tabs := opmG_LanguageBoxList;
0505:     DisplayTabIndex := opmC_Def_DisplayLang;
0506:     FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
0507:       IF (opm_CurrentLang = opmG_LanguageList[CurLang].ID) THEN DisplayTabIndex := CurLang;
0508:     opm_TabControl_PEdit.TabIndex := DisplayTabIndex;
0509:     opm_CheckBox_PEditAvailable.Checked := (opm_CurrentProdRecord.Available > 0);
0510:     opm_StaticText_PeditCDate.Caption := FNopm_DateToString (opm_CurrentProdRecord.CreationDate);
0511:     opm_StaticText_PeditMDate.Caption := FNopm_DateToString (opm_CurrentProdRecord.ChangeDate);
0512:     opm_DateTimePicker_PEditAvailDate.DateTime := opm_CurrentProdRecord.AvailDate;
0513:     opm_StaticText_PeditCurr1.Caption := opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right;
0514:     opm_StaticText_PeditCurr2.Caption := opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right;
0515:     opm_StaticText_PeditCurr3.Caption := opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right;
0516:     opm_Edit_PEditName.Text := opm_CurrentSingleDescList[DisplayTabIndex].Name;
0517:     opm_Edit_PEditURL.Text := opm_FNCleanURL (opm_CurrentSingleDescList[DisplayTabIndex].URL);
0518:     opm_StaticText_PeditViewed.Caption := INTTOSTR (opm_CurrentSingleDescList[DisplayTabIndex].Viewed);
0519:     opm_Memo_PEditDescription.Lines.Text := opm_CurrentSingleDescList[DisplayTabIndex].Description;
0520:     opm_Memo_PEditDescription.SelStart := 0;
0521:     FOR DisplayTabIndex := 0 TO opmC_Max_Languages_PerList DO
0522:       opm_PEdit_CursorPos[DisplayTabIndex] := 0;
0523:     opm_BitBtn_PEditStopDown.Visible := FALSE;
0524:     opm_BitBtn_PEditStopDown.Enabled := FALSE;
0525:     opm_StaticText_PeditImageURL.Visible := NOT (opmG_UIAllowEditImageName > 0);
0526:     opm_StaticText_PeditImageURL.Enabled := NOT (opmG_UIAllowEditImageName > 0);
0527:     opm_SpeedButton_ClearImgCache.Visible := (opmG_UICacheIList > 0);
0528:     opm_SpeedButton_ClearImgCache.Enabled := (opmG_UICacheIList > 0);
0529:     opm_Edit_PeditImageURL.Visible := (opmG_UIAllowEditImageName > 0);
0530:     opm_Edit_PeditImageURL.Enabled := (opmG_UIAllowEditImageName > 0);
0531:     opm_BitBtn_PEditDownAll.Visible := opmG_Capa_MorePics6;
0532:     opm_BitBtn_PEditDownAll.Enabled := opmG_Capa_MorePics6;
0533:     opm_Memo_UploadDEBUG.Clear;
0534:     opm_CurrentImage[0] := opm_CurrentProdRecord.ImageURL;
0535:     opm_CurrentImage[1] := opm_CurrentProdRecord.ImageURL1;
0536:     opm_CurrentImage[2] := opm_CurrentProdRecord.ImageURL2;
0537:     opm_CurrentImage[3] := opm_CurrentProdRecord.ImageURL3;
0538:     opm_CurrentImage[4] := opm_CurrentProdRecord.ImageURL4;
0539:     opm_CurrentImage[5] := opm_CurrentProdRecord.ImageURL5;
0540:     opm_CurrentImage[6] := opm_CurrentProdRecord.ImageURL6;
0541:     opm_ScrollBox_PeditImage.HorzScrollBar.Position := 0;
0542:     opm_ScrollBox_PeditImage.VertScrollBar.Position := 0;
0543:     opm_Panel_PeditImage1.Visible := opmG_Capa_MorePics6;
0544:     opm_Panel_PeditImage2.Visible := opmG_Capa_MorePics6;
0545:     opm_Panel_PeditImage3.Visible := opmG_Capa_MorePics6;
0546:     opm_Panel_PeditImage4.Visible := opmG_Capa_MorePics6;
0547:     opm_Panel_PeditImage5.Visible := opmG_Capa_MorePics6;
0548:     opm_Panel_PeditImage6.Visible := opmG_Capa_MorePics6;
0549:     FOR CurImg := 6 DOWNTO 0 DO
0550:       BEGIN
0551:         opm_PEdit_ImageData[CurImg] := '';
0552:         opm_PEdit_ImageETA[CurImg] := '';
0553:         opm_PRSetControls (opm_CurrentImage[CurImg], opmC_ImageMayExist, TRUE, CurImg);
0554:         opm_PRToggle_ImgSel (-1, CurImg);
0555:       END;
0556:     opm_CurrentImageIdx := 0;
0557:     opm_PRToggle_ImgSel (opm_CurrentImageIdx, -1);
0558:     opm_PRSetModified (FALSE);
0559:     opm_PEdit_CanClose := TRUE;
0560:     PRopm_Prepare_HTTPClient (opm_Form_Progress.opm_ProgressBar_Progress2, opm_Form_Progress.opm_Label_ProgressMsg2, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
0561:     DragAcceptFiles (Handle, (opmG_UIImgDragDrop > 0));
0562:     opm_PEdit_CalcNewTax := TRUE;
0563:     IF (opmG_UIAutoDownImg > 0) THEN PostMessage (Handle, OPM_AUTODOWNLOADIMG, 0, LONGINT (Sender));
0564:   end;
0565:   
0566:   
0567:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0568:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0569:   procedure Topm_Form_PEdit.opm_BitBtn_PEditOkClick(Sender: TObject);
0570:   VAR
0571:     CurMan : opmR_Manufacturer;
0572:     CurCat : opmR_Category;
0573:     CurTax : opmR_Tax;
0574:     CurLang : LONGINT;
0575:   begin
0576:     opm_CurrentPEditRecord.ID := opm_CurrentProdRecord.ID;
0577:     opm_CurrentPEditRecord.Model := FNopm_CleanString (opm_Edit_PEditModel.Text);
0578:     opm_CurrentPEditRecord.Quantity := FNopm_StrToInt (opm_Edit_PEditQuantity.Text);
0579:     CurMan := opm_Form_Main.FNopm_GetManufacturer (opmG_ManufacturerList, opm_ComboBox_PEditMan.ItemIndex, opmC_FindByIndex);
0580:     opm_CurrentPEditRecord.ManufacturerID := CurMan.ID;
0581:     CurTax := FNopm_GetTax (opmG_TaxList, opm_ComboBox_PEditTax.ItemIndex, opmC_FindByIndex);
0582:     opm_CurrentPEditRecord.Tax := CurTax.ID;
0583:     CurCat := opm_Form_Main.FNopm_GetCategory (opmG_CategoryList, opm_ComboBox_PEditCat.ItemIndex, opmC_FindByIndex);
0584:     opm_CurrentPEditRecord.CategoryID := CurCat.ID;
0585:     opm_CurrentPEditRecord.Price := ABS (STRTOCURR (FNopm_CleanNumber (opm_Edit_PEditPrice.Text, opmC_ValIsCurrency)));
0586:     opm_CurrentPEditRecord.Special := ABS (STRTOCURR (FNopm_CleanNumber (opm_Edit_PEditSpecial.Text, opmC_ValIsCurrency)));
0587:     opm_CurrentPEditRecord.Weight := ABS (STRTOCURR (FNopm_CleanNumber (opm_Edit_PEditWeight.Text, opmC_ValIsCurrency)));
0588:     opm_CurrentPEditRecord.DisplayName := FNopm_CleanString (opm_Edit_PEditName.Text);
0589:     opm_CurrentPEditRecord.ImageURL := opm_CurrentImage[0];
0590:     opm_CurrentPEditRecord.ImageURL1 := opm_CurrentImage[1];
0591:     opm_CurrentPEditRecord.ImageURL2 := opm_CurrentImage[2];
0592:     opm_CurrentPEditRecord.ImageURL3 := opm_CurrentImage[3];
0593:     opm_CurrentPEditRecord.ImageURL4 := opm_CurrentImage[4];
0594:     opm_CurrentPEditRecord.ImageURL5 := opm_CurrentImage[5];
0595:     opm_CurrentPEditRecord.ImageURL6 := opm_CurrentImage[6];
0596:     opm_CurrentPEditRecord.LanguageID := opm_CurrentLang;
0597:     opm_CurrentPEditRecord.AvailDate := opm_DateTimePicker_PEditAvailDate.DateTime;
0598:     IF (opm_CheckBox_PEditAvailable.Checked = TRUE) THEN opm_CurrentPEditRecord.Available := 1 ELSE opm_CurrentPEditRecord.Available := 0;
0599:     opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name := FNopm_CleanString (opm_Edit_PEditName.Text);
0600:     opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL := opm_FNCleanURL (opm_Edit_PEditURL.Text);
0601:     opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description := FNopm_CleanString (opm_Memo_PEditDescription.Lines.Text);
0602:     FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
0603:       IF (opm_CurrentSingleDescList[CurLang].ID > 0) THEN
0604:         BEGIN
0605:           IF (opm_CurrentSingleDescList[CurLang].Name = '') THEN
0606:             BEGIN
0607:               opm_PageControl_PEdit.ActivePageIndex := 1;
0608:               opm_Form_PEdit.FocusControl (opm_Edit_PEditName);
0609:               FNopm_Message (_('The name of the product is missing.'), mtWarning, [mbOk], opmG_UISilent);
0610:               ModalResult := mrNone;
0611:               BREAK;
0612:             END;
0613:         END;
0614:     IF ((opm_CurrentPEditRecord.Quantity < 0) AND (opmG_UIAllowNegativeQuantity = 0)) THEN
0615:       BEGIN
0616:         opm_PageControl_PEdit.ActivePageIndex := 0;
0617:         opm_Form_PEdit.FocusControl (opm_Edit_PEditQuantity);
0618:         FNopm_Message (_('The quantity of the product cannot be negative.'), mtWarning, [mbOk], opmG_UISilent);
0619:         ModalResult := mrNone;
0620:       END
0621:     ELSE IF (opm_CurrentPEditRecord.Price < 0) OR ((opm_CurrentPEditRecord.Price = 0) AND (opmG_UIAllowZeroPrice = 0)) THEN
0622:       BEGIN
0623:         opm_PageControl_PEdit.ActivePageIndex := 0;
0624:         opm_Form_PEdit.FocusControl (opm_Edit_PEditPrice);
0625:         FNopm_Message (_('The price of the product is missing.'), mtWarning, [mbOk], opmG_UISilent);
0626:         ModalResult := mrNone;
0627:       END;
0628:     opm_PEdit_CanClose := TRUE;
0629:   END;
0630:   
0631:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0632:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0633:   procedure Topm_Form_PEdit.FormCreate(Sender: TObject);
0634:   begin
0635:     opm_Form_PEdit.Constraints.MinWidth := opmC_MinPWindow_XSize;
0636:     opm_Form_PEdit.Constraints.MinHeight := opmC_MinPWindow_YSize;
0637:     opm_Form_PEdit.Constraints.MaxWidth := opmC_MaxPWindow_XSize;
0638:     opm_Form_PEdit.Constraints.MaxHeight := opmC_MaxPWindow_YSize;
0639:     opm_Form_PEdit.Width := opmC_DefPWindow_XSize;
0640:     opm_Form_PEdit.Height := opmC_DefPWindow_YSize;
0641:     opm_Edit_PEditModel.MaxLength := opmC_ProdModel_MaxLen;
0642:     opm_Edit_PEditPrice.MaxLength := opmC_ProdPrice_MaxLen;
0643:     opm_Edit_PEditSpecial.MaxLength := opmC_ProdSpecial_MaxLen;
0644:     opm_Edit_PEditWeight.MaxLength := opmC_ProdWeight_MaxLen;
0645:     opm_Edit_PEditQuantity.MaxLength := opmC_ProdQuantity_MaxLen;
0646:     opm_Edit_PEditURL.MaxLength := opmC_ProdURL_MaxLen;
0647:     opm_Edit_PEditName.MaxLength := opmC_ProdName_MaxLen;
0648:     opm_Memo_PEditDescription.MaxLength := opmC_ProdDescription_MaxLen;
0649:     opm_DateTimePicker_PEditAvailDate.Date := opmC_Def_PDate;
0650:     opm_DateTimePicker_PEditAvailDate.MaxDate := opmC_Max_PDate;
0651:     opm_DateTimePicker_PEditAvailDate.MinDate := opmC_Min_PDate;
0652:     opm_DateTimePicker_PEditAvailDate.Format := opmC_PDate_Format;
0653:     opm_Panel_PeditImage0.DoubleBuffered := TRUE;
0654:     opm_Panel_PeditImage1.DoubleBuffered := TRUE;
0655:     opm_Panel_PeditImage2.DoubleBuffered := TRUE;
0656:     opm_Panel_PeditImage3.DoubleBuffered := TRUE;
0657:     opm_Panel_PeditImage4.DoubleBuffered := TRUE;
0658:     opm_Panel_PeditImage5.DoubleBuffered := TRUE;
0659:     opm_Panel_PeditImage6.DoubleBuffered := TRUE;
0660:     opm_PEdit_CanClose := TRUE;
0661:     ProductModified := FALSE;
0662:     IF (opmG_UIHotTracking > 0) THEN
0663:       BEGIN
0664:         opm_TabControl_PEdit.HotTrack := TRUE;
0665:         opm_PageControl_PEdit.HotTrack := TRUE;
0666:       END
0667:     ELSE
0668:       BEGIN
0669:         opm_TabControl_PEdit.HotTrack := FALSE;
0670:         opm_PageControl_PEdit.HotTrack := FALSE;
0671:       END;
0672:     IF (opmG_UIWBDebug > 0) THEN
0673:       BEGIN
0674:         opm_Memo_UploadDEBUG.Enabled := TRUE;
0675:         opm_Memo_UploadDEBUG.Visible := TRUE;
0676:       END
0677:     ELSE
0678:       BEGIN
0679:         opm_Memo_UploadDEBUG.Enabled := FALSE;
0680:         opm_Memo_UploadDEBUG.Visible := FALSE;
0681:         opm_Memo_UploadDEBUG.Clear;
0682:       END;
0683:     TranslateComponent (self);
0684:   end;
0685:   
0686:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0687:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0688:   procedure Topm_Form_PEdit.opm_BitBtn_PEditDownClick (Sender: TObject);
0689:   BEGIN
0690:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageMayExist, TRUE, opm_CurrentImageIdx);
0691:     IF (opm_CurrentImage[opm_CurrentImageIdx] <> '') THEN
0692:       BEGIN
0693:         opm_BitBtn_PEditDown.Enabled := FALSE;
0694:         opm_BitBtn_PEditStopDown.Visible := TRUE;
0695:         opm_BitBtn_PEditStopDown.Enabled := TRUE;
0696:         opm_PRDownload_Image (opm_CurrentImage[opm_CurrentImageIdx], opm_CurrentImageIdx);
0697:         opm_BitBtn_PEditDown.Enabled := TRUE;
0698:         opm_BitBtn_PEditStopDown.Visible := FALSE;
0699:         opm_BitBtn_PEditStopDown.Enabled := FALSE;
0700:       END;
0701:   end;
0702:   
0703:   
0704:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0705:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0706:   procedure Topm_Form_PEdit.opm_BitBtn_PEditStopDownClick(Sender: TObject);
0707:   begin
0708:     PRopm_Disconnect_HTTPClient;
0709:   end;
0710:   
0711:   
0712:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0713:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0714:   procedure Topm_Form_PEdit.opm_AutoDownload (var DownloadMsg: TMessage);
0715:   VAR
0716:     AvailImg : BOOLEAN;
0717:     CurImg : LONGINT;
0718:   begin
0719:     AvailImg := FALSE;
0720:     FOR CurImg := 0 TO 6 DO
0721:       IF (opm_CurrentImage[CurImg] <> '') THEN AvailImg := TRUE;
0722:     IF (AvailImg = TRUE) THEN
0723:       BEGIN
0724:         opm_BitBtn_PEditDown.Enabled := FALSE;
0725:         opm_BitBtn_PEditStopDown.Visible := TRUE;
0726:         opm_BitBtn_PEditStopDown.Enabled := TRUE;
0727:         FOR CurImg := 0 TO 6 DO
0728:           BEGIN
0729:             opm_PRSetControls (opm_CurrentImage[CurImg], opmC_ImageMayExist, TRUE, CurImg);
0730:             IF (opm_CurrentImage[CurImg] <> '') THEN
0731:               BEGIN
0732:                 opm_PRDownload_Image (opm_CurrentImage[CurImg], CurImg);
0733:               END;
0734:           END;
0735:         opm_BitBtn_PEditDown.Enabled := TRUE;
0736:         opm_BitBtn_PEditStopDown.Visible := FALSE;
0737:         opm_BitBtn_PEditStopDown.Enabled := FALSE;
0738:         opm_PRToggle_ImgSel (0, opm_CurrentImageIdx);
0739:         opm_CurrentImageIdx := 0;
0740:         opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
0741:       END;
0742:   end;
0743:   
0744:   
0745:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0746:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0747:   PROCEDURE Topm_Form_PEdit.opm_PRDownload_Image (ImgURL : STRING; ImageIdx : WORD);
0748:   VAR
0749:     FileStream : TFileStream;
0750:     ImgFileSize : LONGINT;
0751:   BEGIN
0752:     opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
0753:     opm_Form_Progress.PRopm_PDUpdate_Progress (30, 1, _('Downloading image...'));
0754:     IF (FNopm_Download_File (opmG_WBImgURL + ImgURL, opmG_TMPPath + opmC_TmpImg_Filename) = TRUE) THEN
0755:       TRY
0756:         opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Converting image...'));
0757:         IF (FNopm_ConvertImage2 (opmG_TMPPath + opmC_TmpImg_Filename, opmG_TMPPath + opmC_TmpBMP_Filename, opmC_BMPFormat, 0, '') = TRUE) THEN
0758:           BEGIN
0759:             CASE ImageIdx OF
0760:               0 : opm_Image_Pedit0.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0761:               1 : opm_Image_Pedit1.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0762:               2 : opm_Image_Pedit2.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0763:               3 : opm_Image_Pedit3.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0764:               4 : opm_Image_Pedit4.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0765:               5 : opm_Image_Pedit5.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0766:               6 : opm_Image_Pedit6.Picture.LoadFromFile (opmG_TMPPath + opmC_TmpBMP_Filename);
0767:             END;
0768:             TRY
0769:               FileStream := TFileStream.Create (opmG_TMPPath + opmC_TmpImg_Filename, fmOpenRead);
0770:               TRY
0771:                 ImgFileSize := FileStream.Size;
0772:               FINALLY
0773:                 FileStream.Free;
0774:               END;
0775:             EXCEPT
0776:               ImgFileSize := 0;
0777:             END;
0778:             opm_PEdit_ImageETA[ImageIdx] := INTTOSTR (ROUND (ImgFileSize / ((opmG_ETABase * 1024) / 8))) + ' ' + _('secs') + ' @' + FLOATTOSTR (opmG_ETABase) + _('kbps');
0779:             CASE ImageIdx OF
0780:               0 : BEGIN
0781:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit0.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit0.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0782:                     opm_Image_Pedit0.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0783:                   END;
0784:               1 : BEGIN
0785:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit1.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit1.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0786:                     opm_Image_Pedit1.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0787:                   END;
0788:               2 : BEGIN
0789:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit2.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit2.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0790:                     opm_Image_Pedit2.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0791:                   END;
0792:               3 : BEGIN
0793:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit3.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit3.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0794:                     opm_Image_Pedit3.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0795:                   END;
0796:               4 : BEGIN
0797:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit4.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit4.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0798:                     opm_Image_Pedit4.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0799:                   END;
0800:               5 : BEGIN
0801:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit5.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit5.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0802:                     opm_Image_Pedit5.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0803:                   END;
0804:               6 : BEGIN
0805:                     opm_PEdit_ImageData[ImageIdx] := INTTOSTR (opm_Image_Pedit6.Picture.Width) + 'x' + INTTOSTR (opm_Image_Pedit6.Picture.Height) + ', ' + INTTOSTR (ROUND (ImgFileSize / 1024)) + _('k');
0806:                     opm_Image_Pedit6.Hint := ImgURL + mvHint_Separator + opm_PEdit_ImageData[ImageIdx] + #13#10 + opm_PEdit_ImageETA[ImageIdx] + #13#10 + #13#10 + _('Double-click to show full-size image...');
0807:                   END;
0808:             END;
0809:             opm_StaticText_PeditImageData.Caption := opm_PEdit_ImageData[ImageIdx];
0810:             opm_StaticText_PeditImageETA.Caption := opm_PEdit_ImageETA[ImageIdx];
0811:             opm_PRSetControls (opm_CurrentImage[ImageIdx], opmC_ImageExists, FALSE, ImageIdx);
0812:           END
0813:         ELSE
0814:           BEGIN
0815:             opm_PRSetControls (opm_CurrentImage[ImageIdx], opmC_ImageIsCorrupt, TRUE, ImageIdx);
0816:           END;
0817:       EXCEPT
0818:         opm_PRSetControls (opm_CurrentImage[ImageIdx], opmC_ImageDontExist, TRUE, ImageIdx);
0819:       END
0820:     ELSE opm_PRSetControls (opm_CurrentImage[ImageIdx], opmC_ImageDontExist, TRUE, ImageIdx);
0821:     opm_Form_Progress.PRopm_PDClose;
0822:   END;
0823:   
0824:   
0825:   
0826:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0827:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0828:   procedure Topm_Form_PEdit.opm_BitBtn_PEditDeleteImgClick(Sender: TObject);
0829:   VAR
0830:     ResStr : STRING;
0831:     ResCode : LONGINT;
0832:   begin
0833:     opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
0834:     opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Deleting image...'));
0835:     ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'delete2', opm_CurrentImage[opm_CurrentImageIdx], ResStr);
0836:     IF (ResCode = 0) THEN
0837:       BEGIN
0838:         opm_PRSetModified (TRUE);
0839:         opm_PEdit_CanClose := FALSE;
0840:         opm_CurrentImage[opm_CurrentImageIdx] := '';
0841:         opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0842:       END
0843:     ELSE
0844:       BEGIN
0845:         opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageMayExist, TRUE, opm_CurrentImageIdx);
0846:         FNopm_Message (_('There was an error while deleting the file.') + #13#10 + FNopm_FullRemoteError (ResCode, opmC_DefErrorDataLen), mtError, [mbOk], opmG_UISilent);
0847:       END;
0848:     opm_Form_Progress.PRopm_PDClose;
0849:     opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0850:   end;
0851:   
0852:   
0853:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0854:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0855:   procedure Topm_Form_PEdit.opm_BitBtn_PEditUploadImgClick (Sender: TObject);
0856:   VAR
0857:     ImageJPEG : BOOLEAN;
0858:     ResStr : STRING;
0859:     ResCode : LONGINT;
0860:   begin
0861:     IF ((opmG_Cache_ImageDirList.Count < 1) OR (opmG_UICacheIList < 1)) THEN
0862:       BEGIN
0863:         opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
0864:         opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Getting list of directories...'));
0865:         ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'listdirs', '', ResStr);
0866:         IF (ResCode <> 0) THEN FNopm_Message (_('There was an error while downloading the image directory listing.') + #13#10 + FNopm_FullRemoteError (ResCode, opmC_DefErrorDataLen) + #13#10 + _('I will continue as normal.'), mtWarning, [mbOk], opmG_UISilent);
0867:         opm_Form_Progress.PRopm_PDClose;
0868:         opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0869:         opmG_Cache_ImageDirList.Text := ResStr;
0870:         IF (opmG_Cache_ImageDirList.Count > 1) THEN
0871:           BEGIN
0872:             opmG_Cache_ImageDirList.Delete (0);
0873:             opmG_Cache_ImageDirList.Delete (opmG_Cache_ImageDirList.Count - 1);
0874:             opmG_Cache_ImageDirList.Insert (0, '');
0875:           END
0876:         ELSE
0877:           BEGIN
0878:             opmG_Cache_ImageDirList.Clear;
0879:             opmG_Cache_ImageDirList.Add ('');
0880:           END;
0881:       END;
0882:     opm_Form_UploadImage.opm_ComboBox_UploadDir.Items.Text := opmG_Cache_ImageDirList.Text;
0883:     opm_Form_UploadImage.opm_ComboBox_UploadDir.ItemIndex := 0;
0884:     opm_Form_UploadImage.opm_ComboBox_UploadDir.Text := opmG_Past_PImageDir;
0885:     IF (opm_Form_UploadImage.ShowModal = mrOk) THEN
0886:       BEGIN
0887:         opmG_Past_PImageDir := opm_Form_UploadImage.opm_ComboBox_UploadDir.Text;
0888:         IF (opm_Form_UploadImage.opm_RadioGroup_UploadFormat.ItemIndex = 0) THEN ImageJPEG := TRUE ELSE ImageJPEG := FALSE;
0889:         opm_PRPrepareUpload (opm_Form_UploadImage.opm_Edit_UploadFileName.Text, opm_Form_UploadImage.opm_Edit_UploadNewName.Text,
0890:                              opm_Form_UploadImage.opm_ComboBox_UploadDir.Text, ImageJPEG);
0891:         IF (opmG_UIAutoDownImg > 0) THEN PostMessage (Handle, OPM_AUTODOWNLOADIMG, 0, LONGINT (Sender));
0892:       END;
0893:   end;
0894:   
0895:   
0896:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0897:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0898:   procedure Topm_Form_PEdit.opm_PRPrepareUpload (ImageFile, NewName, ImgSubdir : STRING; ImageJPEG : BOOLEAN);
0899:   VAR
0900:     ConvRes : BOOLEAN;
0901:     ResStr : STRING;
0902:     ResCode : LONGINT;
0903:     UploadResult : STRING;
0904:   begin
0905:     UploadResult := '';
0906:     opm_PRSetControls (ImageFile, opmC_ImageIsBeingProcessed, TRUE, opm_CurrentImageIdx);
0907:     IF ((ImageFile <> '') AND (NewName <> '')) THEN
0908:       BEGIN
0909:         opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
0910:         opm_Form_Progress.PRopm_PDUpdate_Progress (30, 1, _('Deleting old image...'));
0911:         ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'delete2', opm_CurrentImage[opm_CurrentImageIdx], ResStr);
0912:         IF ((opm_CurrentImage[opm_CurrentImageIdx] = '') OR (ResCode = 0)) THEN
0913:           BEGIN
0914:             ResCode := opmC_WebScriptDefaultCode;
0915:             opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0916:             opm_PRSetModified (TRUE);
0917:             opm_PEdit_CanClose := FALSE;
0918:             opm_Form_Progress.PRopm_PDUpdate_Progress (60, 1, _('Converting image...'));
0919:             IF (opmG_WBResizeImg > 0) THEN
0920:               ConvRes := FNopm_ResizeImage2 (ImageFile, opmG_TMPPath + opmC_TmpBMP_Filename, opmG_WBImgX, opmG_WBImgY, opmG_WBKeepARImg, opmG_WBPaddingImg, opmG_WBPaddingColor)
0921:             ELSE
0922:               ConvRes := FNopm_ConvertImage2 (ImageFile, opmG_TMPPath + opmC_TmpBMP_Filename, opmC_BMPFormat, 1, '');
0923:             IF (ConvRes = TRUE) THEN
0924:               BEGIN
0925:                 IF ((opmG_WBWatermarkImg > 0) AND (opmG_WBWatermarkFile <> '')) THEN
0926:                   IF (FNopm_WatermarkImage2 (opmG_WBWatermarkFile, opmG_TMPPath + opmC_TmpBMP_Filename, opmG_WBWatermarkBlend) = FALSE) THEN
0927:                     BEGIN
0928:                       FNopm_Message (_('There was an error while adding the watermark to the image file.'), mtError, [mbOk], opmG_UISilent);
0929:                     END;
0930:               END;
0931:             IF (ConvRes = TRUE) THEN
0932:               BEGIN
0933:                 IF (ImageJPEG = TRUE) THEN
0934:                   BEGIN
0935:                     ImageFile := opmG_TMPPath + opmC_TmpJPG_Filename;
0936:                     ConvRes := FNopm_ConvertImage2 (opmG_TMPPath + opmC_TmpBMP_Filename, ImageFile, opmC_JPEGFormat, opmG_WBImgQ, opmG_FullUserAgent)
0937:                   END
0938:                 ELSE
0939:                   BEGIN
0940:                     ImageFile := opmG_TMPPath + opmC_TmpPNG_Filename;
0941:                     ConvRes := FNopm_ConvertImage2 (opmG_TMPPath + opmC_TmpBMP_Filename, ImageFile, opmC_PNGFormat, 0, opmG_FullUserAgent);
0942:                   END;
0943:                 IF (ConvRes = TRUE) THEN
0944:                   BEGIN
0945:                     opm_Form_Progress.PRopm_PDUpdate_Progress (90, 1, _('Uploading image...'));
0946:                     ResCode := FNopm_Upload_File (opmG_WBUploadURL, ImageFile, NewName, ImgSubdir, UploadResult);
0947:                     opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0948:                   END;
0949:               END;
0950:             IF (ConvRes = TRUE) THEN
0951:               BEGIN
0952:                 IF ((UploadResult <> '') AND (ResCode = 0)) THEN
0953:                   BEGIN
0954:                     opm_CurrentImage[opm_CurrentImageIdx] := UploadResult;
0955:                     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageMayExist, TRUE, opm_CurrentImageIdx);
0956:                     opmG_Cache_ImageList.Clear;
0957:                     IF (ANSIPOS ('/', UploadResult) > 0) THEN
0958:                       BEGIN
0959:                         IF (opmG_Cache_ImageDirList.IndexOf (FNopm_ExtractFilePath (UploadResult, FALSE)) < 1) THEN
0960:                           opmG_Cache_ImageDirList.Clear;
0961:                       END;
0962:                   END
0963:                 ELSE
0964:                   BEGIN
0965:                     opm_CurrentImage[opm_CurrentImageIdx] := '';
0966:                     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0967:                     FNopm_Message (_('There was an error while uploading the file.') + #13#10 + FNopm_FullRemoteError (ResCode, opmC_DefErrorDataLen), mtError, [mbOk], opmG_UISilent);
0968:                   END;
0969:               END
0970:             ELSE
0971:               BEGIN
0972:                 FNopm_Message (_('There was an error while converting the image file.'), mtError, [mbOk], opmG_UISilent);
0973:               END;
0974:           END
0975:         ELSE
0976:           BEGIN
0977:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0978:             opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0979:             IF (ResCode <> 0) THEN FNopm_Message (_('There was an error while deleting the old image.') + #13#10 + FNopm_FullRemoteError (ResCode, opmC_DefErrorDataLen), mtError, [mbOk], opmG_UISilent);
0980:           END;
0981:         opm_Form_Progress.PRopm_PDClose;
0982:       END
0983:     ELSE opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0984:   end;
0985:   
0986:   
0987:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0988:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0989:   procedure Topm_Form_PEdit.FormClose (Sender: TObject; var Action: TCloseAction);
0990:   begin
0991:     IF (((opm_CurrentProdRecord.ImageURL <> opm_CurrentImage[0]) OR
0992:          (opm_CurrentProdRecord.ImageURL1 <> opm_CurrentImage[1]) OR
0993:          (opm_CurrentProdRecord.ImageURL2 <> opm_CurrentImage[2]) OR
0994:          (opm_CurrentProdRecord.ImageURL3 <> opm_CurrentImage[3]) OR
0995:          (opm_CurrentProdRecord.ImageURL4 <> opm_CurrentImage[4]) OR
0996:          (opm_CurrentProdRecord.ImageURL5 <> opm_CurrentImage[5]) OR
0997:          (opm_CurrentProdRecord.ImageURL6 <> opm_CurrentImage[6])) AND (opm_PEdit_CanClose = FALSE)) THEN
0998:       BEGIN
0999:         FNopm_Message (_('The product image has been changed but the product record has not been updated.'), mtWarning	, [mbCancel], opmG_UISilent);
1000:         Action := caNone;
1001:       END;
1002:   end;
1003:   
1004:   
1005:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1006:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1007:   PROCEDURE Topm_Form_PEdit.opm_GetDropFiles (var DropingMsg: TWMDropFiles);
1008:   VAR
1009:     DropFNames : ARRAY [0..MAX_PATH] of CHAR;
1010:   {  ResStr : STRING;}
1011:     CurFName : STRING;
1012:   //  TotalFiles, FileCounter: LONGINT;
1013:   BEGIN
1014:   //  TotalFiles := DragQueryFile (DropingMsg.Drop, $FFFFFFFF, DropFNames, SizeOf (CurFName));
1015:   //  FOR FileCounter := 0 TO (TotalFiles - 1) DO
1016:   //    BEGIN
1017:   //      CurFName := COPY (DropFNames, 0, DragQueryFile (DropingMsg.Drop, FileCounter, DropFNames, MAX_PATH));
1018:   //    END;
1019:     IF (opmG_UIImgDragDrop > 0) THEN
1020:       BEGIN
1021:         CurFName := COPY (DropFNames, 0, DragQueryFile (DropingMsg.Drop, 0, DropFNames, MAX_PATH));
1022:         DropingMsg.Result := 0;
1023:         DragFinish (DropingMsg.Drop);
1024:         opm_PRPrepareUpload (CurFName, ExtractFileName (CurFName), '', TRUE);
1025:       END;
1026:   END;
1027:   
1028:   
1029:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1030:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1031:   procedure Topm_Form_PEdit.opm_BitBtn_PEditSelectImgClick(Sender: TObject);
1032:   VAR
1033:     ResStr : STRING;
1034:     ResCode : LONGINT;
1035:   BEGIN
1036:     IF ((opmG_Cache_ImageList.Count < 1) OR (opmG_UICacheIList < 1)) THEN
1037:       BEGIN
1038:         opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
1039:         opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Getting image list...'));
1040:         ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'list', '', ResStr);
1041:         opm_Form_Progress.PRopm_PDClose;
1042:         opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
1043:         opmG_Cache_ImageList.Text := ResStr;
1044:         IF (ResCode <> 0) THEN FNopm_Message (_('There was an error while downloading the images listing.') + #13#10 + FNopm_FullRemoteError (ResCode, opmC_DefErrorDataLen) + #13#10 + _('I will continue as normal.'), mtWarning, [mbOk], opmG_UISilent);
1045:       END;
1046:     opm_Form_AskUser.AU_DataListText := opmG_Cache_ImageList.Text;
1047:     IF (opm_Form_AskUser.AU_DataListText <> '') THEN
1048:       BEGIN
1049:         opm_Form_AskUser.AU_PreCleanList := TRUE;
1050:         opm_Form_AskUser.AU_Title := _('Select the image image...');
1051:         opm_Form_AskUser.AU_ListItem := 0;
1052:         opm_Form_AskUser.AU_Directions := _('Select the image for the product:');
1053:         opm_Form_AskUser.AU_TextOrList := FALSE;
1054:         opm_Form_AskUser.AU_PassChar := #0;
1055:         IF (opm_Form_AskUser.ShowModal = mrOk) THEN
1056:           BEGIN
1057:             opm_PRSetModified (TRUE);
1058:             opm_PEdit_CanClose := FALSE;
1059:             opm_CurrentImage[opm_CurrentImageIdx] := TRIM (opm_Form_AskUser.AU_DataText);
1060:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageExists, TRUE, opm_CurrentImageIdx);
1061:           END
1062:         ELSE
1063:           BEGIN
1064:             opm_CurrentImage[opm_CurrentImageIdx] := '';
1065:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
1066:           END;
1067:       END
1068:     ELSE
1069:       BEGIN
1070:         FNopm_Message (_('There was an error while getting image files list.'), mtError, [mbOk], opmG_UISilent);
1071:       END;
1072:   end;
1073:   
1074:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1075:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1076:   procedure Topm_Form_PEdit.opm_PopMenuItem_HideUploadDebugClick (Sender: TObject);
1077:   begin
1078:     opmG_UIWBDebug := 0;
1079:     PRReg_WriteSetting ('OSCWBDebug', INTTOSTR (opmG_UIWBDebug), opmC_RegistryKey, opmC_RKConfig);
1080:     opm_Memo_UploadDEBUG.Enabled := FALSE;
1081:     opm_Memo_UploadDEBUG.Visible := FALSE;
1082:     opm_Memo_UploadDEBUG.Clear;
1083:   end;
1084:   
1085:   
1086:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1087:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1088:   FUNCTION Topm_Form_PEdit.opm_FNCleanURL (ProductURL : STRING) : STRING;
1089:   BEGIN
1090:     ProductURL := TRIM (ProductURL);
1091:     IF (ANSIUPPERCASE (COPY (ProductURL, 1, 7)) = 'HTTP://') THEN ProductURL := COPY (ProductURL, 8, opmC_ProdURL_MaxLen);
1092:     opm_FNCleanURL := ProductURL;
1093:   END;
1094:   
1095:   
1096:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1097:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1098:   procedure Topm_Form_PEdit.opm_TabControl_PEditChange(Sender: TObject);
1099:   begin
1100:     IF (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].ID > 0) THEN
1101:       BEGIN
1102:         opm_Edit_PEditName.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name;
1103:         opm_Edit_PEditURL.Text := opm_FNCleanURL (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL);
1104:         opm_StaticText_PeditViewed.Caption := INTTOSTR (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Viewed);
1105:         opm_Memo_PEditDescription.Lines.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description;
1106:         opm_Memo_PEditDescription.SelStart := opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex];
1107:       END
1108:     ELSE
1109:       BEGIN
1110:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].ID := opm_CurrentProdRecord.ID;
1111:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].LanguageID := opmG_LanguageList[opm_TabControl_PEdit.TabIndex].ID;
1112:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name := '';
1113:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL := '';
1114:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Viewed := 0;
1115:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description := '';
1116:         opm_Edit_PEditName.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name;
1117:         opm_Edit_PEditURL.Text := opm_FNCleanURL (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL);
1118:         opm_StaticText_PeditViewed.Caption := INTTOSTR (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Viewed);
1119:         opm_Memo_PEditDescription.Lines.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description;
1120:         opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex] := 0;
1121:         opm_Memo_PEditDescription.SelStart := 0;
1122:       END;
1123:   end;
1124:   
1125:   
1126:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1127:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1128:   procedure Topm_Form_PEdit.opm_TabControl_PEditChanging(Sender: TObject; var AllowChange: Boolean);
1129:   begin
1130:       opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name := FNopm_CleanString (opm_Edit_PEditName.Text);
1131:       opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL := opm_FNCleanURL (opm_Edit_PEditURL.Text);
1132:       opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description := FNopm_CleanString (opm_Memo_PEditDescription.Lines.Text);
1133:       opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex] := opm_Memo_PEditDescription.SelStart;
1134:   end;
1135:   
1136:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1137:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1138:   procedure Topm_Form_PEdit.opm_BitBtn_PEditStripHTMLClick(Sender: TObject);
1139:   begin
1140:     opm_Edit_PEditName.Text := FNopm_StripHTML (opm_Edit_PEditName.Text);
1141:     opm_Memo_PEditDescription.Lines.Text := FNopm_StripHTML (opm_Memo_PEditDescription.Lines.Text);
1142:     opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex] := 0;
1143:     opm_Memo_PEditDescription.SelStart := 0;
1144:     opm_Form_PEdit.FocusControl (opm_Memo_PEditDescription);
1145:     opm_PRSetModified (TRUE);
1146:   end;
1147:   
1148:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1149:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1150:   procedure Topm_Form_PEdit.opm_ComboBox_PEditTaxChange(Sender: TObject);
1151:   begin
1152:     IF (opm_PEdit_CalcNewTax = TRUE) THEN
1153:       BEGIN
1154:         opm_CurrentTaxRecord := FNopm_GetTax (opmG_TaxList, opm_ComboBox_PEditTax.ItemIndex, opmC_FindByIndex);
1155:         opm_Edit_PEditPriceTaxed.Text := FNopm_AfterTaxPrice (opm_Edit_PEditPrice.Text, opm_CurrentTaxRecord.SumRate);
1156:       END;
1157:     opm_PRSetModified (TRUE);
1158:   end;
1159:   
1160:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1161:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1162:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceChange(Sender: TObject);
1163:   begin
1164:     IF (opm_PEdit_CalcTaxed = TRUE) THEN
1165:       opm_Edit_PEditPriceTaxed.Text := FNopm_AfterTaxPrice (opm_Edit_PEditPrice.Text, opm_CurrentTaxRecord.SumRate);
1166:     opm_PRSetModified (TRUE);
1167:   end;
1168:   
1169:   
1170:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1171:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1172:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceTaxedChange(Sender: TObject);
1173:   begin
1174:     IF (opm_PEdit_CalcUnTaxed = TRUE) THEN
1175:       opm_Edit_PEditPrice.Text := FNopm_BeforeTaxPrice (opm_Edit_PEditPriceTaxed.Text, opm_CurrentTaxRecord.SumRate);
1176:     opm_PRSetModified (TRUE);
1177:   end;
1178:   
1179:   
1180:   
1181:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1182:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1183:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceEnter(Sender: TObject);
1184:   begin
1185:     opm_PEdit_CalcTaxed := TRUE;
1186:   end;
1187:   
1188:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1189:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1190:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceExit(Sender: TObject);
1191:   begin
1192:     opm_PEdit_CalcTaxed := FALSE;
1193:   end;
1194:   
1195:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1196:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1197:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceTaxedEnter(Sender: TObject);
1198:   begin
1199:     opm_PEdit_CalcUnTaxed := TRUE;
1200:   end;
1201:   
1202:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1203:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1204:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceTaxedExit(Sender: TObject);
1205:   begin
1206:     opm_PEdit_CalcUnTaxed := FALSE;
1207:   end;
1208:   
1209:   
1210:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1211:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1212:   FUNCTION Topm_Form_PEdit.FNopm_GetTax (VAR TaxList : opmT_TaxList; TaxID : LONGINT; SearchBy : INTEGER) : opmR_Tax;
1213:   VAR
1214:     CurTaxR : opmR_Tax;
1215:     CurTax : LONGINT;
1216:   BEGIN
1217:     CurTaxR.ID := 0;
1218:     CurTaxR.Name := '';
1219:     CurTaxR.ListIndex := 0;
1220:     CurTaxR.SumRate := 0;
1221:     FNopm_GetTax := CurTaxR;
1222:     IF (SearchBy = opmC_FindByID) THEN
1223:       FOR CurTax := 0 TO (opm_TotalTaxes - 1) DO
1224:         BEGIN
1225:           IF (TaxList[CurTax].ID = TaxID) THEN
1226:             BEGIN
1227:               CurTaxR.ID := TaxList[CurTax].ID;
1228:               CurTaxR.Name := TaxList[CurTax].Name;
1229:               CurTaxR.ListIndex := TaxList[CurTax].ListIndex;
1230:               CurTaxR.SumRate := TaxList[CurTax].SumRate;
1231:               FNopm_GetTax := CurTaxR;
1232:               BREAK;
1233:             END;
1234:         END
1235:     ELSE
1236:       FOR CurTax := 0 TO (opm_TotalTaxes - 1) DO
1237:         BEGIN
1238:           IF (TaxList[CurTax].ListIndex = TaxID) THEN
1239:             BEGIN
1240:               CurTaxR.ID := TaxList[CurTax].ID;
1241:               CurTaxR.Name := TaxList[CurTax].Name;
1242:               CurTaxR.ListIndex := TaxList[CurTax].ListIndex;
1243:               CurTaxR.SumRate := TaxList[CurTax].SumRate;
1244:               FNopm_GetTax := CurTaxR;
1245:               BREAK;
1246:             END;
1247:         END;
1248:   END;
1249:   
1250:   
1251:   
1252:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1253:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1254:   procedure Topm_Form_PEdit.opm_Edit_PeditImageURLExit(Sender: TObject);
1255:   begin
1256:     IF (opm_CurrentImage[opm_CurrentImageIdx] <> opm_Edit_PeditImageURL.Text) THEN
1257:       BEGIN
1258:         opm_Edit_PeditImageURL.Text := FNopm_CleanUploadName (opm_Edit_PeditImageURL.Text);
1259:         IF (opm_CurrentImage[opm_CurrentImageIdx] <> opm_Edit_PeditImageURL.Text) THEN
1260:           BEGIN
1261:             opm_CurrentImage[opm_CurrentImageIdx] := opm_Edit_PeditImageURL.Text;
1262:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageMayExist, TRUE, opm_CurrentImageIdx);
1263:             opm_PRSetModified (TRUE);
1264:           END;
1265:       END;
1266:   end;
1267:   
1268:   
1269:   
1270:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1271:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1272:   procedure Topm_Form_PEdit.opm_BitBtn_PEditUnlinkImgClick(Sender: TObject);
1273:   begin
1274:     opm_CurrentImage[opm_CurrentImageIdx] := '';
1275:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageIsEmpty, TRUE, opm_CurrentImageIdx);
1276:     opm_PRSetModified (TRUE);
1277:   end;
1278:   
1279:   
1280:   
1281:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1282:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1283:   PROCEDURE Topm_Form_PEdit.opm_PRSetModified (IsModified: BOOLEAN);
1284:   BEGIN
1285:     IF (ProductModified <> IsModified) THEN
1286:       BEGIN
1287:         ProductModified := IsModified;
1288:         IF (IsModified = TRUE) THEN opm_Form_PEdit.Caption := '* ' + opm_CurrentProdRecord.DisplayName
1289:         ELSE opm_Form_PEdit.Caption := opm_CurrentProdRecord.DisplayName;
1290:       END;
1291:   END;
1292:   
1293:   
1294:   
1295:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1296:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1297:   PROCEDURE Topm_Form_PEdit.opm_Control_SetChange (Sender: TObject);
1298:   begin
1299:     opm_PRSetModified (TRUE);
1300:   end;
1301:   
1302:   
1303:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1304:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1305:   procedure Topm_Form_PEdit.opm_Image_Pedit0Click(Sender: TObject);
1306:   begin
1307:     opm_PRToggle_ImgSel (0, opm_CurrentImageIdx);
1308:     opm_CurrentImageIdx := 0;
1309:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1310:     opm_PRCenterImage (opm_Panel_PeditImage0);
1311:   end;
1312:   
1313:   
1314:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1315:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1316:   procedure Topm_Form_PEdit.opm_Image_Pedit1Click(Sender: TObject);
1317:   begin
1318:     opm_PRToggle_ImgSel (1, opm_CurrentImageIdx);
1319:     opm_CurrentImageIdx := 1;
1320:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1321:     opm_PRCenterImage (opm_Panel_PeditImage1);
1322:   end;
1323:   
1324:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1325:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1326:   procedure Topm_Form_PEdit.opm_Image_Pedit2Click(Sender: TObject);
1327:   begin
1328:     opm_PRToggle_ImgSel (2, opm_CurrentImageIdx);
1329:     opm_CurrentImageIdx := 2;
1330:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1331:     opm_PRCenterImage (opm_Panel_PeditImage2);
1332:   end;
1333:   
1334:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1335:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1336:   procedure Topm_Form_PEdit.opm_Image_Pedit3Click(Sender: TObject);
1337:   begin
1338:     opm_PRToggle_ImgSel (3, opm_CurrentImageIdx);
1339:     opm_CurrentImageIdx := 3;
1340:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1341:     opm_PRCenterImage (opm_Panel_PeditImage3);
1342:   end;
1343:   
1344:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1345:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1346:   procedure Topm_Form_PEdit.opm_Image_Pedit4Click(Sender: TObject);
1347:   begin
1348:     opm_PRToggle_ImgSel (4, opm_CurrentImageIdx);
1349:     opm_CurrentImageIdx := 4;
1350:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1351:     opm_PRCenterImage (opm_Panel_PeditImage4);
1352:   end;
1353:   
1354:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1355:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1356:   procedure Topm_Form_PEdit.opm_Image_Pedit5Click(Sender: TObject);
1357:   begin
1358:     opm_PRToggle_ImgSel (5, opm_CurrentImageIdx);
1359:     opm_CurrentImageIdx := 5;
1360:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1361:     opm_PRCenterImage (opm_Panel_PeditImage5);
1362:   end;
1363:   
1364:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1365:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1366:   procedure Topm_Form_PEdit.opm_Image_Pedit6Click(Sender: TObject);
1367:   begin
1368:     opm_PRToggle_ImgSel (6, opm_CurrentImageIdx);
1369:     opm_CurrentImageIdx := 6;
1370:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1371:     opm_PRCenterImage (opm_Panel_PeditImage6);
1372:   end;
1373:   
1374:   
1375:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1376:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1377:   procedure Topm_Form_PEdit.opm_Image_Pedit0DblClick(Sender: TObject);
1378:   begin
1379:     IF (opm_PEdit_CanZoom[0] = TRUE) THEN
1380:       BEGIN
1381:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1382:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit0.Picture;
1383:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[0] + mvHint_Separator + opm_PEdit_ImageData[0] + #13#10 + opm_PEdit_ImageETA[0];
1384:         opm_Form_ImageZoom.Show;
1385:       END;
1386:   end;
1387:   
1388:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1389:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1390:   procedure Topm_Form_PEdit.opm_Image_Pedit1DblClick(Sender: TObject);
1391:   begin
1392:     IF (opm_PEdit_CanZoom[1] = TRUE) THEN
1393:       BEGIN
1394:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1395:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit1.Picture;
1396:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[1] + mvHint_Separator + opm_PEdit_ImageData[1] + #13#10 + opm_PEdit_ImageETA[1];
1397:         opm_Form_ImageZoom.Show;
1398:       END;
1399:   end;
1400:   
1401:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1402:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1403:   procedure Topm_Form_PEdit.opm_Image_Pedit2DblClick(Sender: TObject);
1404:   begin
1405:     IF (opm_PEdit_CanZoom[2] = TRUE) THEN
1406:       BEGIN
1407:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1408:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit2.Picture;
1409:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[2] + mvHint_Separator + opm_PEdit_ImageData[2] + #13#10 + opm_PEdit_ImageETA[2];
1410:         opm_Form_ImageZoom.Show;
1411:       END;
1412:   end;
1413:   
1414:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1415:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1416:   procedure Topm_Form_PEdit.opm_Image_Pedit3DblClick(Sender: TObject);
1417:   begin
1418:     IF (opm_PEdit_CanZoom[3] = TRUE) THEN
1419:       BEGIN
1420:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1421:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit3.Picture;
1422:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[3] + mvHint_Separator + opm_PEdit_ImageData[3] + #13#10 + opm_PEdit_ImageETA[3];
1423:         opm_Form_ImageZoom.Show;
1424:       END;
1425:   end;
1426:   
1427:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1428:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1429:   procedure Topm_Form_PEdit.opm_Image_Pedit4DblClick(Sender: TObject);
1430:   begin
1431:     IF (opm_PEdit_CanZoom[4] = TRUE) THEN
1432:       BEGIN
1433:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1434:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit4.Picture;
1435:         opm_Form_ImageZoom.Show;
1436:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[4] + mvHint_Separator + opm_PEdit_ImageData[4] + #13#10 + opm_PEdit_ImageETA[4];
1437:       END;
1438:   end;
1439:   
1440:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1441:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1442:   procedure Topm_Form_PEdit.opm_Image_Pedit5DblClick(Sender: TObject);
1443:   begin
1444:     IF (opm_PEdit_CanZoom[5] = TRUE) THEN
1445:       BEGIN
1446:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1447:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit5.Picture;
1448:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[5] + mvHint_Separator + opm_PEdit_ImageData[5] + #13#10 + opm_PEdit_ImageETA[5];
1449:         opm_Form_ImageZoom.Show;
1450:       END;
1451:   end;
1452:   
1453:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1454:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1455:   procedure Topm_Form_PEdit.opm_Image_Pedit6DblClick(Sender: TObject);
1456:   begin
1457:     IF (opm_PEdit_CanZoom[6] = TRUE) THEN
1458:       BEGIN
1459:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1460:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit6.Picture;
1461:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[6] + mvHint_Separator + opm_PEdit_ImageData[6] + #13#10 + opm_PEdit_ImageETA[6];
1462:         opm_Form_ImageZoom.Show;
1463:       END;
1464:   end;
1465:   
1466:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1467:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1468:   procedure Topm_Form_PEdit.opm_BitBtn_PEditDownAllClick(Sender: TObject);
1469:   VAR
1470:     CurImg : LONGINT;
1471:   begin
1472:     IF (opmG_Capa_MorePics6 = TRUE) THEN
1473:       BEGIN
1474:         opm_BitBtn_PEditDown.Enabled := FALSE;
1475:         opm_BitBtn_PEditStopDown.Visible := TRUE;
1476:         opm_BitBtn_PEditStopDown.Enabled := TRUE;
1477:         FOR CurImg := 0 TO 6 DO
1478:           BEGIN
1479:             opm_PRSetControls (opm_CurrentImage[CurImg], opmC_ImageMayExist, TRUE, CurImg);
1480:             IF (opm_CurrentImage[CurImg] <> '') THEN
1481:               BEGIN
1482:                 opm_PRDownload_Image (opm_CurrentImage[CurImg], CurImg);
1483:               END;
1484:           END;
1485:         opm_BitBtn_PEditDown.Enabled := TRUE;
1486:         opm_BitBtn_PEditStopDown.Visible := FALSE;
1487:         opm_BitBtn_PEditStopDown.Enabled := FALSE;
1488:         opm_PRToggle_ImgSel (0, opm_CurrentImageIdx);
1489:         opm_CurrentImageIdx := 0;
1490:         opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1491:       END;
1492:   end;
1493:   
1494:   
1495:   
1496:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1497:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1498:   procedure Topm_Form_PEdit.opm_Image_Pedit0DragOver(Sender, Source: TObject;
1499:                                                      X, Y: Integer; State: TDragState;
1500:                                                      var Accept: Boolean);
1501:   begin
1502:     IF ((opmG_Capa_MorePics6 = TRUE) AND (Source IS TImage) AND (Sender <> Source)) THEN
1503:       BEGIN
1504:         Accept := TRUE;
1505:       END
1506:     ELSE
1507:       BEGIN
1508:         Accept := FALSE;
1509:       END;
1510:   end;
1511:   
1512:   
1513:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1514:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1515:   procedure Topm_Form_PEdit.opm_Image_Pedit0MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1516:   begin
1517:     IF (opmG_Capa_MorePics6 = TRUE) THEN TControl(Sender).BeginDrag (FALSE, -1);
1518:   end;
1519:   
1520:   
1521:   
1522:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1523:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1524:   procedure Topm_Form_PEdit.opm_Image_Pedit0DragDrop(Sender, Source: TObject; X, Y: Integer);
1525:   VAR
1526:     SwapImage : TPICTURE;
1527:     SwapName : STRING;
1528:     SwapZoom : BOOLEAN;
1529:     SwapExist : LONGINT;
1530:     SourceTImg, TargetTImg : STRING;
1531:     SourceImg, TargetImg : WORD;
1532:   begin
1533:     IF ((opmG_Capa_MorePics6 = TRUE) AND (Source IS TImage) AND (Sender <> Source)) THEN
1534:       BEGIN
1535:         SourceTImg := TImage(Source).Name;
1536:         TargetTImg := TImage(Sender).Name;
1537:         IF (ANSIPOS ('opm_Image_Pedit', SourceTImg) > 0) THEN
1538:           BEGIN
1539:             TRY
1540:               SwapImage := TPicture.Create;
1541:               TRY
1542:                 SwapImage.Assign (TImage(Source).Picture.Bitmap);
1543:                 TImage(Source).Picture.Bitmap := TImage(Sender).Picture.Bitmap;
1544:                 TImage(Sender).Picture.Bitmap := SwapImage.Bitmap;
1545:                 SourceImg := STRTOINT (COPY (SourceTImg, LENGTH (SourceTImg), 1));
1546:                 TargetImg := STRTOINT (COPY (TargetTImg, LENGTH (TargetTImg), 1));
1547:   
1548:                 SwapName := opm_CurrentImage[SourceImg];
1549:                 opm_CurrentImage[SourceImg] := opm_CurrentImage[TargetImg];
1550:                 opm_CurrentImage[TargetImg] := SwapName;
1551:   
1552:                 SwapName := opm_PEdit_ImageData[SourceImg];
1553:                 opm_PEdit_ImageData[SourceImg] := opm_PEdit_ImageData[TargetImg];
1554:                 opm_PEdit_ImageData[TargetImg] := SwapName;
1555:   
1556:                 SwapName := opm_PEdit_ImageETA[SourceImg];
1557:                 opm_PEdit_ImageETA[SourceImg] := opm_PEdit_ImageETA[TargetImg];
1558:                 opm_PEdit_ImageETA[TargetImg] := SwapName;
1559:   
1560:                 SwapZoom := opm_PEdit_CanZoom[SourceImg];
1561:                 opm_PEdit_CanZoom[SourceImg] := opm_PEdit_CanZoom[TargetImg];
1562:                 opm_PEdit_CanZoom[TargetImg] := SwapZoom;
1563:   
1564:                 SwapExist := opm_PEdit_ImageExist[SourceImg];
1565:                 opm_PEdit_ImageExist[SourceImg] := opm_PEdit_ImageExist[TargetImg];
1566:                 opm_PEdit_ImageExist[TargetImg] := SwapExist;
1567:   
1568:                 TImage(Source).Hint := opm_CurrentImage[SourceImg] + mvHint_Separator + opm_PEdit_ImageData[SourceImg] + #13#10 + opm_PEdit_ImageETA[SourceImg] + #13#10 + #13#10 + _('Double-click to show full-size image...');
1569:                 TImage(Sender).Hint := opm_CurrentImage[TargetImg] + mvHint_Separator + opm_PEdit_ImageData[TargetImg] + #13#10 + opm_PEdit_ImageETA[TargetImg] + #13#10 + #13#10 + _('Double-click to show full-size image...');
1570:   
1571:                 opm_PRToggle_ImgSel (TargetImg, opm_CurrentImageIdx);
1572:                 opm_CurrentImageIdx := TargetImg;
1573:                 opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1574:   
1575:                 opm_PRSetModified (TRUE);
1576:                 opm_PEdit_CanClose := FALSE;
1577:               FINALLY
1578:                 SwapImage.Free;
1579:               END;
1580:             EXCEPT
1581:             END;
1582:           END;
1583:       END;
1584:   end;
1585:   
1586:   
1587:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1588:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1589:   PROCEDURE Topm_Form_PEdit.opm_InterceptKeys (var KeyPressMsg: TCMDialogKey);
1590:   BEGIN
1591:     IF (opm_ScrollBox_PeditImage.Focused = TRUE) AND (KeyPressMsg.CharCode IN [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN]) THEN
1592:       BEGIN
1593:         CASE KeyPressMsg.CharCode OF
1594:           VK_LEFT, VK_UP : opm_ScrollBox_PeditImage.HorzScrollBar.Position := opm_ScrollBox_PeditImage.HorzScrollBar.Position - opm_ScrollBox_PeditImage.HorzScrollBar.Increment;
1595:           VK_RIGHT, VK_DOWN : opm_ScrollBox_PeditImage.HorzScrollBar.Position := opm_ScrollBox_PeditImage.HorzScrollBar.Position + opm_ScrollBox_PeditImage.HorzScrollBar.Increment;
1596:         END;
1597:         KeyPressMsg.Result := 1;
1598:       END
1599:     ELSE INHERITED;
1600:   END;
1601:   
1602:   
1603:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1604:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1605:   procedure Topm_Form_PEdit.opm_ScrollBox_PeditImageEnter(Sender: TObject);
1606:   begin
1607:     opm_ScrollBox_PeditImage.Color := clHighlight;
1608:   end;
1609:   
1610:   
1611:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1612:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1613:   procedure Topm_Form_PEdit.opm_ScrollBox_PeditImageExit(Sender: TObject);
1614:   begin
1615:     opm_ScrollBox_PeditImage.Color := clBtnFace;
1616:   end;
1617:   
1618:   
1619:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1620:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1621:   procedure Topm_Form_PEdit.opm_SpeedButton_ClearImgCacheClick (Sender: TObject);
1622:   begin
1623:     opmG_Cache_ImageList.Clear;
1624:     opmG_Cache_ImageDirList.Clear;
1625:   end;
1626:   
1627:   
1628:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1629:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1630:   PROCEDURE Topm_Form_PEdit.opm_PRCenterImage (SelectedPanel : TPanel);
1631:   BEGIN
1632:     IF (opmG_UICenterImage > 0) THEN
1633:       opm_ScrollBox_PeditImage.HorzScrollBar.Position := opm_ScrollBox_PeditImage.HorzScrollBar.Position - (opm_ScrollBox_PeditImage.Width DIV 2) + SelectedPanel.Left + (SelectedPanel.Width DIV 2);
1634:   END;
1635:   
1636:   
1637:   
1638:   end.
 
 
NA fum/lmd: 2007.07.15
Copyright ©1994-2018 by Mario A. Valdez-Ramírez.
no siga este enlace / do not follow this link