Ask Your Question
0

how to compose dialog invisibly?

asked 2019-11-29 12:22:45 +0100

dave jordan gravatar image

Is there a better order of instructions than this? The dialog does not always become visible before .execute() I have to resize near the end anyway -- maybe I should just start at .width & .height = 0 or 1?

tia,

-dave

sub tst

    dlgmdl = createunoservice("com.sun.star.awt.UnoControlDialogModel")
    with dlgmdl
        .name = "checkwriter"
        .title = "Check Writer"
        .positionx = 170
        .positiony = 70
        .width = 300
        .height = 100
    end with

    dlg = CreateUnoService("com.sun.star.awt.UnoControlDialog")
    dlg.setModel(dlgmdl)
    window = CreateUnoService("com.sun.star.awt.Toolkit")
    dlg.createPeer(window, null)

    dlg.setvisible(false)

    ctlmdl = dlgmdl.createinstance("com.sun.star.awt.UnoControlFixedTextModel")
    with ctlmdl
        .name = "HI"
        .label = "HI"
        .positionx = 10
        .positiony = 10
        .width = 20
        .height = 20
    end with

    dlgmdl.insertbyname("HI", ctlmdl)

    ' insert about 30 more controls...
    ' resize dialog as appropriate (varies)...

    dlg.setvisible(true)
    dlg.execute()   

end sub
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-11-29 18:59:31 +0100

Ratslinger gravatar image

updated 2019-11-30 22:24:05 +0100

Hello,

dlg.setvisible(true)
dlg.execute()

actually do somewhat the same thing but setting visible requires using a loop. This is mostly used for displaying a GUI developed dialog in a non-modal fashion. For an example see this post -> How to make non-modal dialog?

When creating a dialog using a macro is is easy to make the dialog non-modal by adding a setting to the dialog model. See answer in this post -> Dialog Modal with Basic IDE, Non-Modal with documents

Using setvisible in your sample is not needed and can be deleted. Execute will display the dialog.

In the document `Open Office Macros Explained by Andrew Pitonyak, there are some routines to make setting properties and inserting controls a bit easier. PDF here -> OOME. See Section 18 - Dialogs and Controls. Code mentioned is in -> 18.5.2. Creating a dialog at run time

Edit 2-19-11-30:

In reply to the comment, you can set width or height of the dialog anywhere you want - even in say a listener event. Of note though, if either is set to 0 (zero), that setting set to 0 will be ignored. So the smallest setting is 1,1. Can envision on the resize to simple change the title to something like Processing... and reduce the height to 1. Add the controls then set the new size.

Using Visible to hide and reveal the dialog seems to have it's problems. Positioning is one and hiding doesn't always seem to work. Other things seem to crop up every so often.

If modifying the dialog is the goal, you can add and delete controls from an event handler. Re-use of the dialog creation sub to do this requires special handling of the dialog execute statement to insure it is not run multiple times.

edit flag offensive delete link more

Comments

Well, both those examples use dialogs with predefined dimensions. My problem is i would like to define the dimensions after i have added the varying number of controls, and I would like to have the dialog hidden while the controls are being added so that the dialog window will not visibly resize itself in front of my users. The macro needs to recreate the dialog with a possibly different number of controls and run it every time it is needed.

dave jordan gravatar imagedave jordan ( 2019-11-29 22:48:05 +0100 )edit

Sorry, do not see this in your question as now stated. Only see comment about resizing near end of code. Possibly further explain your needs by editing your question.

May try later to use parameters input to construction for creation depending upon requirements.

This also seems to have some implication that the dialog will change based upon something the user does in the dialog. In that case maybe use steps in a dialog.

Ratslinger gravatar imageRatslinger ( 2019-11-29 23:57:04 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-11-29 12:22:45 +0100

Seen: 40 times

Last updated: Nov 30