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

Resolution Problem with MDI

Status
Not open for further replies.

ashishjain

Programmer
Feb 20, 2002
32
IN
hi all,
I am developing a VB application. I have used MDI and desgined forms in 680x480 resolution. what i find when i change rosolution to some higher resolution like 600x800 or some other resolution, all the controls of the child form moves to the left. It doesn't look's good. Is there any work arround so i can able to show child form in center or all controls in center.

Thanx

 
I assume you are repositioning the controls yourself, as the controls should stay in place. If so, position your controls using Twips which are resolution-independant. Either that or recalculate the positions within the MDI form resize event.

VB sets the control positions in pixels. When you switch your screen to a higher resolution there are more pixels on the screen. 100 Pixels from the edge in 640x480 is going to be a bigger physical distance than 100 pixels from the edge in 800x600. Unfortunately VB6 will not dynamically resize forms (VB.NET will). You will need to write code to resize/reposition your controls.
 
A quick and easy way is to place all of the items on a frame, and when resizing the form, just reposition the frame to the center of the form, and the form to the center of the MDI:


me.Move (myMDI.ScaleWidth-Me.Width)\2,(myMDI.ScaleHeigth-Me.Heigth)\2

Frame1.Move (me.ScaleWidth-Frame1.Width)\2,(me.ScaleHeigth-Frame1.Heigth)\2
 
The controls do not move. They are "anchored" to the Left and Top of the form. At higher resolutions, there are more pixels to the right and toward the bottom. Each pixel is smaller so the controls appear smaller. Twips are not really independent of resolution. If they were then there would be more Twips Per Pixel at higher resolutions i.e. they would be proportional. They are not. There are 15 twips per pixel at every resolution. From 640x480 to 800x600 there is a 25% increase in proportions, so to maintain sizes, you would need to multiply the Left, Top, Width and Height of each control by 1.25 then increase the fontsize by 25%. But then there are controls like MSFlexGrid that have internal cell sizes and Toolbars that can not be resized. Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
My apologies - Twips are resolution-independant ... on Printers only.

Forms are always treated as being the same resolution regardless of actual display settings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top