Changeset 800 for cprs/branches/tmg-cprs/CPRS-Chart/UploadImages.pas
- Timestamp:
- Jun 14, 2010, 12:37:31 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/tmg-cprs/CPRS-Chart/UploadImages.pas
r793 r800 84 84 PolTimer: TTimer; 85 85 DKLanguageController1: TDKLanguageController; 86 btnPickPDF: TBitBtn; 86 87 procedure UploadButtonClick(Sender: TObject); 87 88 procedure PickImagesButtonClick(Sender: TObject); … … 95 96 procedure FormRefresh(Sender: TObject); 96 97 procedure PolTimerTimer(Sender: TObject); 98 procedure btnPickPDFClick(Sender: TObject); 99 procedure FormHide(Sender: TObject); 97 100 private 98 101 { Private declarations } 99 102 Bitmap : TBitmap; 100 103 Picture : TPicture; 104 FAllowNonImages : boolean; 101 105 FUploadedImagesList : TStringList; //List of strings of images succesfully uploaded. 102 106 function MakeThumbNail(Info: TImageInfo): boolean; … … 105 109 //procedure LoadNotesList(); 106 110 function UploadFile(Info: TImageInfo; DelOrig : boolean): boolean; 111 function CopyFileToTemp(FNamePath : string) : string; 107 112 procedure UploadChosenFiles(); 108 113 function ProcessOneLine(Line : string) : string; … … 116 121 DOS, Provider, Title : string; FilePaths : TStrings) : AnsiString; 117 122 procedure FinishDocument(UploadNote : TAutoUploadNote); 123 procedure SetAllowNonImages(Value : boolean); 118 124 public 119 125 { Public declarations } … … 124 130 property ScanDir : String read FScanDir write SetScanDir; 125 131 property UploadedImages : TStringList read FUploadedImagesList; 132 property AllowNonImages : boolean read FAllowNonImages write SetAllowNonImages; 126 133 end; 127 134 … … 142 149 rTIU, 143 150 rHTMLTools, 151 fImagePickPDF, //for PDF picker dialog 144 152 uTMGOptions 145 153 ; … … 622 630 try 623 631 WebBrowser.Navigate(frmImages.NullImageName); 632 sleep(500); //Give Webbrowser time to release any browsed document. 624 633 except 625 634 on E: Exception do exit; … … 645 654 for i := 0 to OpenFileDialog.Files.Count-1 do begin 646 655 FilesToUploadList.Items.Add(OpenFileDialog.Files.Strings[i]); 656 end; 657 end; 658 end; 659 660 procedure TUploadForm.btnPickPDFClick(Sender: TObject); 661 var i : integer; 662 begin 663 if not Assigned(frmImagePickPDF) then begin 664 frmImagePickPDF := TfrmImagePickPDF.Create(Self); //free'd in OnHide 665 end; 666 if frmImagePickPDF.Execute then begin 667 for i := 0 to frmImagePickPDF.Files.Count-1 do begin 668 FilesToUploadList.Items.Add(frmImagePickPDF.Files.Strings[i]); 647 669 end; 648 670 end; … … 678 700 Bitmap.Width := 64; 679 701 Picture := TPicture.Create; 680 702 FAllowNonImages := true; 681 703 FUploadedImagesList := TStringList.Create; 682 704 … … 717 739 if SelectedItem > -1 then begin 718 740 FileName := FilesToUploadList.Items[SelectedItem]; 719 //Application.MessageBox('Here I would pass to IE','NOte'); 741 if UpperCase(ExtractFileExt(FileName))='.PDF' then begin 742 FileName := CopyFileToTemp(FileName); //returns '' if copy fails 743 if FileName = '' then FileName := frmImages.NullImageName; 744 end; 720 745 end else begin 721 746 FileName := frmImages.NullImageName; … … 728 753 end; 729 754 755 function TUploadForm.CopyFileToTemp(FNamePath : string) : string; 756 var DestFile : string; 757 lpDestFile : PAnsiChar; 758 lpSourceFile : PAnsiChar; 759 begin 760 DestFile := frmImages.CacheDir + '\tempbrowseable' + ExtractFileExt(FNamePath); 761 lpDestFile := PAnsiChar(DestFile); 762 lpSourceFile := PAnsiChar(FNamePath); 763 if CopyFile(lpSourcefile,lpDestFile,LongBool(FALSE)) = TRUE then begin //0=success 764 Result := DestFile; 765 end else begin 766 Result := ''; 767 end; 768 end; 769 730 770 procedure TUploadForm.FormRefresh(Sender: TObject); 731 771 begin … … 735 775 on E: Exception do exit; 736 776 end; 777 end; 778 779 procedure TUploadForm.FormHide(Sender: TObject); 780 begin 781 FormRefresh(Sender); 782 frmImagePickPDF.Free; 737 783 end; 738 784 … … 877 923 i : integer; 878 924 Location : string; 879 925 880 926 begin 881 927 Result := ''; //default to success for function … … 989 1035 until FindNext(Found) <> 0; 990 1036 FindClose(Found); 991 FilesList.Sort; //puts filenames in alphanumeric order 1037 FilesList.Sort; //puts filenames in alphanumeric order 992 1038 993 1039 //Now process images in correct order. … … 1157 1203 end; 1158 1204 AllFiles.AddObject(pFInfo.FPath,pFInfo); //Store filename, to allow sorting on this. 1159 until FindNext(Found) <> 0; 1205 until FindNext(Found) <> 0; 1160 1206 AllFiles.Sort; // Sort on timestamp --> put in ascending alpha filename order 1161 1207 … … 1171 1217 if pFInfo.SBarCode <> '' then begin //Found a new barcode 1172 1218 LastFileTimeStamp := CurFileTimeStamp; 1173 //Note: The expected format of barcode must be same as that 1219 //Note: The expected format of barcode must be same as that 1174 1220 // created by TfrmPtLabelPrint.PrintButtonClick: 1175 1221 // 70685-12-31-2008-73-6-1302-0 … … 1277 1323 end; 1278 1324 1325 procedure TUploadForm.SetAllowNonImages(Value : boolean); 1326 begin 1327 FAllowNonImages := Value; 1328 btnPickPDF.Enabled := Value; 1329 PickOtherButton.Enabled := Value; 1330 end; 1331 1279 1332 1280 1333
Note:
See TracChangeset
for help on using the changeset viewer.