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

Accessing components in Dialog with OOoBasic

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


Joined: 14 Nov 2004
Posts: 61
Location: France - Lyon

PostPosted: Tue Dec 14, 2004 5:59 am    Post subject: Accessing components in Dialog with OOoBasic Reply with quote

Hi everybody,

I work on a dialog box with an event when there is a click on a chackbox ... but nevermind.

In the procedure called with this event in Basic I want to access to an other component of the dialog box ... Do you know how to do it ?
_________________
Perso: http://cedric.bosdonnat.free.fr
Back to top
View user's profile Send private message Visit poster's website
cbosdonnat
Power User
Power User


Joined: 14 Nov 2004
Posts: 61
Location: France - Lyon

PostPosted: Tue Dec 14, 2004 6:22 am    Post subject: I learned by my self ... by it may help others Reply with quote

I just have found a solution :

You have to write all your methods dealing with the dialog in the same module, then create a private global variable :

Code:

' Dlg_Test Module

Private Dlg As Variant

Sub Main
  DialogLibraries.LoadLibrary("Standard")
  Dlg = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
 
  Dlg.execute()
End Sub

Sub Clic (Event As Object)
    'access your Dlg without having to get it : you allready get it

End Sub


So you can access your dialog. But if somebody could give me a way to make it wihout a global variable it would be fun Wink
_________________
Perso: http://cedric.bosdonnat.free.fr
Back to top
View user's profile Send private message Visit poster's website
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Tue Dec 14, 2004 12:32 pm    Post subject: Reply with quote

You must use a global variable of some sort to store a pointer to the dialog, as you have done!
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
alphaQ
General User
General User


Joined: 08 Sep 2004
Posts: 30
Location: New York, Cubao

PostPosted: Tue Dec 14, 2004 5:41 pm    Post subject: Reply with quote

What is the difference between:
Private Dlg As Variant
and
Public Dlg As Variant
Back to top
View user's profile Send private message
cbosdonnat
Power User
Power User


Joined: 14 Nov 2004
Posts: 61
Location: France - Lyon

PostPosted: Sat Dec 18, 2004 12:01 am    Post subject: Reply with quote

Hi,


Thank you for your help ... I want to give an answer about Public and Private :

When you use Private, the variable is visible in the block where you declared it.
But Public means that the variable may be used by any other module or function.

This is a way to protect some variables Smile

Cedric
_________________
Perso: http://cedric.bosdonnat.free.fr
Back to top
View user's profile Send private message Visit poster's website
Cybb20
Super User
Super User


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

PostPosted: Sun Dec 19, 2004 9:08 pm    Post subject: Reply with quote

Private variables are only valid in its module,
Public variables are valid in all modules of the library.

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Dec 20, 2004 11:36 am    Post subject: Reply with quote

Is there any difference between Global and Public?

Doing a couple quick experiments (OOo 1.1.3, Win XP Pro).

Document 1 -- Module1
Code:
Public xyzzy1
Global xyzzy2
Private xyzzy3

Sub Main
   xyzzy1 = 101
   xyzzy2 = 102
   xyzzy3 = 103
   
   TestPrint()
End Sub


Document 1 -- Module2
Code:
Sub Main
   TestPrint()
End Sub

Sub TestPrint()
   Print xyzzy1
   Print xyzzy2
   Print xyzzy3
End Sub


Document 2 -- Module1
Code:
Sub Main
   Print xyzzy1
   Print xyzzy2
   Print xyzzy3
End Sub


When Document1 Module1 runs, it prints all three values. This means that Module2 can see all three vriables from Module1.

When Document1 Module2 is then run, it can only see the 2nd value xyzzy2. Therefore, a Global variable is not only publicly visible like Public, but also retains its value beyond the end of program execution.

When Document2 Module1 is run, it cannot see any of the values. Therefore both Public and Global only make the variable visible to other modules of the same library. (I did not try a different library of the same document! That would be work a test. But I'm insufficiently motivated.)
_________________
Want to make OOo Drawings like the colored flower design to the left?
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