OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How can center a dialog on the screen?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Jesse
General User
General User


Joined: 01 Jul 2004
Posts: 7

PostPosted: Mon Oct 25, 2004 6:52 pm    Post subject: How can center a dialog on the screen? Reply with quote

I created a dialog, and I find the method setPosSize ( SbxLONG, SbxLONG, SbxLONG, SbxLONG, SbxINTEGER ). but how can I get the height and width of the screen and form to make the dialog central?
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Mon Oct 25, 2004 9:16 pm    Post subject: Reply with quote

To make it fast, this is what I use:
Code:

 'the following lines center the Dialog on the Screen
 FramePosSize = ThisComponent.getCurrentController().Frame.getComponentWindow.PosSize
 xWindowPeer = oDlg.getPeer()
 CurPosSize = oDlg.getPosSize()
 WindowHeight = FramePosSize.Height
 WindowWidth = FramePosSize.Width
 DialogWidth = CurPosSize.Width
 DialogHeight = CurPosSize.Height
 iXPos = ((WindowWidth/2) - (DialogWidth/2))
 iYPos = ((WindowHeight/2) - (DialogHeight/2))
 oDlg.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, com.sun.star.awt.PosSize.POS)   


Hope this helps.
Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Jesse
General User
General User


Joined: 01 Jul 2004
Posts: 7

PostPosted: Mon Oct 25, 2004 11:54 pm    Post subject: Reply with quote

Wonderful solution! greatly appreciate for your help!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group