Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize event not fired ... 2

Status
Not open for further replies.

vyper78

Programmer
Feb 5, 2004
30
0
0
AU
Guys

I've got an mdi form which has a picture in the top right hand corner which is placed there on load using the resize event. The forms windowstate is set to 2 (maximise).

When the form is minimised and then restored, the logo remains at the far left (ie: the resize event is not working). If I manually resize the form by dragging, the logo jumps back to the top right hand side.

Is there a maximise/restore/minimise event for a form? or is there some way I can fire the resize event when any of the max/res/min buttons are clicked?

I want the user to have these options, so disabling is out of the picture. Any ideas would be great.

V.
 
try something like

Private Sub MDIForm_Resize()
On Error GoTo ErrorHandler
picStretched.Move 0, 0, ScaleWidth, ScaleHeight
' Copy the original picture into picStretched.
picStretched.PaintPicture _
picOriginal.Picture, _
0, 0, _
picStretched.ScaleWidth, _
picStretched.ScaleHeight, _
0, 0, _
picOriginal.ScaleWidth, _
picOriginal.ScaleHeight
' Set the MDI form's picture.
Picture = picStretched.Image
end Sub

 
Cheers for the reply gk53, but perhaps I should give some further information:
A couple of things happen on my resize event.
1. The picture (in a picture box) is set to the top right hand corner;
2. a progress bar is added to the status bar.
When the form is minimised, restored etc, neither the pic or the pb go to the position as set out in the resize event.
The only time they do is when i manually resize the form.
So it would seem that the resize event is not being fired when the buttons in the control box are used.
Bascially I'm looking for a way to fire the resize event when the buttons in the control box are used.

Cheers

V.
 
Well, you can always call the resize event from your code.
 
So you have an mdiForm with a container control like a PictureBox (toolbar?) that has the Align property set to 1 (Align Top) and another picture box (logo?) within the container control that should always be to the right?

If so, put your logo repositioning code in the resize event of the container control.

Code:
Private Sub picToolBar_Resize()

    'If the mdiForm is being minimized then 
    'we don't do anything

    If Me.WindowState <> vbMinimized Then
     
       picLogo.Left = picToolBar.ScaleWidth - picLogo.Width
    
    End If


End Sub
 
Well, you can always call the resize event from your code."

This is my issue. HOW do you call the resize event from your code. I've got no problems with the coding to move the picture in the resize event - my problem is when the user clicks on the maximise/minimise/restore buttons. When the user uses the control box, the resize event IS NOT fired.
 
>When the user uses the control box, the resize event IS NOT fired.

Sure it does!
Something going real fishy out there. The resize event does fire when control box buttons are used.
I think the problem lies somewhere else.

Can you show your code? And some details about the layout of the form. Is the picture box placed on the MDI form or MDI child form? How do you resize the picture box? Because if the picture box is placed on the MDI form it MUST be docking inside the client area of the MDI form. And if it is docking on top (Align = 1 - Top) you cannot move it horizontally, unless you have placed it another picture box aligned on the MDI form and have set the Align property of the child picture box to 0 - None.
 
The container control placed on a MDI form does not get re-sized until the resize event of the mdi form finishes. So if you minimize your mdi form, your container control will have a width of 0 when you normalize the window. If you are doing any repositioning based on the width of the container control then it won't work unless you put the repositioning code in the container control resize event.
 
HOW do you call the resize event from your code.

Event procedures are just like any other procedures in this respect. Just put in the name of the procedure and it will run!

Code:
Sub myControl_Resize()
'do my resize stuff
End Sub

Sub CallResize()
myControl_Resize
End Sub

'calling CallResize runs the resize event handler.

HTH

bob
 
Thanks to jjames and BobRhodes .. that fixed the problem.

The picture that was in the top right corner is in another picture box. My positioning code was in the forms resize event, not the controls resize event.
I altered it so the container resize event called the forms resize event and all is well.

Thanks heaps

V.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top