| View previous topic :: View next topic |
| Author |
Message |
Jesse General User

Joined: 01 Jul 2004 Posts: 7
|
Posted: Mon Oct 25, 2004 6:52 pm Post subject: How can center a dialog on the screen? |
|
|
| 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 |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Mon Oct 25, 2004 9:16 pm Post subject: |
|
|
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 |
|
 |
Jesse General User

Joined: 01 Jul 2004 Posts: 7
|
Posted: Mon Oct 25, 2004 11:54 pm Post subject: |
|
|
| Wonderful solution! greatly appreciate for your help! |
|
| Back to top |
|
 |
|