Source code of file oscpmwin_v0.4.1.692/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), 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) + #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 (ImageJPEG = TRUE) THEN
0926:                   BEGIN
0927:                     ImageFile := opmG_TMPPath + opmC_TmpJPG_Filename;
0928:                     ConvRes := FNopm_ConvertImage2 (opmG_TMPPath + opmC_TmpBMP_Filename, ImageFile, opmC_JPEGFormat, opmG_WBImgQ, opmG_FullUserAgent)
0929:                   END
0930:                 ELSE
0931:                   BEGIN
0932:                     ImageFile := opmG_TMPPath + opmC_TmpPNG_Filename;
0933:                     ConvRes := FNopm_ConvertImage2 (opmG_TMPPath + opmC_TmpBMP_Filename, ImageFile, opmC_PNGFormat, 0, opmG_FullUserAgent);
0934:                   END;
0935:                 IF (ConvRes = TRUE) THEN
0936:                   BEGIN
0937:                     opm_Form_Progress.PRopm_PDUpdate_Progress (90, 1, _('Uploading image...'));
0938:                     ResCode := FNopm_Upload_File (opmG_WBUploadURL, ImageFile, NewName, ImgSubdir, UploadResult);
0939:                     opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0940:                   END;
0941:               END;
0942:             IF ((UploadResult <> '') AND (ResCode = 0)) THEN
0943:               BEGIN
0944:                 opm_CurrentImage[opm_CurrentImageIdx] := UploadResult;
0945:                 opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageMayExist, TRUE, opm_CurrentImageIdx);
0946:                 opmG_Cache_ImageList.Clear;
0947:                 IF (ANSIPOS ('/', UploadResult) > 0) THEN
0948:                   BEGIN
0949:                     IF (opmG_Cache_ImageDirList.IndexOf (FNopm_ExtractFilePath (UploadResult, FALSE)) < 1) THEN
0950:                       opmG_Cache_ImageDirList.Clear;
0951:                   END;
0952:               END
0953:             ELSE
0954:               BEGIN
0955:                 opm_CurrentImage[opm_CurrentImageIdx] := '';
0956:                 opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0957:                 FNopm_Message (_('There was an error while uploading the file.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
0958:               END;
0959:           END
0960:         ELSE
0961:           BEGIN
0962:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0963:             opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
0964:             IF (ResCode <> 0) THEN FNopm_Message (_('There was an error while deleting the old image.') + #13#10 + FNopm_FullRemoteError (ResCode), mtError, [mbOk], opmG_UISilent);
0965:           END;
0966:         opm_Form_Progress.PRopm_PDClose;
0967:       END
0968:     ELSE opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
0969:   end;
0970:   
0971:   
0972:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0973:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0974:   procedure Topm_Form_PEdit.FormClose (Sender: TObject; var Action: TCloseAction);
0975:   begin
0976:     IF (((opm_CurrentProdRecord.ImageURL <> opm_CurrentImage[0]) OR
0977:          (opm_CurrentProdRecord.ImageURL1 <> opm_CurrentImage[1]) OR
0978:          (opm_CurrentProdRecord.ImageURL2 <> opm_CurrentImage[2]) OR
0979:          (opm_CurrentProdRecord.ImageURL3 <> opm_CurrentImage[3]) OR
0980:          (opm_CurrentProdRecord.ImageURL4 <> opm_CurrentImage[4]) OR
0981:          (opm_CurrentProdRecord.ImageURL5 <> opm_CurrentImage[5]) OR
0982:          (opm_CurrentProdRecord.ImageURL6 <> opm_CurrentImage[6])) AND (opm_PEdit_CanClose = FALSE)) THEN
0983:       BEGIN
0984:         FNopm_Message (_('The product image has been changed but the product record has not been updated.'), mtWarning	, [mbCancel], opmG_UISilent);
0985:         Action := caNone;
0986:       END;
0987:   end;
0988:   
0989:   
0990:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0991:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0992:   PROCEDURE Topm_Form_PEdit.opm_GetDropFiles (var DropingMsg: TWMDropFiles);
0993:   VAR
0994:     DropFNames : ARRAY [0..MAX_PATH] of CHAR;
0995:   {  ResStr : STRING;}
0996:     CurFName : STRING;
0997:   //  TotalFiles, FileCounter: LONGINT;
0998:   BEGIN
0999:   //  TotalFiles := DragQueryFile (DropingMsg.Drop, $FFFFFFFF, DropFNames, SizeOf (CurFName));
1000:   //  FOR FileCounter := 0 TO (TotalFiles - 1) DO
1001:   //    BEGIN
1002:   //      CurFName := COPY (DropFNames, 0, DragQueryFile (DropingMsg.Drop, FileCounter, DropFNames, MAX_PATH));
1003:   //    END;
1004:     IF (opmG_UIImgDragDrop > 0) THEN
1005:       BEGIN
1006:         CurFName := COPY (DropFNames, 0, DragQueryFile (DropingMsg.Drop, 0, DropFNames, MAX_PATH));
1007:         DropingMsg.Result := 0;
1008:         DragFinish (DropingMsg.Drop);
1009:         opm_PRPrepareUpload (CurFName, ExtractFileName (CurFName), '', TRUE);
1010:       END;
1011:   END;
1012:   
1013:   
1014:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1015:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1016:   procedure Topm_Form_PEdit.opm_BitBtn_PEditSelectImgClick(Sender: TObject);
1017:   VAR
1018:     ResStr : STRING;
1019:     ResCode : LONGINT;
1020:   BEGIN
1021:     IF ((opmG_Cache_ImageList.Count < 1) OR (opmG_UICacheIList < 1)) THEN
1022:       BEGIN
1023:         opm_Form_Progress.PRopm_PDShow (FALSE, TRUE);
1024:         opm_Form_Progress.PRopm_PDUpdate_Progress (50, 1, _('Getting image list...'));
1025:         ResCode := FNopm_Send_Command (opmG_WBUploadURL, 'list', '', ResStr);
1026:         opm_Form_Progress.PRopm_PDClose;
1027:         opm_Memo_UploadDEBUG.Lines.Text := opmG_HTTPClient_TransactLog;
1028:         opmG_Cache_ImageList.Text := ResStr;
1029:         IF (ResCode <> 0) THEN FNopm_Message (_('There was an error while downloading the images listing.') + #13#10 + FNopm_FullRemoteError (ResCode) + #13#10 + _('I will continue as normal.'), mtWarning, [mbOk], opmG_UISilent);
1030:       END;
1031:     opm_Form_AskUser.AU_DataListText := opmG_Cache_ImageList.Text;
1032:     IF (opm_Form_AskUser.AU_DataListText <> '') THEN
1033:       BEGIN
1034:         opm_Form_AskUser.AU_PreCleanList := TRUE;
1035:         opm_Form_AskUser.AU_Title := _('Select the image image...');
1036:         opm_Form_AskUser.AU_ListItem := 0;
1037:         opm_Form_AskUser.AU_Directions := _('Select the image for the product:');
1038:         opm_Form_AskUser.AU_TextOrList := FALSE;
1039:         opm_Form_AskUser.AU_PassChar := #0;
1040:         IF (opm_Form_AskUser.ShowModal = mrOk) THEN
1041:           BEGIN
1042:             opm_PRSetModified (TRUE);
1043:             opm_PEdit_CanClose := FALSE;
1044:             opm_CurrentImage[opm_CurrentImageIdx] := TRIM (opm_Form_AskUser.AU_DataText);
1045:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageExists, TRUE, opm_CurrentImageIdx);
1046:           END
1047:         ELSE
1048:           BEGIN
1049:             opm_CurrentImage[opm_CurrentImageIdx] := '';
1050:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageDontExist, TRUE, opm_CurrentImageIdx);
1051:           END;
1052:       END
1053:     ELSE
1054:       BEGIN
1055:         FNopm_Message (_('There was an error while getting image files list.'), mtError, [mbOk], opmG_UISilent);
1056:       END;
1057:   end;
1058:   
1059:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1060:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1061:   procedure Topm_Form_PEdit.opm_PopMenuItem_HideUploadDebugClick (Sender: TObject);
1062:   begin
1063:     opmG_UIWBDebug := 0;
1064:     PRReg_WriteSetting ('OSCWBDebug', INTTOSTR (opmG_UIWBDebug), opmC_RegistryKey, opmC_RKConfig);
1065:     opm_Memo_UploadDEBUG.Enabled := FALSE;
1066:     opm_Memo_UploadDEBUG.Visible := FALSE;
1067:     opm_Memo_UploadDEBUG.Clear;
1068:   end;
1069:   
1070:   
1071:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1072:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1073:   FUNCTION Topm_Form_PEdit.opm_FNCleanURL (ProductURL : STRING) : STRING;
1074:   BEGIN
1075:     ProductURL := TRIM (ProductURL);
1076:     IF (ANSIUPPERCASE (COPY (ProductURL, 1, 7)) = 'HTTP://') THEN ProductURL := COPY (ProductURL, 8, opmC_ProdURL_MaxLen);
1077:     opm_FNCleanURL := ProductURL;
1078:   END;
1079:   
1080:   
1081:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1082:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1083:   procedure Topm_Form_PEdit.opm_TabControl_PEditChange(Sender: TObject);
1084:   begin
1085:     IF (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].ID > 0) THEN
1086:       BEGIN
1087:         opm_Edit_PEditName.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name;
1088:         opm_Edit_PEditURL.Text := opm_FNCleanURL (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL);
1089:         opm_StaticText_PeditViewed.Caption := INTTOSTR (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Viewed);
1090:         opm_Memo_PEditDescription.Lines.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description;
1091:         opm_Memo_PEditDescription.SelStart := opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex];
1092:       END
1093:     ELSE
1094:       BEGIN
1095:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].ID := opm_CurrentProdRecord.ID;
1096:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].LanguageID := opmG_LanguageList[opm_TabControl_PEdit.TabIndex].ID;
1097:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name := '';
1098:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL := '';
1099:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Viewed := 0;
1100:         opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description := '';
1101:         opm_Edit_PEditName.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name;
1102:         opm_Edit_PEditURL.Text := opm_FNCleanURL (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL);
1103:         opm_StaticText_PeditViewed.Caption := INTTOSTR (opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Viewed);
1104:         opm_Memo_PEditDescription.Lines.Text := opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description;
1105:         opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex] := 0;
1106:         opm_Memo_PEditDescription.SelStart := 0;
1107:       END;
1108:   end;
1109:   
1110:   
1111:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1112:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1113:   procedure Topm_Form_PEdit.opm_TabControl_PEditChanging(Sender: TObject; var AllowChange: Boolean);
1114:   begin
1115:       opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Name := FNopm_CleanString (opm_Edit_PEditName.Text);
1116:       opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].URL := opm_FNCleanURL (opm_Edit_PEditURL.Text);
1117:       opm_CurrentSingleDescList[opm_TabControl_PEdit.TabIndex].Description := FNopm_CleanString (opm_Memo_PEditDescription.Lines.Text);
1118:       opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex] := opm_Memo_PEditDescription.SelStart;
1119:   end;
1120:   
1121:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1122:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1123:   procedure Topm_Form_PEdit.opm_BitBtn_PEditStripHTMLClick(Sender: TObject);
1124:   begin
1125:     opm_Edit_PEditName.Text := FNopm_StripHTML (opm_Edit_PEditName.Text);
1126:     opm_Memo_PEditDescription.Lines.Text := FNopm_StripHTML (opm_Memo_PEditDescription.Lines.Text);
1127:     opm_PEdit_CursorPos[opm_TabControl_PEdit.TabIndex] := 0;
1128:     opm_Memo_PEditDescription.SelStart := 0;
1129:     opm_Form_PEdit.FocusControl (opm_Memo_PEditDescription);
1130:     opm_PRSetModified (TRUE);
1131:   end;
1132:   
1133:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1134:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1135:   procedure Topm_Form_PEdit.opm_ComboBox_PEditTaxChange(Sender: TObject);
1136:   begin
1137:     IF (opm_PEdit_CalcNewTax = TRUE) THEN
1138:       BEGIN
1139:         opm_CurrentTaxRecord := FNopm_GetTax (opmG_TaxList, opm_ComboBox_PEditTax.ItemIndex, opmC_FindByIndex);
1140:         opm_Edit_PEditPriceTaxed.Text := FNopm_AfterTaxPrice (opm_Edit_PEditPrice.Text, opm_CurrentTaxRecord.SumRate);
1141:       END;
1142:     opm_PRSetModified (TRUE);
1143:   end;
1144:   
1145:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1146:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1147:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceChange(Sender: TObject);
1148:   begin
1149:     IF (opm_PEdit_CalcTaxed = TRUE) THEN
1150:       opm_Edit_PEditPriceTaxed.Text := FNopm_AfterTaxPrice (opm_Edit_PEditPrice.Text, opm_CurrentTaxRecord.SumRate);
1151:     opm_PRSetModified (TRUE);
1152:   end;
1153:   
1154:   
1155:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1156:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1157:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceTaxedChange(Sender: TObject);
1158:   begin
1159:     IF (opm_PEdit_CalcUnTaxed = TRUE) THEN
1160:       opm_Edit_PEditPrice.Text := FNopm_BeforeTaxPrice (opm_Edit_PEditPriceTaxed.Text, opm_CurrentTaxRecord.SumRate);
1161:     opm_PRSetModified (TRUE);
1162:   end;
1163:   
1164:   
1165:   
1166:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1167:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1168:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceEnter(Sender: TObject);
1169:   begin
1170:     opm_PEdit_CalcTaxed := TRUE;
1171:   end;
1172:   
1173:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1174:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1175:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceExit(Sender: TObject);
1176:   begin
1177:     opm_PEdit_CalcTaxed := FALSE;
1178:   end;
1179:   
1180:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1181:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1182:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceTaxedEnter(Sender: TObject);
1183:   begin
1184:     opm_PEdit_CalcUnTaxed := TRUE;
1185:   end;
1186:   
1187:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1188:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1189:   procedure Topm_Form_PEdit.opm_Edit_PEditPriceTaxedExit(Sender: TObject);
1190:   begin
1191:     opm_PEdit_CalcUnTaxed := FALSE;
1192:   end;
1193:   
1194:   
1195:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1196:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1197:   FUNCTION Topm_Form_PEdit.FNopm_GetTax (VAR TaxList : opmT_TaxList; TaxID : LONGINT; SearchBy : INTEGER) : opmR_Tax;
1198:   VAR
1199:     CurTaxR : opmR_Tax;
1200:     CurTax : LONGINT;
1201:   BEGIN
1202:     CurTaxR.ID := 0;
1203:     CurTaxR.Name := '';
1204:     CurTaxR.ListIndex := 0;
1205:     CurTaxR.SumRate := 0;
1206:     FNopm_GetTax := CurTaxR;
1207:     IF (SearchBy = opmC_FindByID) THEN
1208:       FOR CurTax := 0 TO (opm_TotalTaxes - 1) DO
1209:         BEGIN
1210:           IF (TaxList[CurTax].ID = TaxID) THEN
1211:             BEGIN
1212:               CurTaxR.ID := TaxList[CurTax].ID;
1213:               CurTaxR.Name := TaxList[CurTax].Name;
1214:               CurTaxR.ListIndex := TaxList[CurTax].ListIndex;
1215:               CurTaxR.SumRate := TaxList[CurTax].SumRate;
1216:               FNopm_GetTax := CurTaxR;
1217:               BREAK;
1218:             END;
1219:         END
1220:     ELSE
1221:       FOR CurTax := 0 TO (opm_TotalTaxes - 1) DO
1222:         BEGIN
1223:           IF (TaxList[CurTax].ListIndex = TaxID) THEN
1224:             BEGIN
1225:               CurTaxR.ID := TaxList[CurTax].ID;
1226:               CurTaxR.Name := TaxList[CurTax].Name;
1227:               CurTaxR.ListIndex := TaxList[CurTax].ListIndex;
1228:               CurTaxR.SumRate := TaxList[CurTax].SumRate;
1229:               FNopm_GetTax := CurTaxR;
1230:               BREAK;
1231:             END;
1232:         END;
1233:   END;
1234:   
1235:   
1236:   
1237:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1238:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1239:   procedure Topm_Form_PEdit.opm_Edit_PeditImageURLExit(Sender: TObject);
1240:   begin
1241:     IF (opm_CurrentImage[opm_CurrentImageIdx] <> opm_Edit_PeditImageURL.Text) THEN
1242:       BEGIN
1243:         opm_Edit_PeditImageURL.Text := FNopm_CleanUploadName (opm_Edit_PeditImageURL.Text);
1244:         IF (opm_CurrentImage[opm_CurrentImageIdx] <> opm_Edit_PeditImageURL.Text) THEN
1245:           BEGIN
1246:             opm_CurrentImage[opm_CurrentImageIdx] := opm_Edit_PeditImageURL.Text;
1247:             opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageMayExist, TRUE, opm_CurrentImageIdx);
1248:             opm_PRSetModified (TRUE);
1249:           END;
1250:       END;
1251:   end;
1252:   
1253:   
1254:   
1255:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1256:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1257:   procedure Topm_Form_PEdit.opm_BitBtn_PEditUnlinkImgClick(Sender: TObject);
1258:   begin
1259:     opm_CurrentImage[opm_CurrentImageIdx] := '';
1260:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opmC_ImageIsEmpty, TRUE, opm_CurrentImageIdx);
1261:     opm_PRSetModified (TRUE);
1262:   end;
1263:   
1264:   
1265:   
1266:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1267:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1268:   PROCEDURE Topm_Form_PEdit.opm_PRSetModified (IsModified: BOOLEAN);
1269:   BEGIN
1270:     IF (ProductModified <> IsModified) THEN
1271:       BEGIN
1272:         ProductModified := IsModified;
1273:         IF (IsModified = TRUE) THEN opm_Form_PEdit.Caption := '* ' + opm_CurrentProdRecord.DisplayName
1274:         ELSE opm_Form_PEdit.Caption := opm_CurrentProdRecord.DisplayName;
1275:       END;
1276:   END;
1277:   
1278:   
1279:   
1280:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1281:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1282:   PROCEDURE Topm_Form_PEdit.opm_Control_SetChange (Sender: TObject);
1283:   begin
1284:     opm_PRSetModified (TRUE);
1285:   end;
1286:   
1287:   
1288:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1289:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1290:   procedure Topm_Form_PEdit.opm_Image_Pedit0Click(Sender: TObject);
1291:   begin
1292:     opm_PRToggle_ImgSel (0, opm_CurrentImageIdx);
1293:     opm_CurrentImageIdx := 0;
1294:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1295:     opm_PRCenterImage (opm_Panel_PeditImage0);
1296:   end;
1297:   
1298:   
1299:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1300:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1301:   procedure Topm_Form_PEdit.opm_Image_Pedit1Click(Sender: TObject);
1302:   begin
1303:     opm_PRToggle_ImgSel (1, opm_CurrentImageIdx);
1304:     opm_CurrentImageIdx := 1;
1305:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1306:     opm_PRCenterImage (opm_Panel_PeditImage1);
1307:   end;
1308:   
1309:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1310:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1311:   procedure Topm_Form_PEdit.opm_Image_Pedit2Click(Sender: TObject);
1312:   begin
1313:     opm_PRToggle_ImgSel (2, opm_CurrentImageIdx);
1314:     opm_CurrentImageIdx := 2;
1315:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1316:     opm_PRCenterImage (opm_Panel_PeditImage2);
1317:   end;
1318:   
1319:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1320:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1321:   procedure Topm_Form_PEdit.opm_Image_Pedit3Click(Sender: TObject);
1322:   begin
1323:     opm_PRToggle_ImgSel (3, opm_CurrentImageIdx);
1324:     opm_CurrentImageIdx := 3;
1325:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1326:     opm_PRCenterImage (opm_Panel_PeditImage3);
1327:   end;
1328:   
1329:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1330:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1331:   procedure Topm_Form_PEdit.opm_Image_Pedit4Click(Sender: TObject);
1332:   begin
1333:     opm_PRToggle_ImgSel (4, opm_CurrentImageIdx);
1334:     opm_CurrentImageIdx := 4;
1335:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1336:     opm_PRCenterImage (opm_Panel_PeditImage4);
1337:   end;
1338:   
1339:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1340:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1341:   procedure Topm_Form_PEdit.opm_Image_Pedit5Click(Sender: TObject);
1342:   begin
1343:     opm_PRToggle_ImgSel (5, opm_CurrentImageIdx);
1344:     opm_CurrentImageIdx := 5;
1345:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1346:     opm_PRCenterImage (opm_Panel_PeditImage5);
1347:   end;
1348:   
1349:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1350:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1351:   procedure Topm_Form_PEdit.opm_Image_Pedit6Click(Sender: TObject);
1352:   begin
1353:     opm_PRToggle_ImgSel (6, opm_CurrentImageIdx);
1354:     opm_CurrentImageIdx := 6;
1355:     opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1356:     opm_PRCenterImage (opm_Panel_PeditImage6);
1357:   end;
1358:   
1359:   
1360:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1361:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1362:   procedure Topm_Form_PEdit.opm_Image_Pedit0DblClick(Sender: TObject);
1363:   begin
1364:     IF (opm_PEdit_CanZoom[0] = TRUE) THEN
1365:       BEGIN
1366:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1367:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit0.Picture;
1368:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[0] + mvHint_Separator + opm_PEdit_ImageData[0] + #13#10 + opm_PEdit_ImageETA[0];
1369:         opm_Form_ImageZoom.Show;
1370:       END;
1371:   end;
1372:   
1373:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1374:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1375:   procedure Topm_Form_PEdit.opm_Image_Pedit1DblClick(Sender: TObject);
1376:   begin
1377:     IF (opm_PEdit_CanZoom[1] = TRUE) THEN
1378:       BEGIN
1379:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1380:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit1.Picture;
1381:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[1] + mvHint_Separator + opm_PEdit_ImageData[1] + #13#10 + opm_PEdit_ImageETA[1];
1382:         opm_Form_ImageZoom.Show;
1383:       END;
1384:   end;
1385:   
1386:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1387:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1388:   procedure Topm_Form_PEdit.opm_Image_Pedit2DblClick(Sender: TObject);
1389:   begin
1390:     IF (opm_PEdit_CanZoom[2] = TRUE) THEN
1391:       BEGIN
1392:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1393:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit2.Picture;
1394:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[2] + mvHint_Separator + opm_PEdit_ImageData[2] + #13#10 + opm_PEdit_ImageETA[2];
1395:         opm_Form_ImageZoom.Show;
1396:       END;
1397:   end;
1398:   
1399:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1400:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1401:   procedure Topm_Form_PEdit.opm_Image_Pedit3DblClick(Sender: TObject);
1402:   begin
1403:     IF (opm_PEdit_CanZoom[3] = TRUE) THEN
1404:       BEGIN
1405:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1406:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit3.Picture;
1407:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[3] + mvHint_Separator + opm_PEdit_ImageData[3] + #13#10 + opm_PEdit_ImageETA[3];
1408:         opm_Form_ImageZoom.Show;
1409:       END;
1410:   end;
1411:   
1412:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1413:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1414:   procedure Topm_Form_PEdit.opm_Image_Pedit4DblClick(Sender: TObject);
1415:   begin
1416:     IF (opm_PEdit_CanZoom[4] = TRUE) THEN
1417:       BEGIN
1418:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1419:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit4.Picture;
1420:         opm_Form_ImageZoom.Show;
1421:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[4] + mvHint_Separator + opm_PEdit_ImageData[4] + #13#10 + opm_PEdit_ImageETA[4];
1422:       END;
1423:   end;
1424:   
1425:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1426:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1427:   procedure Topm_Form_PEdit.opm_Image_Pedit5DblClick(Sender: TObject);
1428:   begin
1429:     IF (opm_PEdit_CanZoom[5] = TRUE) THEN
1430:       BEGIN
1431:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1432:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit5.Picture;
1433:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[5] + mvHint_Separator + opm_PEdit_ImageData[5] + #13#10 + opm_PEdit_ImageETA[5];
1434:         opm_Form_ImageZoom.Show;
1435:       END;
1436:   end;
1437:   
1438:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1439:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1440:   procedure Topm_Form_PEdit.opm_Image_Pedit6DblClick(Sender: TObject);
1441:   begin
1442:     IF (opm_PEdit_CanZoom[6] = TRUE) THEN
1443:       BEGIN
1444:         opm_Form_ImageZoom.Caption := opm_CurrentImage[opm_CurrentImageIdx];
1445:         opm_Form_ImageZoom.opm_Image_ZoomImage.Picture := opm_Image_Pedit6.Picture;
1446:         opm_Form_ImageZoom.opm_Image_ZoomImage.Hint := opm_CurrentImage[6] + mvHint_Separator + opm_PEdit_ImageData[6] + #13#10 + opm_PEdit_ImageETA[6];
1447:         opm_Form_ImageZoom.Show;
1448:       END;
1449:   end;
1450:   
1451:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1452:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1453:   procedure Topm_Form_PEdit.opm_BitBtn_PEditDownAllClick(Sender: TObject);
1454:   VAR
1455:     CurImg : LONGINT;
1456:   begin
1457:     IF (opmG_Capa_MorePics6 = TRUE) THEN
1458:       BEGIN
1459:         opm_BitBtn_PEditDown.Enabled := FALSE;
1460:         opm_BitBtn_PEditStopDown.Visible := TRUE;
1461:         opm_BitBtn_PEditStopDown.Enabled := TRUE;
1462:         FOR CurImg := 0 TO 6 DO
1463:           BEGIN
1464:             opm_PRSetControls (opm_CurrentImage[CurImg], opmC_ImageMayExist, TRUE, CurImg);
1465:             IF (opm_CurrentImage[CurImg] <> '') THEN
1466:               BEGIN
1467:                 opm_PRDownload_Image (opm_CurrentImage[CurImg], CurImg);
1468:               END;
1469:           END;
1470:         opm_BitBtn_PEditDown.Enabled := TRUE;
1471:         opm_BitBtn_PEditStopDown.Visible := FALSE;
1472:         opm_BitBtn_PEditStopDown.Enabled := FALSE;
1473:         opm_PRToggle_ImgSel (0, opm_CurrentImageIdx);
1474:         opm_CurrentImageIdx := 0;
1475:         opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1476:       END;
1477:   end;
1478:   
1479:   
1480:   
1481:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1482:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1483:   procedure Topm_Form_PEdit.opm_Image_Pedit0DragOver(Sender, Source: TObject;
1484:                                                      X, Y: Integer; State: TDragState;
1485:                                                      var Accept: Boolean);
1486:   begin
1487:     IF ((opmG_Capa_MorePics6 = TRUE) AND (Source IS TImage) AND (Sender <> Source)) THEN
1488:       BEGIN
1489:         Accept := TRUE;
1490:       END
1491:     ELSE
1492:       BEGIN
1493:         Accept := FALSE;
1494:       END;
1495:   end;
1496:   
1497:   
1498:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1499:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1500:   procedure Topm_Form_PEdit.opm_Image_Pedit0MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1501:   begin
1502:     IF (opmG_Capa_MorePics6 = TRUE) THEN TControl(Sender).BeginDrag (FALSE, -1);
1503:   end;
1504:   
1505:   
1506:   
1507:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1508:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1509:   procedure Topm_Form_PEdit.opm_Image_Pedit0DragDrop(Sender, Source: TObject; X, Y: Integer);
1510:   VAR
1511:     SwapImage : TPICTURE;
1512:     SwapName : STRING;
1513:     SwapZoom : BOOLEAN;
1514:     SwapExist : LONGINT;
1515:     SourceTImg, TargetTImg : STRING;
1516:     SourceImg, TargetImg : WORD;
1517:   begin
1518:     IF ((opmG_Capa_MorePics6 = TRUE) AND (Source IS TImage) AND (Sender <> Source)) THEN
1519:       BEGIN
1520:         SourceTImg := TImage(Source).Name;
1521:         TargetTImg := TImage(Sender).Name;
1522:         IF (ANSIPOS ('opm_Image_Pedit', SourceTImg) > 0) THEN
1523:           BEGIN
1524:             TRY
1525:               SwapImage := TPicture.Create;
1526:               TRY
1527:                 SwapImage.Assign (TImage(Source).Picture.Bitmap);
1528:                 TImage(Source).Picture.Bitmap := TImage(Sender).Picture.Bitmap;
1529:                 TImage(Sender).Picture.Bitmap := SwapImage.Bitmap;
1530:                 SourceImg := STRTOINT (COPY (SourceTImg, LENGTH (SourceTImg), 1));
1531:                 TargetImg := STRTOINT (COPY (TargetTImg, LENGTH (TargetTImg), 1));
1532:   
1533:                 SwapName := opm_CurrentImage[SourceImg];
1534:                 opm_CurrentImage[SourceImg] := opm_CurrentImage[TargetImg];
1535:                 opm_CurrentImage[TargetImg] := SwapName;
1536:   
1537:                 SwapName := opm_PEdit_ImageData[SourceImg];
1538:                 opm_PEdit_ImageData[SourceImg] := opm_PEdit_ImageData[TargetImg];
1539:                 opm_PEdit_ImageData[TargetImg] := SwapName;
1540:   
1541:                 SwapName := opm_PEdit_ImageETA[SourceImg];
1542:                 opm_PEdit_ImageETA[SourceImg] := opm_PEdit_ImageETA[TargetImg];
1543:                 opm_PEdit_ImageETA[TargetImg] := SwapName;
1544:   
1545:                 SwapZoom := opm_PEdit_CanZoom[SourceImg];
1546:                 opm_PEdit_CanZoom[SourceImg] := opm_PEdit_CanZoom[TargetImg];
1547:                 opm_PEdit_CanZoom[TargetImg] := SwapZoom;
1548:   
1549:                 SwapExist := opm_PEdit_ImageExist[SourceImg];
1550:                 opm_PEdit_ImageExist[SourceImg] := opm_PEdit_ImageExist[TargetImg];
1551:                 opm_PEdit_ImageExist[TargetImg] := SwapExist;
1552:   
1553:                 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...');
1554:                 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...');
1555:   
1556:                 opm_PRToggle_ImgSel (TargetImg, opm_CurrentImageIdx);
1557:                 opm_CurrentImageIdx := TargetImg;
1558:                 opm_PRSetControls (opm_CurrentImage[opm_CurrentImageIdx], opm_PEdit_ImageExist[opm_CurrentImageIdx], FALSE, opm_CurrentImageIdx);
1559:   
1560:                 opm_PRSetModified (TRUE);
1561:                 opm_PEdit_CanClose := FALSE;
1562:               FINALLY
1563:                 SwapImage.Free;
1564:               END;
1565:             EXCEPT
1566:             END;
1567:           END;
1568:       END;
1569:   end;
1570:   
1571:   
1572:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1573:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1574:   PROCEDURE Topm_Form_PEdit.opm_InterceptKeys (var KeyPressMsg: TCMDialogKey);
1575:   BEGIN
1576:     IF (opm_ScrollBox_PeditImage.Focused = TRUE) AND (KeyPressMsg.CharCode IN [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN]) THEN
1577:       BEGIN
1578:         CASE KeyPressMsg.CharCode OF
1579:           VK_LEFT, VK_UP : opm_ScrollBox_PeditImage.HorzScrollBar.Position := opm_ScrollBox_PeditImage.HorzScrollBar.Position - opm_ScrollBox_PeditImage.HorzScrollBar.Increment;
1580:           VK_RIGHT, VK_DOWN : opm_ScrollBox_PeditImage.HorzScrollBar.Position := opm_ScrollBox_PeditImage.HorzScrollBar.Position + opm_ScrollBox_PeditImage.HorzScrollBar.Increment;
1581:         END;
1582:         KeyPressMsg.Result := 1;
1583:       END
1584:     ELSE INHERITED;
1585:   END;
1586:   
1587:   
1588:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1589:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1590:   procedure Topm_Form_PEdit.opm_ScrollBox_PeditImageEnter(Sender: TObject);
1591:   begin
1592:     opm_ScrollBox_PeditImage.Color := clHighlight;
1593:   end;
1594:   
1595:   
1596:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1597:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1598:   procedure Topm_Form_PEdit.opm_ScrollBox_PeditImageExit(Sender: TObject);
1599:   begin
1600:     opm_ScrollBox_PeditImage.Color := clBtnFace;
1601:   end;
1602:   
1603:   
1604:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1605:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1606:   procedure Topm_Form_PEdit.opm_SpeedButton_ClearImgCacheClick (Sender: TObject);
1607:   begin
1608:     opmG_Cache_ImageList.Clear;
1609:     opmG_Cache_ImageDirList.Clear;
1610:   end;
1611:   
1612:   
1613:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1614:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1615:   PROCEDURE Topm_Form_PEdit.opm_PRCenterImage (SelectedPanel : TPanel);
1616:   BEGIN
1617:     IF (opmG_UICenterImage > 0) THEN
1618:       opm_ScrollBox_PeditImage.HorzScrollBar.Position := opm_ScrollBox_PeditImage.HorzScrollBar.Position - (opm_ScrollBox_PeditImage.Width DIV 2) + SelectedPanel.Left + (SelectedPanel.Width DIV 2);
1619:   END;
1620:   
1621:   
1622:   
1623:   end.
 
 
NA fum/lmd: 2007.07.15
Copyright ©1994-2017 by Mario A. Valdez-Ramírez.
no siga este enlace / do not follow this link