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

Bringing Frames in the Middle of a form!!? Pls Help

Status
Not open for further replies.

Fori

Programmer
Jun 18, 2003
84
0
0
MT
hi All,

I just want to make all controls (two frames) in the middle of the screen!! Is there a non-complicated version!! mine is very complicated (about 10lines!! ok maybe i exagerated but it doesn't work as i would like it too!!) !

Thanks
Nick
 
Assuming your Frame is named "fraFrame":
Code:
With fraFrame
  .Top = (frmForm.Height - .Height) / 2
  .Left = (frmForm.Width - .Width) / 2
End With

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
Andy, Don't mean to be facetious but using your code I've found a couple of glitches. These seemed to be fixed when changed to

[tt]
With fraFrame
.Top = (frmForm.ScaleHeight - .Height) / 2
.Left = (frmForm.ScaleWidth - .Width) / 2
End With
[/tt]

I don't exactly know why though!

As a pointer for Fori, This code works well in the Resize event of your form, so they stay in the center even if your user changes your form (unless it's Non-Resizable!).



jgjge3.gif
[tt]"Very funny, Scotty... Now Beam down my clothes."[/tt]
 
<Whistling very loudly>
Oh, did I mis-type ScaleHeight? Darn Intellisense.
</Whistling very loudly>

In truth I didn't actually test my code...

ScaleWidth would work, on reflection, because it reflects the internal size of the Form, rather than the external - which would be the Width. I refer you to my post yesterday regarding the fantastic-ness of my coding.

And no, I don't consider your comments facetious. Nice to know someone actually bothers to read my posts!

Andy
&quot;Logic is invincible because in order to combat logic it is necessary to use logic.&quot; -- Pierre Boutroux
&quot;Why does my program keep showing error messages every time something goes wrong?&quot;
 
You're fast becoming a good guy Andy.... be careful! lol


jgjge3.gif
[tt]&quot;Very funny, Scotty... Now Beam down my clothes.&quot;[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top