From c12083614dded208bd51f753a67277b2c128af27 Mon Sep 17 00:00:00 2001
From: doom4ster <doom4ster@gmail.com>
Date: 星期四, 04 一月 2018 15:09:37 +0800
Subject: [PATCH] CB_IMGPSScan.cab ver2.0.1.63  修正掃瞄壓縮比無效的問題  匯入時灰階與彩色都能辨條碼

---
 CB_IMGPSScanImp.pas |  392 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 299 insertions(+), 93 deletions(-)

diff --git a/CB_IMGPSScanImp.pas b/CB_IMGPSScanImp.pas
index a02ce81..ddc6977 100644
--- a/CB_IMGPSScanImp.pas
+++ b/CB_IMGPSScanImp.pas
@@ -257,6 +257,7 @@
     ISB1: TImageScrollBox;
     Label3: TLabel;
     LogFile1: TLogFile;
+    ScanGrayCB: TCheckBox;
     procedure ActiveFormCreate(Sender: TObject);
     procedure Panel9Resize(Sender: TObject);
     procedure ISB1Click(Sender: TObject);
@@ -372,6 +373,9 @@
     procedure ImageScrollBox1NewGraphic(const Graphic: TDibGraphic);
     procedure SmoothCBClick(Sender: TObject);
     procedure N1Click(Sender: TObject);
+    procedure TreeView1MouseEnter(Sender: TObject);
+    procedure ScrollBox1MouseEnter(Sender: TObject);
+    procedure ScanGrayCBClick(Sender: TObject);
   private
     { Private declarations }
     HotKeyId1,HotKeyId2,HotKeyId3,HotKeyId4 :Integer;
@@ -1026,32 +1030,89 @@
 end;
 
 procedure TCB_IMGPSScanX.WMMOUSEWHEEL(var message: TWMMouseWheel);
+var
+  I: Integer;
+  iISB : TImageScrollBox;
 begin
     inherited;
+    //lb1.Caption:=IntToStr(message.Keys);
+    if (message.WheelDelta = WHEEL_DELTA) Then
+    begin
 
-    if (message.WheelDelta = WHEEL_DELTA) Then begin
-     if Edit1.Focused then
-     begin
-       ScrollBox1.VertScrollBar.Increment := 50;
-       ScrollBox1.Perform(WM_VSCROLL, SB_LINEUP, 0);
-     end
-     else if DisplayISB.Focused then
-     begin
-       DisplayISB.VertScrollBar.Increment := 50;
-       DisplayISB.Perform(WM_VSCROLL, SB_LINEUP, 0);
-     end;
-     end else if (message.WheelDelta = -WHEEL_DELTA) then begin
-     if Edit1.Focused then
-     begin
-       ScrollBox1.VertScrollBar.Increment := 50;
-       ScrollBox1.Perform(WM_VSCROLL, SB_LINEDOWN, 0);
-     end
-     else if DisplayISB.Focused then
-     begin
-       DisplayISB.VertScrollBar.Increment := 50;
-       DisplayISB.Perform(WM_VSCROLL, SB_LINEDOWN, 0);
-     end;
+      if ScrollBox1.Focused then
+      begin
+        ScrollBox1.VertScrollBar.Increment := 50;
+        ScrollBox1.Perform(WM_VSCROLL,SB_Lineup,0);
+      end;
+      if DisplayISB <> nil then
+      begin
+        if (DisplayISB.Focused) and (message.Keys=0) then
+        begin
+           DisplayISB.VertScrollBar.Increment := 50;
+           DisplayISB.Perform(WM_VSCROLL,SB_Lineup,0);
+        end;
+
+        if (DisplayISB.Focused) and (message.Keys=50) then
+        begin
+          DisplayISB.ZoomMode := zmPercent;
+          if DisplayISB.ZoomPercent < 90 then
+            DisplayISB.ZoomPercent := DisplayISB.ZoomPercent+10;
+        end;
+
+      end;
+      i:=0;
+      while FindComponent(ISBName+inttostr(i)) <> nil do
+      begin
+        iISB := TImageScrollBox(FindComponent(ISBName+inttostr(i)));
+        if iISB.Focused then
+        begin
+          ScrollBox1.VertScrollBar.Increment := 50;
+          ScrollBox1.Perform(WM_VSCROLL,SB_Lineup,0);
+        end;
+        inc(i);
+      end;
+
+    end
+    else if (message.WheelDelta = -WHEEL_DELTA) then
+    begin
+
+      if ScrollBox1.Focused then
+      begin
+        ScrollBox1.VertScrollBar.Increment := 50;
+        ScrollBox1.Perform(WM_VSCROLL, SB_LINEDOWN, 0);
+      end;
+      if DisplayISB <> nil then
+      begin
+        if (DisplayISB.Focused) and (message.Keys=0) then
+        begin
+           DisplayISB.VertScrollBar.Increment := 50;
+           DisplayISB.Perform(WM_VSCROLL,SB_LINEDOWN,0);
+        end;
+        if (DisplayISB.Focused) and (message.Keys=50) then
+        begin
+          DisplayISB.ZoomMode := zmPercent;
+          if DisplayISB.ZoomPercent > 10 then
+            DisplayISB.ZoomPercent := DisplayISB.ZoomPercent-10;
+        end;
+
+
+      end;
+
+      i:=0;
+      while FindComponent(ISBName+inttostr(i)) <> nil do
+      begin
+        iISB := TImageScrollBox(FindComponent(ISBName+inttostr(i)));
+        if iISB.Focused then
+        begin
+          ScrollBox1.VertScrollBar.Increment := 50;
+          ScrollBox1.Perform(WM_VSCROLL,SB_Lineup,0);
+        end;
+        inc(i);
+      end;
+
     end;
+
+
 end;
 
 procedure TCB_IMGPSScanX.WNoteBtnClick(Sender: TObject);
@@ -1225,53 +1286,24 @@
   ST1,ST2,ST3,ST4:TStringList;
   i,j,k:Integer;
 begin
-//ShowMessage('casepath='+casepath);
+
   ST1:=TStringList.Create;
   ST2:=TStringList.Create;
   ST3:=TStringList.Create;
 
-//FImgDelete:='Y';
-  {if FileExists(casepath+'CaseDocNo.dat') then
-  begin
-    ST1.LoadFromFile(casepath+'CaseDocNo.dat');
-    for I := 0 to ST1.Count - 1 do
-    begin
-      ST2.LoadFromFile(casepath+ST1.Strings[i]+'\Context.dat');
-      for j := 0 to ST2.Count - 1 do
-      begin
-        ExistImgList.Add(casepath+ST1.Strings[i]+'\'+ST2.Strings[j])
-      end;
-    end;
-  end;
-
-  if FileExists(casepath+'S_Attach\Context.dat') then
-  begin
-    ST3.LoadFromFile(casepath+'S_Attach\Context.dat');
-    for I := 0 to ST3.Count - 1 do
-    begin
-      ExistImgList.Add(casepath+'S_Attach\'+ST3.Strings[i])
-    end;
-  end;
-
-  if FileExists(casepath+'Attach\Context.dat') then
-  begin
-    ST3.LoadFromFile(casepath+'Attach\Context.dat');
-    for I := 0 to ST3.Count - 1 do
-    begin
-      ExistImgList.Add(casepath+'Attach\'+ST3.Strings[i])
-    end;
-  end; }
   ExistImgList.Clear;
   ST1.LoadFromFile(casepath+'Download\Context.dat');
   for I := 0 to ST1.Count - 1 do
   begin
+LogFile1.LogToFile(logTimeString+casepath+'Download\'+ST1.Strings[i]+',MD5='+LoadFileGetMD5(casepath+'Download\'+ST1.Strings[i]));
     ExistImgList.Add(LoadFileGetMD5(casepath+'Download\'+ST1.Strings[i])) ;
   end;
+LogFile1.LogToFile(logTimeString+'ExistImgList.text'+ExistImgList.CommaText);
 
   ST1.Free;
   ST2.Free;
   ST3.Free;
-//ShowMessage('ExistImgList='+ExistImgList.Text);
+
 end;
 
 procedure TCB_IMGPSScanX.Initialize;
@@ -1335,7 +1367,7 @@
 
 procedure TCB_IMGPSScanX.ISB1Enter(Sender: TObject);
 begin
-  //ISB1.SetFocus;
+  ISB1.SetFocus;
 end;
 
 procedure TCB_IMGPSScanX.ISB1ImageMouseDown(Sender: TObject; Button: TMouseButton;
@@ -1344,7 +1376,8 @@
   p : Integer;
 begin
   DisplayISB := TImageScrollBox(Sender);
-  DisplayISB.SetFocus;
+  if NowClick<>0 then
+    DisplayISB.SetFocus;
   Shape1.Left := TPanel(TImageScrollBox(Sender).Parent).Left - Seg;
   Shape1.Top := TPanel(TImageScrollBox(Sender).Parent).Top - Seg;
   P := strtoint(copy(DisplayISB.Name,4,1)) + ScrollBar1.Position-2;
@@ -1379,17 +1412,25 @@
 begin
    //Edit1.SetFocus;
   //TImageScrollBox(Sender).SetFocus;
+
   if TImageScrollBox(Sender).FileName = '' then
-  begin
-//ShowMessage('AAA');
-Label3.Caption:='FileName='+TImageScrollBox(Sender).FileName+'  time='+FormatDateTime('yyyy/mm/dd HH:MM:SS', now);
     TImageScrollBox(Sender).MouseMode := mmUser
-  end
   Else
-  begin
-Label3.Caption:='FileName='+TImageScrollBox(Sender).FileName;
     ViewMouseMode(NowClick);
-  end;
+
+  ISB1.AlwaysShowAnnotations := False;
+
+//  if TImageScrollBox(Sender).FileName = '' then
+//  begin
+////ShowMessage('AAA');
+//Label3.Caption:='FileName='+TImageScrollBox(Sender).FileName+'  time='+FormatDateTime('yyyy/mm/dd HH:MM:SS', now);
+//    TImageScrollBox(Sender).MouseMode := mmUser
+//  end
+//  Else
+//  begin
+//Label3.Caption:='FileName='+TImageScrollBox(Sender).FileName;
+//    ViewMouseMode(NowClick);
+//  end;
 end;
 
 procedure TCB_IMGPSScanX.ISB1ImageMouseUp(Sender: TObject; Button: TMouseButton;
@@ -1648,6 +1689,12 @@
   ExistImgList.Free;
   reSizeExistImgList.Free;
   //********清單區********
+  if (FMode = 'DSCAN') or (FMode = 'ESCAN')  then //重掃件及異動件要只能掃指定編號的件
+  begin
+    if ImagePath<>'' then
+      _Deltree(ImagePath);
+  end;
+
   if FEvents <> nil then FEvents.OnDestroy;
 end;
 
@@ -2732,9 +2779,15 @@
       ShowText := _Msg('檔案加入中,請稍候(' + inttostr(i) + '/' + inttostr(P) + ')');
       DataLoading(True, True);
       ISB.LoadFromFile(FName, i);
-      // ISB.SaveToFile('C:\OCX\aaaaaa'+IntToStr(i)+'.tif');
       DeskewImg(ISB.Graphic);
-      // ISB.SaveToFile('C:\OCX\bbbbbb'+IntToStr(i)+'.tif');
+
+
+      ISB_BW.Graphic.Assign(ISB.Graphic); //20180104
+      If ISB.Graphic.ImageFormat <> ifBlackWhite Then   //20180104
+      begin
+        ConvertToBW(ISB_BW.Graphic);
+      end;
+      ///ISB_BW.SaveToFile('KKKKKKKK.tif');
 
       iGraphic_First := TTiffGraphic.Create;
       iGraphic_sec := TTiffGraphic.Create;
@@ -2742,7 +2795,7 @@
       iGraphic_First.Assign(ISB.Graphic);
       //ShowMessage(IntToStr(iGraphic_First.Palette.palNumEntries)); //彩色 會為0  黑白 為2
 
-      MpsGetBarcode(ISB.Graphic, MpsBarcodeinf); //判斷A3 有用FormID 所以要先辨條碼
+      MpsGetBarcode(ISB_BW.Graphic, MpsBarcodeinf); //判斷A3 有用FormID 所以要先辨條碼
       //有必要的話先把影像轉正 再開始切圖
       If CheckNeedCrop(iGraphic_First) Then
       Begin
@@ -2770,7 +2823,13 @@
           (TreeView1.Selected = MyTreeNode1) Then
         Begin
           SaveFilename := '';
-          MpsGetBarcode(iGraphic, MpsBarcodeinf);
+          ISB_BW.Graphic.Assign(iGraphic); //20180104
+          If iGraphic.ImageFormat <> ifBlackWhite Then   //20180104
+          begin
+            ConvertToBW(ISB_BW.Graphic);
+          end;
+          MpsGetBarcode(ISB_BW.Graphic, MpsBarcodeinf);
+//ShowMessage(IntToStr(MpsBarcodeinf.Count));
           For n := 1 To MpsBarcodeinf.Count Do
           Begin
             If MpsBarcodeinf.r180[n] <> 0 Then // 依條碼角度轉影像
@@ -2781,6 +2840,7 @@
             End;
           End;
           FormID := BarCode2FormID;
+//ShowMessage('FormID='+FormID);
           // 取出FormID
           SaveFilename := FormID;
           If (TreeView1.Selected = NewTreeNode) Then
@@ -2848,8 +2908,8 @@
               Break;
             End;
           End;
-
-          if iGraphic.Palette.palNumEntries = 0 then  //20171130 彩色 會為0  黑白 為2
+//ShowMessage(IntToStr(iGraphic.Palette.palNumEntries));
+          if (iGraphic.Palette.palNumEntries = 0) or (iGraphic.Palette.palNumEntries = 256) then  //20171130 彩色 會為0  黑白 為2  灰階256
           begin
             iGraphic.Compression:=tcJPEG;
             iGraphic.JpegQuality:=cooom;
@@ -2885,9 +2945,6 @@
               // SaveStream.Free;
             End;
           End;
-
-          // Rotate(ISB.Graphic,MpsBarcodeinf.r180[n]);  //20170705 加入有條碼就轉正
-          // ISB.SaveToFile(SavePath+SaveFilename);
 
           SetContextList('A', -1, CaseID, DocDir, SaveFilename);
           If (TreeView1.Selected = NewTreeNode) Then
@@ -2928,8 +2985,8 @@
               Break;
             End;
           End;
-          // Rotate(ISB.Graphic,MpsBarcodeinf.r180[n]); //20170705 加入有條碼就轉正
-          if iGraphic.Palette.palNumEntries = 0 then  //20171130 彩色 會為0  黑白 為2
+
+          if (iGraphic.Palette.palNumEntries = 0) or (iGraphic.Palette.palNumEntries = 256) then  //20171130 彩色 會為0  黑白 為2
           begin
             iGraphic.Compression:=tcJPEG;
             iGraphic.JpegQuality:=cooom;
@@ -3189,7 +3246,7 @@
         end;
         ShowText := _Msg('歸類中,請稍侯');
         DataLoading(True,True);
-
+//ShowMessage('NowDocDir='+NowDocDir);
         FormIDReplace(NowCaseNo,NowDocDir,NowFormCode,NewFormID);
 
       end;
@@ -3911,6 +3968,11 @@
 
 end;
 
+procedure TCB_IMGPSScanX.ScrollBox1MouseEnter(Sender: TObject);
+begin
+ScrollBox1.SetFocus;
+end;
+
 procedure TCB_IMGPSScanX.SelectScanBtnClick(Sender: TObject);
 begin
   Panel1.Enabled := False;
@@ -4061,8 +4123,8 @@
   //lb1.Caption:='AAAAAAAAAAA';
   //Showmessage(CreateDocnoFrom_Info(NowCaseno));
   //Showmessage(self.CreateCustDocNoFrom_Info(NowCaseno));
-  ShowMessage('FMaxUploadSize='+FMaxUploadSize);
-        initkscan;
+  //ShowMessage('FMaxUploadSize='+FMaxUploadSize);
+        //initkscan;
 	showmessage('FUrl='+FUrl+#10#13+
 	'FCaseID='+FCaseID+#10#13+
 	'FMode='+FMode+#10#13+
@@ -4093,7 +4155,8 @@
     'FImgDelete='+    FImgDelete+#10#13+
     'FIsExternal='+    FIsExternal+#10#13+
     'FWH_category='+FWH_category+
-    'FCheck_main_form='+    FCheck_main_form);
+    'FCheck_main_form='+    FCheck_main_form+#10#13+
+    'FMaxUploadSize='+FMaxUploadSize);
     //FImgDelete:='Y';
   LoadImgFile;
  { ShowMessage('UpLPoint='+IntToStr(UpLPoint.X)+','+IntToStr(UpLPoint.Y)+#10#13+
@@ -4278,14 +4341,14 @@
           end;
         end;
         pScanInfo^.Graphic.Compression := tcJpeg;
-        pScanInfo^.Graphic.JpegQuality := 70;
+        pScanInfo^.Graphic.JpegQuality := FJpgCompression;
     end
     else if pScanInfo^.Graphic.ImageFormat = ifColor256 Then
     begin
       //Ext := '.jpg';
       ConvertToGray(pScanInfo^.Graphic);
       pScanInfo^.Graphic.Compression := tcJpeg;
-      pScanInfo^.Graphic.JpegQuality := 70;
+      pScanInfo^.Graphic.JpegQuality := FJpgCompression;
     end
     else if pScanInfo^.Graphic.ImageFormat = ifGray256 Then
     begin
@@ -4303,7 +4366,13 @@
         end;
       end;
       pScanInfo^.Graphic.Compression := tcJpeg;
-      pScanInfo^.Graphic.JpegQuality := 70;
+      pScanInfo^.Graphic.JpegQuality := FJpgCompression;
+//ShowMessage(IntToStr(pScanInfo^.Graphic.JpegQuality));
+//if pScanInfo^.Graphic.Compression = tcJpeg then
+//begin
+//ShowMessage('jpg');
+//end;
+
     end
     else
     begin
@@ -4336,6 +4405,19 @@
     end;
     //iGraphic.Assign(iGraphic_First);
     iGraphic := iGraphic_First;
+
+    if iGraphic.ImageFormat=ifGray256 then  //20180104
+    begin
+      iGraphic.Compression:=tcJPEG;
+      iGraphic.JpegQuality:=FJpgCompression;
+    end;
+    if iGraphic.ImageFormat=ifTrueColor then  //20180104
+    begin
+      iGraphic.Compression:=tcJPEG;
+      iGraphic.JpegQuality:=FJpgCompression;
+    end;
+
+
     while not iGraphic.IsEmpty do
     begin
       //Application.ProcessMessages;
@@ -4345,6 +4427,26 @@
         ImageScrollBox1NewGraphic(ImageScrollBox1.Graphic);
 
         MpsGetBarcode(ISB_BW.Graphic,MpsBarcodeinf);
+        For i := 1 To MpsBarcodeinf.Count Do
+        Begin
+          If MpsBarcodeinf.r180[i] <> 0 Then // 依條碼角度轉影像
+          Begin
+            Rotate(iGraphic, MpsBarcodeinf.r180[i]);
+            Break;
+          End;
+        End;
+
+        if iGraphic.ImageFormat=ifGray256 then  //20180104 因此旋轉後變為回packbits 所以要改為jpeg
+        begin
+          iGraphic.Compression:=tcJPEG;
+          iGraphic.JpegQuality:=FJpgCompression;
+        end;
+        if iGraphic.ImageFormat=ifTrueColor then
+        begin
+          iGraphic.Compression:=tcJPEG;
+          iGraphic.JpegQuality:=FJpgCompression;
+        end;
+
         PageEnd;
         IF PEFileName <> '' Then
         begin
@@ -4369,7 +4471,7 @@
             JpgGr := TJpegGraphic.Create;
             try
               JpgGr.Assign(iGraphic);
-              JpgGr.SaveQuality := 30;
+              JpgGr.SaveQuality := FJpgCompression;
               //JpgGr.AppendToStream(SaveStream);
               JpgGr.SaveToFile(PEFileName);
             finally
@@ -5903,13 +6005,19 @@
 Function TCB_IMGPSScanX.CheckCaseDocNoPage(CaseID,DocNo,Version:String;Pages:Integer):Integer; //取案件裡的文件_版本頁數
 var
   i,n,Count : integer;
-  S : TStringlist;
+  S, S2 : TStringlist;
   FormCode,iPage : String;
+  docInt,tempInt:integer;
+  v,v2:integer;
 begin
   Count := 0;
+  docInt:=0;
+  tempInt:=0;
   S := TStringlist.Create;
+  S2 := TStringlist.Create;
   try
     S.LoadFromFile(ImageSavePath+CaseID+'\upload\Context.dat');
+    S2.LoadFromFile(ImageSavePath+CaseID+'\upload\DocDir.dat'); //2017 1220 改成只承認第一份的
     for I := 1 to pages do //從0到pages-1  改成 1到pages 20170316 這樣可以修改檢核的頁數問題
     begin
       iPage := Add_Zoo(i,2);
@@ -5923,6 +6031,23 @@
             Continue;
           end;
         end;
+        if Length(S2.Strings[n])>8 then //2017 1220 改成只承認第一份的
+        begin
+          v:=Pos('(',S2.Strings[n]);
+          v2:=Pos(')',S2.Strings[n]);
+          tempInt:=StrToInt(Copy(S2.Strings[n],v+1,v2-v-1));
+
+          if docInt=0 then
+          begin
+            docInt:=tempInt;
+          end;
+
+          if docInt<>tempInt then
+          begin
+            Break
+          end;
+        end;
+
         FormCode := FileName2FormCode(S.Strings[n]);
 //Showmessage('1:'+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
 LogFile1.LogToFile(logTimeString+'CheckCaseDocNoPage caseno='+CaseID+','+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
@@ -5938,6 +6063,7 @@
     end;
   finally
   S.Free;
+  S2.free;
   end;
   Result := Count;
 end;
@@ -7263,7 +7389,16 @@
     NewDocNo := FormCode2DocNo(NewFormID);
     NewDocDir := FindLastestDocDir(CaseID,NewDocNo);
     if NewDocDir = '' then
-      NewDocDir := NewDocNo;
+    begin
+      if DocNoNeedDiv(NewDocNo) then
+      begin
+        NewDocDir:=DocNo2DocNoDir(ImageSavePath + NowCaseno+'\',NewDocNo);
+      end
+      else
+      begin
+        NewDocDir := NewDocNo;
+      end;
+    end;
 //ShowMessage('NewDocDir='+NewDocDir);
     if DocNoNeedDiv(NewDocNo) and (FormCode2Page(NewFormID)='01') then
     begin
@@ -8060,6 +8195,33 @@
   //R_W_ScanIni('W');       //user要求改成預設後不能改
 end;
 
+procedure TCB_IMGPSScanX.ScanGrayCBClick(Sender: TObject);
+begin
+
+  if ScanGrayCB.Checked then
+  begin
+    ScanColor:=ifGray256;
+  end
+  else
+  begin
+    if FScanColor = 0 then
+    begin
+      ScanColor := ifBlackWhite;
+    end;
+
+    if FScanColor = 1 then
+    begin
+      ScanColor := ifGray256 ;
+    end;
+
+    if FScanColor = 2 then
+    begin
+      ScanColor := ifTrueColor ;
+    end;
+  end;
+
+end;
+
 Function TCB_IMGPSScanX.GetFormatID(CaseID: string):String;
 Var
   S : TStringlist;
@@ -8465,6 +8627,7 @@
   CaseDocNo_CopiesList := TStringlist.Create;
   StrList := TStringlist.Create;
   ST1:=TStringList.Create;
+LogFile1.LogToFile(logTimeString+'產文件樹開始');
   try
     CaseNode.ImageIndex := 1;
     CaseNode.SelectedIndex := 1;
@@ -8485,7 +8648,8 @@
         FileList.LoadFromFile(ImageSavePath+Caseno+'\'+CaseDocNoList.Strings[i]+'\Context.dat');
       iDocNo := DocNoDir2DocNo(CaseDocNoList.Strings[i]);
       ST1.Clear;
-//ShowMessage(FileList.Text);
+
+LogFile1.LogToFile(logTimeString+'FileList.Text='+FileList.CommaText);
       if (FWH_category='N') and (FIs_In_Wh='Y') then
       begin
         for n := 0 to FileList.Count - 1 do
@@ -8505,11 +8669,9 @@
         end;
       end;
 
-
+LogFile1.LogToFile(logTimeString+'WH_category='+FWH_category+',Is_In_Wh='+FIs_In_Wh+',FileList.Text='+FileList.CommaText);
       if FileList.Count=0 then Continue;
 
-
-//Showmessage('aaa '+FileList.Text);
       DocNoCopies := Strtoint(CaseDocNo_CopiesList.Strings[i]);
       DocNoPage := FileList.Count;
       iDocNo := DocNoDir2DocNo(CaseDocNoList.Strings[i]);
@@ -8528,6 +8690,7 @@
 
       //DocNode := TreeView1.Items.AddChild(CaseNode,Format('%s{%s}-%d'+_msg('頁'),[CaseDocNoList.Strings[i],DocNo2DocName(Caseno,iDocNo),DocNoPage]));
       //DocNode := TreeView1.Items.AddChild(CaseNode,Format('%s{%s}-%d'+_msg('份'),[CaseDocNoList.Strings[i],DocNo2DocName(Caseno,iDocNo),DocNoCopies]));
+//ShowMessage('iDocNo='+iDocNo);
       DocNode := TreeView1.Items.AddChild(CaseNode,Format('%s{%s}-%d'+_msg('份'),[DocNo2DocName(Caseno,iDocNo),CaseDocNoList.Strings[i],DocNoCopies]));
 
       if GetUseCase('F',ImageSavePath+Caseno+'\',CaseDocNoList.Strings[i]) <> '' Then
@@ -8686,7 +8849,7 @@
         end;
       end;
     end;
-
+LogFile1.LogToFile(logTimeString+'產文件樹結束');
   Finally
   FileList.Free;
   CaseDocNoList.Free;
@@ -9221,7 +9384,7 @@
 
 function TCB_IMGPSScanX.logTimeString: String;
 begin
-Result:=FormatDateTime('yyyymmdd hh:mm:ss',now) +'  '
+Result:=FormatDateTime('yyyymmdd hh:mm:ss',now) +'  caseNo='+NowCaseno+'  ';
 end;
 
 Function TCB_IMGPSScanX.FindDivFormCode(FormCode:String):Boolean; //找有沒有分案的條碼
@@ -11227,6 +11390,7 @@
   begin
     If FindSQLData(Doc_Inf_List,'DOC_U_DESC','DOC_NO',DocNo,0,FindResult) Then
     begin
+//ShowMessage(FindResult.Text);
       Result := GetFindResult('DOC_U_DESC');
     end;
   end;
@@ -11529,6 +11693,7 @@
               MainFormPage := GetDataDocNoPage(MainDocNo,MainVersion); //資料庫記錄主文件頁數
               CaseFormPage := CheckCaseDocNoPage(CaseID,MainDocNo,MainVersion,MainFormPage); //案件主文件的頁數
 LogFile1.LogToFile(logTimeString+CaseID+',MainDocNo='+MainDocNo+',MainVersion='+MainVersion+',MainFormPage='+IntToStr(MainFormPage)+',CaseFormPage='+IntToStr(CaseFormPage));
+              //CheckFirstDocNoPage
               IF (MainFormPage > 0) and (MainFormPage <> CaseFormPage) then
               begin
                 ErrStr:=MainDocNo+Format(OMRErrInfo[1].Info,[Inttostr(MainFormPage),Inttostr(CaseFormPage)]); //主要文件需有XX頁僅附XX頁
@@ -12881,7 +13046,7 @@
 Procedure TCB_IMGPSScanX.ISBMouseMove(Sender: TObject; Shift: TShiftState;
   X, Y: Integer);
 begin
-  Edit1.SetFocus;
+  //Edit1.SetFocus;
   if Draging then
   begin
     if not (TShape(FindComponent('SP'+Copy(TImageScrollBox(Sender).Name,length(ISBName)+1,length(TImageScrollBox(Sender).Name)-length(ISBName)))) = nil) then
@@ -14293,6 +14458,8 @@
 
   ReduceLogFile;
 
+  LogFile1.LogToFile(logTimeString+'OCX取表data結束');
+
   ShowText := _Msg('資料載入中,請稍候');
   DataLoading(True,True);
 
@@ -14416,6 +14583,40 @@
   Splitter2.Visible := False; }
 //ShowMessage('ImageSavePath='+ImageSavePath);
   DataLoading(False,False);
+
+  LogFile1.LogToFile(logTimeString+'OCX初始化結束');
+  LogFile1.LogToFile(logTimeString+'FUrl='+FUrl+
+	',FCaseID='+FCaseID+
+	',FMode='+FMode+
+	',FModeName='+FModeName+
+	',FWork_no='+FWork_no+
+	',FUserID='+FUserID+
+	',FUserName='+FUserName+
+	',FUserUnit='+FUserUnit+
+	',FData='+FData+
+	',FVerify='+FVerify+
+	',FReWrite='+FReWrite+
+	',FLanguage='+FLanguage+
+	',FLoanDoc_Value='+FLoanDoc_Value+
+	',FLoanDoc_Enable='+FLoanDoc_Enable+
+	',FUseProxy='+FUseProxy+
+	',FC_DocNoList='+FC_DocNoList+
+	',FC_DocNameList='+FC_DocNameList+
+	',FFixFileList='+FFixFileList+
+	',FIs_In_Wh='+FIs_In_Wh+
+	',FOldCaseInfo='+FOldCaseInfo+
+	',FPrintyn='+FPrintyn+
+	',FIs_OldCase='+FIs_OldCase+
+	',FCustDocYN='+FCustDocYN);
+  LogFile1.LogToFile(logTimeString+'FImgDPI='+IntToStr(FImgDPI)+
+    ',FScanColor='+    IntToStr(FScanColor)+
+    ',FFileSizeLimit='+  IntToStr(FFileSizeLimit)+
+    ',FCaseNoLength='+ IntToStr(FCaseNoLength)+
+    ',FImgDelete='+FImgDelete+
+    ',FIsExternal='+FIsExternal+
+    ',FWH_category='+FWH_category+
+    ',FCheck_main_form='+FCheck_main_form+
+    ',FMaxUploadSize='+FMaxUploadSize);
 
 end;
 
@@ -15061,10 +15262,15 @@
 
 end;
 
+procedure TCB_IMGPSScanX.TreeView1MouseEnter(Sender: TObject);
+begin
+TreeView1.SetFocus;
+end;
+
 procedure TCB_IMGPSScanX.TreeView1MouseMove(Sender: TObject; Shift: TShiftState;
   X, Y: Integer);
 begin
-  TreeView1.SetFocus;
+  //TreeView1.SetFocus;
   {UnRegisterHotKey(Handle, HotKeyId1);
   UnRegisterHotKey(Handle, HotKeyId2); }
 end;

--
Gitblit v1.8.0