Paolo Mantovani wrote:

> Hi Laurent,
> 
> Alle 13:58, giovedì 20 aprile 2006, Laurent Godard ha scritto:
>> Hi Paolo
>>
>> > It sounds quite strange to me that a UNOControlDialog behaves as
>> > non-modal.
>>
>> a hack iirc is to set the visible property to true
>> do not use execute
>> but loop over a global boolean to detect a stop set
>> do not forget a wait statement in the loop to allow other process to
>> work :-)
>>
>> the global idea (tested a long time ago)
> [...]
>> Feel free to ask, i may find some old code
> 
> Np, your example is perfectly understandable 
> It works!
> 
> Cool!! I didn't know this trick! :-)

It's not a trick - all vcl based dialogs can be executed either modal
(using execute) or modeless (using setVisible(True)). But this alone is
not enough, a dialog started with setVisible is still a modal one if you
have a polling loop like in Laurents example, the only difference is
that the modality is in the macro code and not in VCL (where BTW it
takes *much* less CPU cycles to do nothing except waiting).

There might be another unexpected side effect with the basic loop: the
existence of such a loop (either in Basic or in VCL) makes it necessary
to prevent the closing(/destruction of the dialog or its parent window
before the loop ends (otherwise a crash will happen sooner or later).
For this reason VCL disables the parent window of the dialog so that you
can't close it while the excute() call is done.

It's possible that in the example with the Basic loop where vcl doesn't
know about this modality the parent window is not disabled and so you
can shoot yourself in the foot by closing the parent window while the
dialog is waiting for input. You can try it out, but please try the
Basic IDE and a document window as a parent (by starting the macro from
inside either one), they might behave differently here.

A "real" modeless treatment that does not suffer from this pain needs
that your macro terminates after the dialog is shown (no wait loop!) and
"sleeps" until a callback from the dialog awakes it again (click
handler). AFAIK this means that your dialog must be kept in a global
variable so that termination of your macro does not kill the dialog
automatically.

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [EMAIL PROTECTED] is a spam sink.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to