Skip to content

Commit

Permalink
Fix for #13 and #14, viewport problems related to maximized image win…
Browse files Browse the repository at this point in the history
…dows

pdImages now tracks window state, and triggers a redraw of all viewports
when an image form is maximized or un-maximized.  (Necessary because MDI
rules require ALL child windows to be maximized or NO child windows to
be maximized.)  Also added checking for off-screen images; these are now
moved on-screen when an image form is un-maximized.
  • Loading branch information
tannerhelland committed Jul 17, 2012
1 parent 78047db commit f6a75dc
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Classes/pdImage.cls
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ Option Explicit
Public WindowLeft As Long
Public WindowTop As Long

'Track the current window state; if the image's containing form goes from maximized to normal, all images need their
' buffer refreshed (as scroll bars may then be needed)
Public WindowState As Long

'Variables related to drawing the buffer on-screen; these are set by PrepareViewport and read by ScrollViewport
Public targetWidth As Long
Public targetHeight As Long 'Formerly the width and height of the .FrontBuffer picture box
Expand Down
35 changes: 35 additions & 0 deletions Forms/VBP_FormImage.frm
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,41 @@ Private Sub Form_Resize()
Me.Height = 6000
Me.Width = 8000
End If

Dim i As Long

'If the window is being un-maximized, it's necessary to redraw every image buffer (to check for scroll bar enabling/disabling)
If pdImages(Me.Tag).WindowState = vbMaximized And Me.WindowState = 0 Then

For i = 1 To CurrentImage
If pdImages(i).IsActive = True Then
pdImages(i).WindowState = 0
PrepareViewport pdImages(i).containingForm

'While we're at it, make sure the images aren't still hidden off-form (which can happen if they were loaded while the window was maximized)
If pdImages(i).containingForm.Left >= FormMain.ScaleWidth Then pdImages(i).containingForm.Left = pdImages(i).WindowLeft
If pdImages(i).containingForm.Top >= FormMain.ScaleHeight Then pdImages(i).containingForm.Top = pdImages(i).WindowTop

End If
Next i

End If

'If this window is going from non-maximized to maximized, note that across all relevant pdImage objects
If pdImages(Me.Tag).WindowState <> vbMaximized And Me.WindowState = vbMaximized Then

For i = 1 To CurrentImage
If pdImages(i).IsActive = True Then
pdImages(i).WindowState = vbMaximized
PrepareViewport pdImages(i).containingForm
End If
Next i

End If


'Remember this window state in the relevant pdImages object
pdImages(Me.Tag).WindowState = Me.WindowState

End Sub

Expand Down
3 changes: 3 additions & 0 deletions Modules/VBP_LoadModule.bas
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ Public Sub PreLoadImage(ByRef sFile() As String, Optional ByVal ToUpdateMRU As B

PrepareViewport FormMain.ActiveForm

'Note the window state, as it may be important in the future
pdImages(CurrentImage).WindowState = FormMain.ActiveForm.WindowState

'The form has been hiding off-screen this entire time, and now it's finally time to bring it to the forefront
If FormMain.ActiveForm.WindowState = 0 Then
FormMain.ActiveForm.Left = pdImages(CurrentImage).WindowLeft
Expand Down
15 changes: 7 additions & 8 deletions Modules/VBP_MDIWindow.bas
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Public Sub CreateNewImageForm(Optional ByVal forInternalUse As Boolean = False)

Set pdImages(NumOfImagesLoaded) = New pdImage

'This is the actual, physical form object that the image will reside on
'This is the actual, physical form object on which an image will reside
Dim frm As New FormImage

'IMPORTANT: the form tag is the only way we can keep track of separate forms
Expand Down Expand Up @@ -70,13 +70,12 @@ Public Sub CreateNewImageForm(Optional ByVal forInternalUse As Boolean = False)
Dim RandPercent As Long
RandPercent = Int(Rnd * 100)

'Hide the form off-screen while the loading takes place.
If frm.WindowState = 0 Then
pdImages(NumOfImagesLoaded).WindowLeft = frm.Left
pdImages(NumOfImagesLoaded).WindowTop = frm.Top
frm.Left = FormMain.ScaleWidth
frm.Top = FormMain.ScaleHeight
End If
'Hide the form off-screen while the loading takes place, but remember its location so we can restore it post-load.
pdImages(NumOfImagesLoaded).WindowLeft = frm.Left
pdImages(NumOfImagesLoaded).WindowTop = frm.Top
frm.Left = FormMain.ScaleWidth
frm.Top = FormMain.ScaleHeight

frm.Show
frm.Caption = "Loading image (" & RandPercent & "%)..."
frm.SetFocus
Expand Down
Binary file modified PhotoDemon.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion PhotoDemon.vbp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Description="PhotoDemon"
CompatibleMode="0"
MajorVer=4
MinorVer=1
RevisionVer=16
RevisionVer=17
AutoIncrementVer=1
ServerSupportFiles=0
VersionComments="�2000-2012 Tanner Helland - www.tannerhelland.com"
Expand Down

0 comments on commit f6a75dc

Please sign in to comment.