i have a form with a mschart and a msflexgrid in it. What i want to do is that when the form is maximized, scale these two components and move the rest of them (command buttons, combo boxes, etc)

I would apprecciate your help

Re: maximizing form 80 80

in the form_resize event, you should be able to simple adjust the properties of the controls you want to mess with. For example, when the form gets resized (maximized) you can figure out the percentage and ratio, and use the .top, .left, .width and .height properties of any control:

command1.height = 5
command1.width = 10
command1.top = 0
command1.left = 0

For example..... let me know what you figure out.

Re: maximizing form 80 80

well first of all thanks for your quick response

But, do I have to do it manually for each control? is there an option to do them all at once?

Another point that I did not specify, is that the form_resize event of the form is executed when the form is loaded, how do i verify if the form is maximized, do i have to compare the actual width with the original size or is there another way?

Re: maximizing form 80 80

You should be able to do a simple text like...

if form1.state = vbmaximized then
     ' /* Code For Maximized Form */
end if

However, vbmaximized MIGHT NOT be a constant, but numbers work, I believe 2 is maximized, but I could be mistaken. Also, The property might not be state, it might be style or something similar. So, Just test the property to find out if it's maximized or not.

As for adjusting the controls, you could do a loop of the control's collection, but you are going to be using a lot of comparisions to figure out the type of control you are working with. A Textbox doesn't have a caption property, for example, so you need to be aware of the differences involved with the properties of certain objects. I believe you can do a simple:

for each XCtrl in Controls
     msgbox XCtrl
next XCtrl

Then you could adjust them all with their properties in a simple for each loop. I hope this helps some.

Re: maximizing form 80 80

Great, i know what to do now, i used the first suggestion,

by the way, the code will be:

If frmGraphs.WindowState = vbMaximized Then

' /* Code For Maximized Form */

End If

Thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.