Page 1 of 1

[Solved] How to position a dialog opened from another dialog

PostPosted: Thu Jul 31, 2008 2:03 pm
by grnhorn
When opening a dialog from another dialog, the new one may be any place on the screen. I tried the following code to control the position, but it seems to be ignored:

oDBDlg.PosSize.X = 100
oDBDlg.PosSize.Y = 10

The above code is also ignored if opening the dialog in BASIC. Any positioning set in the properties sheet is also ignored when ran. The only time the position can be controlled is during development. Is this a bug or is there an answer?

Thanks...

Re: How to position a dialog opened from another dialog?

PostPosted: Thu Jul 31, 2008 2:20 pm
by Villeroy
http://api.openoffice.org/docs/common/r ... setPosSize
http://api.openoffice.org/docs/common/r ... sSize.html
Code: Select all   Expand viewCollapse view
with com.sun.star.awt.PosSize
   nWhat= .X + .Y
end with
oDBDlg.setPositionSize(100, 10, 0, 0, nWhat)

sets X and Y while ignoring Width and Height.

Re: How to position a dialog opened from another dialog

PostPosted: Thu Jul 31, 2008 3:42 pm
by grnhorn
Thanks Villeroy. This works for a dialog that is being used by itself, but I still could not get it to work when calling a second dialog from a first. I did have to make one change and I completely understand how it happened: setPositionSize to setPosSize. One thing about code when you work with a bunch of them, they all look a like.
Code: Select all   Expand viewCollapse view
with com.sun.star.awt.PosSize
   nWhat= .X + .Y
end with
oDBDlg.setPosSize(100, 10, 0, 0, nWhat)

Re: How to position a dialog opened from another dialog?

PostPosted: Thu Jul 31, 2008 6:46 pm
by Villeroy
I don't know.

Re: How to position a dialog opened from another dialog?

PostPosted: Thu Jul 31, 2008 11:19 pm
by rmdemi
Hello Grnhorn,

Here is the code;

Code: Select all   Expand viewCollapse view
Private oform1, oform2  as Variant
Sub Form1show
oform1 = createUnoDialog(DialogLibraries.Standard.Dialog1)
oform1.setPosSize(0,0,,,3)
    oform1.execute

' You can Assign this macro a dialog1 buton or dialog1 event
Sub Form2show
oform2 = createUnoDialog(DialogLibraries.Standard.Dialog2)
oform2.setPosSize(0,200,,,3)
    oform2.execute
End Sub
End Sub



The fifth parameter is for flag in our example set to 3
The description of flags adress is here. http://api.openoffice.org/docs/common/ref/com/sun/star/awt/PosSize.html

Dialog1 and Dialog2 come from dialog editor's dialog modules,

setPosSize Methods' Details
setPosSize
[oneway] void
setPosSize( [in] long X,
[in] long Y,
[in] long Width,
[in] long Height,
[in] short Flags );

Description
sets the outer bounds of the window.
Parameter X ; the x-coordinate of the window.
Parameter Y ; the y-coordinate of the window.
Parameter Width ; the width of the window.
Parameter Height ; the height of the window.
Parameter Flags
Flags are of type PosSize and specify, which parameters are taken into account when setting the outer bounds of the window.

This code is working well

Cheers. :)

[Solved] How to position a dialog opened from another dialog

PostPosted: Thu Jul 31, 2008 11:56 pm
by grnhorn
Thanks rmdemi and villeroy, I think I understand what is happening now. The second dialog is opening relative to the first and each succeeding dialog opens relative to the previous. There are 2 solutions. 1) close the 1st dialog before opening the 2nd or 2) use the code below and set negative (-100) to move the 2nd dialog further left or higher then the 1st dialog. Positive numbers will move to the right or down. rmdemi (above) has supplied a link for all of the flags.

Both pieces of code above will work, just apply the positive and negative rules for the position.

Thanks all...