954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

maximizing form

Hi

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

williamrojas78
Junior Poster
111 posts since Jun 2005
Reputation Points: 23
Solved Threads: 10
 

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.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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?

williamrojas78
Junior Poster
111 posts since Jun 2005
Reputation Points: 23
Solved Threads: 10
 

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

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

However, vbmaximizedMIGHT 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.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

williamrojas78
Junior Poster
111 posts since Jun 2005
Reputation Points: 23
Solved Threads: 10
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You