-
Centering within MDI Form
Can someone please tell me how to center an MDI child form within a parent
form?
I'm trying to find a way to code this without having to check the user's
resolution settings and then coding the screen positions. The property
"StartupPosition - 2 - CenterScreen" does not work and I tried to use the
following code:
--------------------------
Call Centerform (Me)
-------------------------
Sub CenterForm (inform as Form)
inform.Move (Screen.Width - inform.Width) /2, (screen.Height -
inform.Height) /2
End Sub
However this code doesn't work well if you have a toolbar within the MDI
form.
Any help would be appreciated!
-
Re: Centering within MDI Form
Michelle,
Try this:
'==========
CenterForm Me, MDIForm1
'==========
Sub CenterForm(frm As Form, inFrm As Form)
frm.Move (inFrm.ScaleWidth - frm.Width) \ 2, (inFrm.ScaleHeight -
frm.Height) \ 2
End Sub
Regards,
Shawn K. Hall
Programmer / Analyst
*Please* post/respond in the newsgroups!
http://i.am/shawnkhall
"Michelle" <mychelle@rcn.com> wrote in message
news:3945603f@news.devx.com...
>
> Can someone please tell me how to center an MDI child form within a
parent
> form?
>
> I'm trying to find a way to code this without having to check the
user's
> resolution settings and then coding the screen positions. The
property
> "StartupPosition - 2 - CenterScreen" does not work and I tried to
use the
> following code:
> --------------------------
> Call Centerform (Me)
> -------------------------
> Sub CenterForm (inform as Form)
> inform.Move (Screen.Width - inform.Width) /2, (screen.Height -
> inform.Height) /2
> End Sub
>
> However this code doesn't work well if you have a toolbar within the
MDI
> form.
>
> Any help would be appreciated!
>
>
-
Re: Centering within MDI Form
Thanks for your help Shawn! Your code worked!
Michelle
"Shawn K. Hall" <shawnkhall@iname.com> wrote:
>Michelle,
>
>Try this:
>
>'==========
> CenterForm Me, MDIForm1
>'==========
>Sub CenterForm(frm As Form, inFrm As Form)
> frm.Move (inFrm.ScaleWidth - frm.Width) \ 2, (inFrm.ScaleHeight -
>frm.Height) \ 2
>End Sub
>
>Regards,
>
>Shawn K. Hall
>Programmer / Analyst
>*Please* post/respond in the newsgroups!
>http://i.am/shawnkhall
>
>
>"Michelle" <mychelle@rcn.com> wrote in message
>news:3945603f@news.devx.com...
>>
>> Can someone please tell me how to center an MDI child form within a
>parent
>> form?
>>
>> I'm trying to find a way to code this without having to check the
>user's
>> resolution settings and then coding the screen positions. The
>property
>> "StartupPosition - 2 - CenterScreen" does not work and I tried to
>use the
>> following code:
>> --------------------------
>> Call Centerform (Me)
>> -------------------------
>> Sub CenterForm (inform as Form)
>> inform.Move (Screen.Width - inform.Width) /2, (screen.Height -
>> inform.Height) /2
>> End Sub
>>
>> However this code doesn't work well if you have a toolbar within the
>MDI
>> form.
>>
>> Any help would be appreciated!
>>
>>
>
>
-
Re: Centering within MDI Form
You're welcome.
--
Shawn K. Hall
Programmer / Analyst
*Please* post/respond in the newsgroups!
http://i.am/shawnkhall
"Michelle" <mychelle@rcn.com> wrote in message
news:39457e26$1@news.devx.com...
>
> Thanks for your help Shawn! Your code worked!
>
> Michelle
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks