| View previous topic :: View next topic |
| Author |
Message |
dfuchs Newbie

Joined: 13 Jan 2004 Posts: 2
|
Posted: Tue Jan 13, 2004 2:52 pm Post subject: Getting parent dialog object from button? |
|
|
Hi,
I have a button and a List Box on a dialog. This dialog is opened from another script by executing this code as the result of another button on the parent(?) form being pressed:
oDlg = LoadDialog ("Standard", "dlgName")
oDlg.Execute()
And here is the function LoadDialog copied straight from the help:
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
If IsMissing(oLibContainer ) then
oLibContainer = DialogLibraries
End If
oLibContainer.LoadLibrary(LibName)
oLib = oLibContainer.GetByName(Libname)
oLibDialog = oLib.GetByName(DialogName)
oRuntimeDialog = CreateUnoDialog(oLibDialog)
LoadDialog() = oRuntimeDialog
End Function
In the dialog, when I click the button (let's call it btnA), I want to change the selected item in the List Box (lbxB). So, in the "On Initiation" event of btnA, I have dim'ed an object, set it to the result of LoadDialog(...), and tried calling getControl("lbxB") on it. However, it seems like this is not giving me control of the list box:
parentDialog = LoadDialog ("Standard", "dlgName")
cntl = parentDialog.getControl("lbxB")
cntl.DoSomethingWithThisControl
Is there any way to just get the parent dialog object of the button that is pressed from the On Initiation code of that button?
Sorry if this is confusing, and thanks in advance for the help!
Dan |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Jan 13, 2004 3:18 pm Post subject: |
|
|
What I have always done is to just put the dialog into a Private variable (visible in all modules in current library). Then when Sub's are called as controls on teh dialog are initiated, I can just access the dialog.
I have lots of examples of dialogs in Danny's Draw Power Tools. You can download Danny's Draw Power Tools from here....
http://ooomacros.org/files.php?type=macro#DannysDrawPowerTools
http://sourceforge.net/project/showfiles.php?group_id=87718&package_id=91518
The current (released) generation of Danny's Draw Power Tools makes extensive use of dialog boxes. So it might serve as a useful example. The next generation of Danny's Draw Power Tools (not yet released) does away with dialog boxes entirely, as I've found them extremely inconvenient to actually work with from a usability standpoint. (You can't close a document while a Basic dialog is on screen. Major Pain.)
Sorry not to directly answer your question. I do not know a way to walk the data structures from a control or its model to the dialog box (or its model). But I've never been motivated to try because of the Private variable technique I just described. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
dfuchs Newbie

Joined: 13 Jan 2004 Posts: 2
|
Posted: Wed Jan 14, 2004 2:03 pm Post subject: Thanks! |
|
|
Hey Danny,
Thanks a lot for your response and the code, I got it to work using the method you described!
Thanks,
Dan |
|
| Back to top |
|
 |
|
|
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
|