[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Form_Resize

Posted on 2001-07-12
5
Medium Priority
?
510 Views
Last Modified: 2007-11-27
Hi everybody,

I'm new with VB and have a small problem with resizing.
I have a mdiForm that contains frmCube as a child.  frmCube only as an activeX call DynamiCube.  This Cube is called in my code DCube1.  It consist mainly of a pivot table with it's data.  I want the user to be able to resize the frmCube so the DCube1 size always follow.  So here's what I've tryed :

Private Sub Form_Load()'frmCube load
    iFrmHeight = Me.Height
    iFrmWidth = Me.Width
    iFrmTop = Me.Top
    iFrmLeft = Me.Left
    iCubeLeft = DCube1.Left
    iCubeWidth = DCube1.Width
    iCubeTop = DCube1.Top
    iCubeHeight = DCube1.Height
   
End Sub

Private Sub Form_Resize()
Dim diffWidth As Double
Dim diffHeight As Double
Dim diffTop As Double
Dim diffLeft As Double

On Error Resume Next
   
diffWidth = Me.Width - iFrmWidth 'Width courant- precedent
diffHeight = Me.Height - iFrmHeight
diffTop = Me.Top - iFrmTop
diffLeft = Me.Left - iFrmLeft

'0.090909 = DCube.Left / frmCube.Left        
DCube1.Left = iCubeLeft + diffLeft * 0.090909  
DCube1.Width = iCubeWidth + diffWidth * 0.95542
DCube1.Top = iCubeTop + diffTop * 0.096969
DCube1.Height = iCubeHeight + diffHeight * 0.924242
   
    iFrmWidth = Me.Width        'update
    iFrmHeight = Me.Height
    iFrmTop = Me.Top
    iFrmLeft = Me.Left
    iCubeLeft = DCube1.Left
    iCubeWidth = DCube1.Width
    iCubeTop = DCube1.Top
    iCubeHeight = DCube1.Height
End Sub


The problem I have is that the DCube1 do resize but I lose the scroll bar on the bottom and on the right of the Cube.
I've also tried with the DCube1.move method but it does the same.  I dont even know if that's how I'm suppose to do it...I'm open to other suggestion!

Thank's

Richard
0
Comment
Question by:richardferron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Expert Comment

by:Otana
ID: 6277647
You can make the borders of your form a bit larger.
Or subtract the size of the scrollbars of the size of the cube.
0
 

Expert Comment

by:JimBarron
ID: 6277688
If the user shrinks the form then the control will not shrink enough.  For example, with
DCube1.Width = iCubeWidth + diffWidth * 0.95542
assume that diffWidth is positive; you're fine, because this means that the control will grow slightly less than your form, still exposing the scroll bars.  However, if diffWidth is negative, then your control will shrink slightly less than your form, hiding the scroll bars.

See if this works:
if diffWidth < 0 then
DCube1.Width = iCubeWidth + diffWidth * 1.04458
else
DCube1.Width = iCubeWidth + diffWidth * 0.95542
endif
0
 
LVL 4

Accepted Solution

by:
VincentLawlor earned 400 total points
ID: 6277932
If it's always fills the form then use

DCube.With = Me.ScaleWidth
DCube.Height = Me.ScleHeight
DCube.Left = 0
DCube.Right = 0

Vin.
0
 
LVL 17

Expert Comment

by:inthedark
ID: 6278290
Yes VincentLawlor hit the nail on the head. The scalewidth is your bit.


Here are some more tips:

1) Correct the standard resize bug like what youve got.

Always put the following at the top of your form resize:

If Me.WindowState=vbminimized then exit sub

2) Always test the form With a minimize and a maximize and then back to normal.

3) Create a command button and place your resize code in the command button to test.  The form resize disables some objects making it hard to debug, like the mouse, for example.

When working put the code back into the resize.

This will stop the system becomming unstable which it can do in a resize event. And you loose your changes when you have to reboot.

4) Cool Enhancement to item 3 so that your form resize code will not cause your system to hang.

For a real professional approach.

If you have a complex resize wich make takes more than a few 1000ths of a second to complete, change your form resize to fire a timer.  In this way your application won't hang.  As Windows will call Form_Resize each time the mouse is moved, when in resize mode.

Sub Form_Resize()

LastResize=Timer
timerResize.Interval=100

End Sub

Sub timerResize()

Static ResizeTime as single
Dim ResizeStart as single

if ResizeTime<.001 then ResizeTime=.001

if timer-lastresize<ResizeTime then exit sub

timerResize.Interval=0

ResizeStart=Timer

' Now call the invisible Command button where you placed your your code to test the resize.
' In practive you would give the button a better name e.g. SUBResize (as Command1 is a bit of a naff name).

Call SUBResize.Click


ResizeTime=(Timer-ResizeTime)*1.5 ' allow some time for other windows functions and timers

End Sub


0
 

Author Comment

by:richardferron
ID: 6280668
Thank's Vincent it's exactly what I needed.  Thank's also to inthedark who completed the answer with excellent comments!  I would've like to give points to you both but it does'nt seem possible. Sorry inthedark .  

Richard
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question