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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Resizing

Status
Not open for further replies.

Logit

Programmer
Sep 23, 1998
20
US
I am using the following code in a small project to resize FORM1 based on the size of the PICTURE1 picture box control.<br>
The form will not resize on its own when the image in the picture box is larger than the initial size of FORM1. If, however I attempt to manually resize the form when the large image is present, the form &quot;jumps&quot; to the correct size without my having to drag its edges all the way out to the desired width and height.<br>
<br>
What is wrong with this code and/or why won't the form automatically resize itself ? Any help is deeply appreciated.<br>
<br>
========== code follows ============<br>
<br>
Private Sub Form_Resize()<br>
<br>
If Picture1.Width &lt; Data1.Width + Command1.Width Then<br>
Form1.Width = Data1.Width + Command1.Width + 500<br>
Else<br>
Form1.Width = Picture1.Width + 500<br>
End If<br>
<br>
Form1.Height = Picture1.Height + 2000<br>
<br>
End Sub<br>

 
It seems to me that your form is behaving correctly because it resizes as soon as you attempt the resize event.The form should resize when your picture size changes and you should maybe try and pick up an event that triggers when your picture resizes<br>
Peekay
 
HI Logit,<br>
<br>
When a picture is larger than the form, you form_resize proc will not fire. You need to put your code in the proc where your picture get loaded.<br>
<br>
The reason why your form jumps when you touch it, is due to the fact that when you touch you forms size you have programmed the form to jump to +500 on width and +2000 on height. Your procedure gets called as soon as you move the forms width or height(at all).<br>
<br>
You need to call a resize event from the the pic load proc.<br>
<br>
C
 
Thanks for the information which finally got me started in the right direction. The comment of placing the resize code in the load pic area did it. I placed the code in the Picture1_Change event and it works great !<br>
<br>
There is another problem with the project which I have posted elsewhere. Thanks to all who responded !<br>
<br>
(Now, why didn't I think of that sooner ? ;-p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top