Waiting for a window to resize...

Akumadevil
01-08-2005, 09:35 AM
Hi,
I have 2 forms:

Form1 is my border
Form2 sits inside the border and displays the information

When I resize Form2 I want Form1 to automatically adjust around Form2. Problem is because it takes processing time to draw Form1 it results in strange behaviour.

When resizing horizontally for instance, Form1 gets wider so that a gap appears between it an Form2 (pictures). The faster the resize drag, the bigger the gap. The gap closes up in a second, but I would rather not have a gap at all.

This is an overview of my code dealing with a left/right window resize as shown in the pictures.

---------------------------------------------------------------------

ALL CODE ON FORM1, NO CODE IN FORM2

---------------------------------------------------------------------

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

temp = ScaleX(x, vbPixels, vbTwips)

Form2.Left = Form2.Left + temp
Form2.Width = Form2.Width - temp
Form2.Refresh

DrawBorder

End Sub


Public Sub DrawBorder()

Form1.Height = Form2.Height + 100
Form1.Top = Form2.Top - 100
Form1.Left = Form1.Left + temp
Form1.Width = Form1.Width - temp

...draw border...

End Sub

---------------------------------------------------------------------

If anyone can shed some light it would be appreciated.

Regards.

Verphix
01-08-2005, 10:13 PM
why not just put the border on form2 itself, instead of using another form?

Akumadevil
01-09-2005, 07:03 AM
I would but I call UpdateLayer in a way that controls, such as buttons and text boxes, cannot be displayed.

subzero0000
01-09-2005, 07:16 AM
what about using the Form_resize event in Form2?

Akumadevil
01-10-2005, 01:09 AM
Can I have an example of what you mean?

I need the mousedown, mousemove, and mouseup events in Form1 because it is larger than Form2. If I didn't, you couldn't resize without the mouse being well within the borders of the program.

I tried:

----------------FORM 1----------------------------

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

temp = ScaleX(x, vbPixels, vbTwips)

Form2.Left = Form2.Left + temp
Form2.Width = Form2.Width - temp
Form2.Refresh

End Sub

-----------------FORM 2---------------------------

Private Sub Form_Resize()

DrawBorder

End Sub

---------------------------------------------------

But it didn't seem to help.

subzero0000
01-10-2005, 01:12 AM
Nooooo, put the resize event for the form that you actually resize.

So, put it to form1, because form1 control form2 size.

subzero0000
01-10-2005, 01:14 AM
anyway, I'm not sure why you need this:
temp = ScaleX(x, vbPixels, vbTwips)

mmm...

Akumadevil
01-10-2005, 02:35 PM
anyway, I'm not sure why you need this:
temp = ScaleX(x, vbPixels, vbTwips)

When the mouse is dragged it provides a positive or negative number depending on the amount of movement. So a slow right drag would produce the following:

0
15
0
15

Whereas a quick drag provides:

30
60
70
100

The reason I use scaleX is because I need to change the number from a pixel, like the above numbers, into a twip which is larger.

Akumadevil
01-10-2005, 03:23 PM
Ok, I made the following adjustments on Form1:

Private Sub Form_Resize()
DrawBorder
Form2.Show
End Sub

Private Sub DrawBorder()

Form2.Height = Form1.Height - 200
Form2.Top = Form1.Top + 100
Form2.Left = Form1.Left + 100
Form2.Width = Form1.Width - 200

...

End Sub

-----------------------------------------

A lot simpler code which is good. There are 8 places to drag a window (N, NE, E, SE, S, SW, W, NW). E, SE and S dragging work perfect.

The remaning still cause gaps. Classic example is dragging the 'W' resize of a window back and fourth only to see the 'E' side of Form1 sway back and forth as you do!

Any further suggestions appreaciated.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum