PDA

View Full Version : How to destroy a rollout in a dockable window


madjeter
12-10-2008, 01:17 AM
Dear forum:

I created one rollout and add it to a dialog. Then I registered the dialog and make it docked to left. That is good. But I fount out that I can not run my script twice. Because it can not destroy the existing rollout, it shows the rollout twice there. I did add codes to destroy it but it must be failed. Here are my codes:

try(cui.UnRegisterDialogBar my_toolbar) catch()
DestroyDialog my_toolbar
removeRollout my_toolbar
createDialog my_toolbar 30 120
cui.RegisterDialogBar my_toolbar
cui.DockDialogBar my_toolbar #cui_dock_left

Here, my_toolbar is a rollout.
Please help me!
Thanks a lot!

Bobo
12-10-2008, 02:49 AM
Dear forum:

I created one rollout and add it to a dialog. Then I registered the dialog and make it docked to left. That is good. But I fount out that I can not run my script twice. Because it can not destroy the existing rollout, it shows the rollout twice there. I did add codes to destroy it but it must be failed. Here are my codes:

try(cui.UnRegisterDialogBar my_toolbar) catch()
DestroyDialog my_toolbar
removeRollout my_toolbar
createDialog my_toolbar 30 120
cui.RegisterDialogBar my_toolbar
cui.DockDialogBar my_toolbar #cui_dock_left

Here, my_toolbar is a rollout.
Please help me!
Thanks a lot!


The destruction code MUST be before any re-definition of the dialog's rollout. Otherwise, a NEW instance of the rollout will be created in memory and the destruction code will not be able to "see" the old rollout.


(
global my_toolbar --declare as global to be able to access it later
try(cui.UnRegisterDialogBar my_toolbar) catch() --try to undock
try(DestroyDialog my_toolbar)catch() --try to destroy

rollout my_toolbar "Toolbar" --now define the rollout
(
label lbl_01 "Testing"
)
--if the destruction code were here, it would "see" the new rollout and not the docked one
createDialog my_toolbar 30 120 --and create the dialog
cui.RegisterDialogBar my_toolbar --register as dialog bar
cui.DockDialogBar my_toolbar #cui_dock_left --and dock left
)

madjeter
12-11-2008, 12:05 AM
In fact, my codes define the rollout before destroy it. It goes like:
* rollout My_toolbar (...)
* define my ShowToolbar function, which contains codes:
a. unregister and destroy my_toolbar
b. creat new and register
But it does not work. After adding codes 'global my_toolbar' at the beginning of ShowToolbar function, it works.
Thanks a lot!

CGTalk Moderation
12-11-2008, 12:05 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.