Repository navigation
Expand file tree
/
Copy pathPREVIEW.FRM
More file actions
1690 lines (1459 loc) · 52.7 KB
/
Copy pathPREVIEW.FRM
File metadata and controls
1690 lines (1459 loc) · 52.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmPreview
AutoRedraw = -1 'True
Caption = "Print Preview"
ClientHeight = 1995
ClientLeft = 1905
ClientTop = 2790
ClientWidth = 4875
Icon = "Preview.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
PaletteMode = 1 'UseZOrder
ScaleHeight = 1995
ScaleWidth = 4875
Begin ComctlLib.Toolbar Toolbar
Align = 1 'Align Top
Height = 390
Left = 0
TabIndex = 0
Top = 0
Width = 4875
_ExtentX = 8599
_ExtentY = 688
ButtonWidth = 635
ButtonHeight = 582
AllowCustomize = 0 'False
Wrappable = 0 'False
ImageList = "ilButtons"
_Version = 327682
BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7}
NumButtons = 16
BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "Print"
Description = "Print"
Object.ToolTipText = "Print document"
Object.Tag = ""
ImageIndex = 1
EndProperty
BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "Copy"
Object.ToolTipText = "Copy page image to clipboard"
Object.Tag = ""
ImageIndex = 3
EndProperty
BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "Pages"
Object.ToolTipText = "View multiple pages"
Object.Tag = ""
ImageIndex = 4
EndProperty
BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Zoom"
Object.ToolTipText = "Zoom"
Object.Tag = ""
Style = 4
Object.Width = 720
EndProperty
BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "First"
Object.ToolTipText = "Go to first page"
Object.Tag = ""
ImageIndex = 5
EndProperty
BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "Previous"
Object.ToolTipText = "Go to previous page"
Object.Tag = ""
ImageIndex = 6
EndProperty
BeginProperty Button11 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "Next"
Object.ToolTipText = "Go to next page"
Object.Tag = ""
ImageIndex = 7
EndProperty
BeginProperty Button12 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = "Last"
Object.ToolTipText = "Go to last page"
Object.Tag = ""
ImageIndex = 8
EndProperty
BeginProperty Button13 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button14 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Close"
Object.ToolTipText = "Exit preview"
Object.Tag = ""
ImageIndex = 9
EndProperty
BeginProperty Button15 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button16 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Progress"
Object.Tag = ""
Style = 4
Object.Width = 360
EndProperty
EndProperty
End
Begin VB.ComboBox cboZoom
Enabled = 0 'False
Height = 315
ItemData = "Preview.frx":030A
Left = 1440
List = "Preview.frx":0323
TabIndex = 1
Text = "100%"
Top = 30
Width = 735
End
Begin VB.PictureBox picMultiView
AutoRedraw = -1 'True
Height = 1110
Left = 2010
ScaleHeight = 1050
ScaleWidth = 1020
TabIndex = 9
TabStop = 0 'False
Top = 435
Visible = 0 'False
Width = 1080
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 315
Left = 30
TabIndex = 5
Top = 705
Width = 960
End
Begin VB.Image imgPage
BorderStyle = 1 'Fixed Single
Height = 300
Index = 5
Left = 690
Picture = "Preview.frx":034D
Stretch = -1 'True
Top = 360
Width = 300
End
Begin VB.Image imgPage
BorderStyle = 1 'Fixed Single
Height = 300
Index = 4
Left = 360
Picture = "Preview.frx":044F
Stretch = -1 'True
Top = 360
Width = 300
End
Begin VB.Image imgPage
BorderStyle = 1 'Fixed Single
Height = 300
Index = 3
Left = 30
Picture = "Preview.frx":0551
Stretch = -1 'True
Top = 360
Width = 300
End
Begin VB.Image imgPage
BorderStyle = 1 'Fixed Single
Height = 300
Index = 2
Left = 690
Picture = "Preview.frx":0653
Stretch = -1 'True
Top = 30
Width = 300
End
Begin VB.Image imgPage
BorderStyle = 1 'Fixed Single
Height = 300
Index = 1
Left = 360
Picture = "Preview.frx":0755
Stretch = -1 'True
Top = 30
Width = 300
End
Begin VB.Image imgPage
BorderStyle = 1 'Fixed Single
Height = 300
Index = 0
Left = 30
Picture = "Preview.frx":0857
Stretch = -1 'True
Top = 30
Width = 300
End
End
Begin VB.ComboBox cboPage
Height = 315
Left = 0
Style = 2 'Dropdown List
TabIndex = 4
Top = 1695
Visible = 0 'False
Width = 825
End
Begin VB.PictureBox picPaper
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 570
Left = 45
ScaleHeight = 570
ScaleWidth = 540
TabIndex = 8
TabStop = 0 'False
Top = 465
Visible = 0 'False
Width = 540
End
Begin VB.VScrollBar VScroll
Enabled = 0 'False
Height = 1005
Left = 1725
Min = -15
TabIndex = 2
Top = 420
Width = 225
End
Begin VB.HScrollBar HScroll
Enabled = 0 'False
Height = 225
Left = 0
Min = -15
SmallChange = 100
TabIndex = 3
Top = 1425
Width = 1710
End
Begin VB.PictureBox picParent
AutoRedraw = -1 'True
BorderStyle = 0 'None
Height = 705
Left = 615
ScaleHeight = 705
ScaleWidth = 1095
TabIndex = 6
TabStop = 0 'False
Top = 450
Width = 1095
Begin VB.Image imgView
Appearance = 0 'Flat
Height = 300
Index = 5
Left = 735
Stretch = -1 'True
Tag = "0"
Top = 345
Visible = 0 'False
Width = 300
End
Begin VB.Image imgView
Appearance = 0 'Flat
Height = 300
Index = 4
Left = 390
Stretch = -1 'True
Tag = "0"
Top = 345
Visible = 0 'False
Width = 300
End
Begin VB.Image imgView
Appearance = 0 'Flat
Height = 300
Index = 3
Left = 45
Stretch = -1 'True
Tag = "0"
Top = 345
Visible = 0 'False
Width = 300
End
Begin VB.Image imgView
Appearance = 0 'Flat
Height = 300
Index = 2
Left = 735
Stretch = -1 'True
Tag = "0"
Top = 15
Visible = 0 'False
Width = 300
End
Begin VB.Image imgView
Appearance = 0 'Flat
Height = 300
Index = 1
Left = 390
Stretch = -1 'True
Tag = "0"
Top = 15
Visible = 0 'False
Width = 300
End
Begin VB.Image imgView
Appearance = 0 'Flat
Height = 300
Index = 0
Left = 45
Stretch = -1 'True
Tag = "0"
Top = 15
Visible = 0 'False
Width = 300
End
End
Begin ComctlLib.ProgressBar ProgressBar
Height = 255
Left = 4320
TabIndex = 10
Top = 60
Visible = 0 'False
Width = 465
_ExtentX = 820
_ExtentY = 450
_Version = 327682
Appearance = 1
End
Begin ComctlLib.StatusBar StatusBar
Align = 2 'Align Bottom
Height = 330
Left = 0
TabIndex = 7
Top = 1665
Width = 4875
_ExtentX = 8599
_ExtentY = 582
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 2
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 2
Object.Width = 1429
MinWidth = 176
Text = "Initialising "
TextSave = "Initialising "
Key = "Page"
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 6712
MinWidth = 1764
TextSave = ""
Key = "Bar"
Object.Tag = ""
EndProperty
EndProperty
End
Begin MSComDlg.CommonDialog CommonDialog
Left = 3135
Top = 1065
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin ComctlLib.ImageList ilButtons
Left = 3165
Top = 465
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 9
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":0959
Key = ""
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":0C73
Key = ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":0F8D
Key = ""
EndProperty
BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":12A7
Key = ""
EndProperty
BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":15C1
Key = ""
EndProperty
BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":18DB
Key = ""
EndProperty
BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":1BF5
Key = ""
EndProperty
BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":1F0F
Key = ""
EndProperty
BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Preview.frx":2229
Key = ""
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmPreview"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' picPaper contains the actual page information (which is hidden)
' imgView(0) shows the page (from picPaper) and is scalable.
Private Const VIEWPORT_OFFSET As Integer = 120
Private Const MULTIPAGE_OFFSET As Integer = 60
Private Type OffsetState
X As Long
Y As Long
V As Integer
H As Integer
pV As Integer
pH As Integer
End Type
Dim Offset As OffsetState
Dim bPanning As Boolean
Private Type PagesState
Layout() As LayoutState
LineCount As Integer
End Type
Dim Pages() As PagesState
Dim nPageCount As Integer
Private Type MultiState
Mode As Integer
Enabled As Boolean
Across As Integer
Down As Integer
Count As Integer ' Zero based (0 to 5)
End Type
Dim MultiPage As MultiState
Dim bZoomChanged As Boolean
Dim nCurrentPage As Integer
Dim bResizing As Boolean
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
Private Sub Form_Load()
StatusBar.Panels(1).Text = "Inicializando "
StatusBar.Panels(2).Text = ""
bZoomChanged = False
bPanning = False
bResizing = True
If WinPreview.State > -1 Then
ScaleMode = vbTwips
Me.Move WinPreview.Left, WinPreview.Top, WinPreview.Width, WinPreview.Height
Me.WindowState = WinPreview.State
Else
Width = Screen.Width * 0.75
Height = Screen.Height * 0.75
CentreForm Me
End If
bResizing = False
With cboZoom
.Text = frmMain.cboZoom.Text
.Move Toolbar.Buttons("Zoom").Left, Toolbar.Buttons("Zoom").Top, Toolbar.Buttons("Zoom").Width
.ZOrder 0
End With
With ProgressBar
.Visible = False
.Move Toolbar.Buttons("Progress").Left, Toolbar.Buttons("Progress").Top, 465
.ZOrder 0
End With
HScroll.Min = -VIEWPORT_OFFSET
VScroll.Min = -VIEWPORT_OFFSET
HScroll.Value = HScroll.Min
VScroll.Value = VScroll.Min
MultiPage.Mode = 0
MultiPage.Enabled = False
MultiPage.Across = 1
MultiPage.Down = 1
MultiPage.Count = 0
Page.Show = True
Set Page.Form = Me
End Sub
Private Sub Form_Resize()
If WindowState = vbMinimized Then Exit Sub
If bResizing Then Exit Sub
bResizing = True
On Error Resume Next
picParent.Move 0, Toolbar.Height, ScaleWidth - VScroll.Width, ScaleHeight - Toolbar.Height - (HScroll.Height + StatusBar.Height)
picParent.Line (0, 0)-(picParent.Width, 3), , BF
VScroll.Move ScaleWidth - VScroll.Width, picParent.Top, VScroll.Width, picParent.Height
HScroll.Move 0, picParent.Top + picParent.Height, ScaleWidth - VScroll.Width
cboZoom.Move Toolbar.Buttons("Zoom").Left, Toolbar.Buttons("Zoom").Top + ((Toolbar.Buttons("Zoom").Height - cboZoom.Height) / 2), Toolbar.Buttons("Zoom").Width
If ProgressBar.Visible Then ShowProgressBar True
cboZoom_Click
cboZoom.ZOrder 0
bResizing = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Page.Show = False ' No more calls to this form
Set Page.Form = Nothing
Erase Pages ' Erase to gain resources/memory
nPageCount = 0
If WindowState <> vbMinimized Then ' Take a snapshot of the window position
WinPreview.Left = Me.Left
WinPreview.Top = Me.Top
WinPreview.Width = Me.Width
WinPreview.Height = Me.Height
WinPreview.State = Me.WindowState
End If
End Sub
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
Private Sub Toolbar_ButtonClick(ByVal Button As Button)
If Button.Key <> "Pages" Then SetVisible picMultiView, False
Select Case Button.Key
Case Is = "Print"
Print2Device
Case Is = "Copy"
CopyPage
Case Is = "Pages"
MultiPages
Case Is = "Close"
Unload Me
Case Is = "First"
If nCurrentPage > 1 Then LoadPage 1
Case Is = "Previous"
If nCurrentPage > 1 Then LoadPage nCurrentPage - 1
Case Is = "Next"
If nCurrentPage < nPageCount Then LoadPage nCurrentPage + 1
Case Is = "Last"
If nCurrentPage < nPageCount Then LoadPage nPageCount
End Select
End Sub
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
Private Sub MultiPages()
picMultiView.Move Toolbar.Buttons("Pages").Left, Toolbar.Buttons("Pages").Top + Toolbar.Height + 6
SetVisible picMultiView, True
End Sub
' 0 1 2
' 3 4 5
'
Private Sub imgPage_Click(Index As Integer)
MultiPage.Enabled = False
Select Case Index
Case 0
If MultiPage.Mode = 0 Then Exit Sub
MultiPage.Mode = 0
MultiPage.Enabled = False
MultiPage.Across = 1
MultiPage.Down = 1
MultiPage.Count = 0
Case 1
If MultiPage.Mode = 1 Then Exit Sub
MultiPage.Mode = 1
MultiPage.Enabled = True
MultiPage.Across = 2
MultiPage.Down = 1
MultiPage.Count = 1
Case 2
If MultiPage.Mode = 2 Then Exit Sub
MultiPage.Mode = 2
MultiPage.Enabled = True
MultiPage.Across = 3
MultiPage.Down = 1
MultiPage.Count = 2
Case 3
If MultiPage.Mode = 3 Then Exit Sub
MultiPage.Mode = 3
MultiPage.Enabled = True
MultiPage.Across = 1
MultiPage.Down = 2
MultiPage.Count = 1
Case 4
If MultiPage.Mode = 4 Then Exit Sub
MultiPage.Mode = 4
MultiPage.Enabled = True
MultiPage.Across = 2
MultiPage.Down = 2
MultiPage.Count = 3
Case 5
If MultiPage.Mode = 5 Then Exit Sub
MultiPage.Mode = 5
MultiPage.Enabled = True
MultiPage.Across = 3
MultiPage.Down = 2
MultiPage.Count = 5
End Select
If MultiPage.Enabled Then
Toolbar.Buttons("Pages").Value = tbrPressed
cboZoom.ZOrder 0
cboZoom.Enabled = False
Else
Toolbar.Buttons("Pages").Value = tbrUnpressed
cboZoom.ZOrder 0
cboZoom.Enabled = True
End If
ZoomImage
LoadPage nCurrentPage
SetVisible picMultiView, False
End Sub
Private Sub picMultiView_LostFocus()
SetVisible picMultiView, False
End Sub
Private Sub cmdCancel_Click()
SetVisible picMultiView, False
End Sub
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
Private Sub cboZoom_Change()
bZoomChanged = True
End Sub
Private Sub cboZoom_LostFocus()
If bZoomChanged Then cboZoom_Click
End Sub
Private Sub cboZoom_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If bZoomChanged Then cboZoom_Click
End If
End Sub
Private Sub cboZoom_Click()
SetVisible picMultiView, False
ZoomImage
bZoomChanged = False
End Sub
Private Sub ZoomImage()
Dim nLeft As Integer, nTop As Integer, nHeight As Integer, nWidth As Integer, i As Integer, j As Integer, n As Integer
Dim nRatio As Double
Dim nFactor As Single
Dim sText As String
On Error Resume Next
MousePointer = vbHourglass
cboZoom.ZOrder 0
If MultiPage.Enabled Then
' Position the pages - ignore the visible flag
' Fit all pages in window...
nWidth = (picParent.Width - ((VIEWPORT_OFFSET * 2) + (MULTIPAGE_OFFSET * (MultiPage.Across - 1)))) / MultiPage.Across
nHeight = (picParent.Height - ((VIEWPORT_OFFSET * 2) + (MULTIPAGE_OFFSET * (MultiPage.Down - 1)))) / MultiPage.Down
If picPaper.Height > picPaper.Width Then
' Portrait
nRatio = nHeight / picPaper.Height
If (picPaper.Width * nRatio) > nWidth Then
nRatio = nWidth / picPaper.Width
End If
Else
' Landscape - Width is factor 1
nRatio = nWidth / picPaper.Width
If (picPaper.Height * nRatio) > nHeight Then
nRatio = nHeight / picPaper.Height
End If
End If
nFactor = nRatio
sText = "Fit"
' Size'm
nHeight = picPaper.Height * nFactor
nWidth = picPaper.Width * nFactor
' Total size
nLeft = (nWidth * MultiPage.Across) + (MULTIPAGE_OFFSET * (MultiPage.Across - 1))
nTop = (nHeight * MultiPage.Down) + (MULTIPAGE_OFFSET * (MultiPage.Down - 1))
' Calculate left-most and top-most coordinates
nLeft = ((picParent.Width - nLeft) / 2) ' - VIEWPORT_OFFSET
nTop = ((picParent.Height - nTop) / 2) ' - VIEWPORT_OFFSET
nFactor = nLeft
' Positioning ...
n = 0
For i = 1 To MultiPage.Down
For j = 1 To MultiPage.Across
imgView(n).Move nLeft, nTop, nWidth, nHeight
n = n + 1
nLeft = nLeft + nWidth + MULTIPAGE_OFFSET
Next
nLeft = nFactor
nTop = nTop + nHeight + MULTIPAGE_OFFSET
Next
' No scrolling in multipage mode
HScroll.Enabled = False
VScroll.Enabled = False
Else
nFactor = Int(Val(cboZoom.Text))
If nFactor <= 0 Then
' Fit
nWidth = picParent.Width - (VIEWPORT_OFFSET * 2)
nHeight = picParent.Height - (VIEWPORT_OFFSET * 2)
If picPaper.Height > picPaper.Width Then
' Portrait
nRatio = nHeight / picPaper.Height
If (picPaper.Width * nRatio) > nWidth Then
nRatio = nWidth / picPaper.Width
End If
Else
' Landscape - Width is factor 1
nRatio = nWidth / picPaper.Width
If (picPaper.Height * nRatio) > nHeight Then
nRatio = nHeight / picPaper.Height
End If
End If
nFactor = nRatio
sText = "Fit"
Else
nFactor = nFactor / 100
sText = Format(nFactor * 100, "##0") & "%"
End If
With imgView(0)
.Height = picPaper.Height * nFactor
.Width = picPaper.Width * nFactor
End With
SetSliders
End If
If cboZoom.Text <> sText Then
cboZoom.Text = sText
bZoomChanged = False
End If
MousePointer = vbDefault
End Sub
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
Private Sub imgView_DblClick(Index As Integer)
If imgView(Index).Tag < 1 Then Exit Sub
If MultiPage.Enabled Then
nCurrentPage = imgView(Index).Tag
imgPage_Click 0
ElseIf Int(Val(cboZoom.Text)) <= 0 Then
' From Fit to 100%
cboZoom.Text = "100%"
ZoomImage
Else
' From Zoom to Fit
cboZoom.Text = "Fit"
ZoomImage
End If
End Sub
' Take a snapshot of current mouse coordinates prior page panning
Private Sub imgView_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
SetVisible picMultiView, False
If MultiPage.Enabled Then Exit Sub
If Button = vbLeftButton And Shift = 0 Then
Offset.X = X
Offset.Y = Y
MousePointer = vbSizePointer ' Let the user know we are panning...
End If
End Sub
' Update scrollbars after pan
Private Sub imgView_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If MultiPage.Enabled Then Exit Sub
On Error Resume Next
If Button = vbLeftButton And Shift = 0 Then
bPanning = True
If VScroll.Enabled Then VScroll.Value = -(imgView(0).Top)
If HScroll.Enabled Then HScroll.Value = -(imgView(0).Left)
bPanning = False
End If
MousePointer = vbDefault ' Tell the user it's all over now
End Sub
' Pan page
Private Sub imgView_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nTop As Integer, nLeft As Integer
On Error Resume Next
cboZoom.ZOrder 0
If MultiPage.Enabled Then Exit Sub
If Button = vbLeftButton And Shift = 0 Then
' What would be the new coordinates...?
With imgView(0)
nTop = -(.Top + (Y - Offset.Y))
nLeft = -(.Left + (X - Offset.X))
End With
' Check limitations...
With VScroll
If .Enabled Then
If nTop < .Min Then
nTop = .Min
ElseIf nTop > .Max Then
nTop = .Max
End If
Else
nTop = -imgView(0).Top
End If
End With
With HScroll
If .Enabled Then
If nLeft < .Min Then
nLeft = .Min
ElseIf nLeft > .Max Then
nLeft = .Max
End If
Else
nLeft = -imgView(0).Left
End If
End With
' Go ahead, make my pan.... (Do you feel lucky, punk...)
' Generates MouseMove event... (see VB help on MouseMove)
imgView(0).Move -nLeft, -nTop
End If
End Sub
Private Sub VScroll_Change()
If bPanning Then Exit Sub
SetVisible picMultiView, False
imgView(0).Top = -VScroll.Value
End Sub
Private Sub HScroll_Change()
If bPanning Then Exit Sub
SetVisible picMultiView, False
imgView(0).Left = -HScroll.Value
End Sub
Private Sub SetSliders()
Dim nLeft As Long, nTop As Long
Dim nHeight As Long, nWidth As Long
With imgView(0)
nLeft = .Left
nTop = .Top
nHeight = .Height
nWidth = .Width
End With
If nHeight > 32767 Then nHeight = 32767 ' 16-bit limitation (only a integer)
If nWidth > 32767 Then nWidth = 32767
If picParent.Width < nWidth Then
' Enable horinzontal scroll mode
With HScroll
.Max = (nWidth - picParent.Width) + (VIEWPORT_OFFSET * 2)
.LargeChange = picParent.Width
.Enabled = True
If .Value > .Max Then .Value = .Max
End With
Else
With HScroll
.Max = .Min + 1
.LargeChange = 1
.Value = .Min
.Enabled = False
End With
' Centre "page"
nLeft = (picParent.Width - nWidth) / 2
End If
If picParent.Height < nHeight Then
' Enable vertical scroll mode
With VScroll
.Max = (nHeight - picParent.Height) + (VIEWPORT_OFFSET * 2)
.LargeChange = picParent.Height
.Enabled = True
If .Value > .Max Then .Value = .Max
End With
Else
With VScroll
.Max = VScroll.Min + 1
.LargeChange = 1
.Value = .Min
.Enabled = False
End With
' Centre "page"
nTop = (picParent.Height - nHeight) / 2
End If
imgView(0).Move nLeft, nTop
End Sub
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
' Copy current view display to clipboard.
Private Sub CopyPage()
MousePointer = vbHourglass
DoEvents ' Just in case the system needs refreshing
Clipboard.SetData imgView(0).Picture, 2
MousePointer = vbDefault
End Sub
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'
Private Sub ShowProgressBar(bFlag As Boolean)
If bFlag Then
If (Width - 4860) < 465 Then
ProgressBar.Visible = False
Else
With ProgressBar
.Move Toolbar.Buttons("Progress").Left, Toolbar.Buttons("Progress").Top + ((Toolbar.Buttons("Zoom").Height - ProgressBar.Height) / 2), Width - 4860
.Visible = True
.ZOrder 0
End With
cboZoom.ZOrder 0
Me.Refresh
End If