| View previous topic :: View next topic |
| Author |
Message |
cbosdonnat Power User


Joined: 14 Nov 2004 Posts: 61 Location: France - Lyon
|
Posted: Tue Dec 14, 2004 5:59 am Post subject: Accessing components in Dialog with OOoBasic |
|
|
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 |
|
 |
cbosdonnat Power User


Joined: 14 Nov 2004 Posts: 61 Location: France - Lyon
|
Posted: Tue Dec 14, 2004 6:22 am Post subject: I learned by my self ... by it may help others |
|
|
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  _________________ Perso: http://cedric.bosdonnat.free.fr |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Tue Dec 14, 2004 12:32 pm Post subject: |
|
|
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 |
|
 |
alphaQ General User

Joined: 08 Sep 2004 Posts: 30 Location: New York, Cubao
|
Posted: Tue Dec 14, 2004 5:41 pm Post subject: |
|
|
What is the difference between:
Private Dlg As Variant
and
Public Dlg As Variant |
|
| Back to top |
|
 |
cbosdonnat Power User


Joined: 14 Nov 2004 Posts: 61 Location: France - Lyon
|
Posted: Sat Dec 18, 2004 12:01 am Post subject: |
|
|
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
Cedric _________________ Perso: http://cedric.bosdonnat.free.fr |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Sun Dec 19, 2004 9:08 pm Post subject: |
|
|
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 |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Mon Dec 20, 2004 11:36 am Post subject: |
|
|
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 |
|
 |
|