I am using VB.net created a palette。 I need to call refresh drawing(my own function) when user close this palette. But I don't know which event I need to put my code in
Thanks very much
Do you mean closing a PaletteSet, or a Palette in a PaletteSet (if so, how your code let user to close a Palette in a PaletteSet? Set the user control invisible, or remove the user control from the PaletteSet)?
For the former, PaletteSet fires an event "PaletteSetStateChanged" when its visibility is changed. That is, when user click the "x" on the even fires. So, you can handle this event with information provided in the PaletteSetStateChangedeventArgs.
For the latter, you may have to derive your PaletteSet from PaletteSet class and create your own event when user control is added/removed to the PaletteSet, or when the user control's visibility changed. Note, PaletteSet is inheritable only since Acad2009.
Also, since PletteSet is a modeless window, it seems odd that you need to "refresh" (by regenerating?) the drawing on its closing. Usually, the drawing should be updated right after the change is done in the paletteset if the change affects the drawing. "Update drawing after winodw closiing" is usually applied to modal window.
Thanks for your reply.
I meant to close paletteset. on the palette there are 2 buttons on the top right corner. one looks like "-", the other one looks like "x". "-" is for hide and "x" is for close. click either button can trigger statechange event, but new state all =hide.
I would like to do something when user click "x" but not "-"
any ideas ?
Teh StateChanged event always fires when click "x" at the top corner of the PaletteSet.
However, clicking "-" to set "auto-hide" on or off that causes the PaletteSet to be hidden partially (e.g. the PaletteSet's window bar is still visible while its working area is hidden. Iin this case, it is arguable to say a PaletteSet is visible or not :-() would cause the StateChanged event firing or not firing, depending on if the PaletteSet is docked or not.
In my test, if the PaletteSet is floating (not docked), then when the main part of the PaletteSet becomes hidden (automatically after mouse cursor leaves from it a few seconds), the StateChange event will not fire. When puttiing mouse cursor onto the PaletteSet's winodws bar to cause the PaletteSet working area being shown, the StateChange event also does not fire. That is, when the PaletteSet is floating, StateChanged event only fires when user click "x" or when your code to set PaletteSet.Visible=true.
When the PaletteSet is docked, clicking both "x" and "-" cuases StateChanged event fire with NewState index as "Hide". But "x" set entire PaletteSet invisible, while "-" leave the PaletteSet's window bar still docked and visible (auto-hide). Placing mouse curosr on the docked PaletteSet window bar causes the PaletteSet's work area poping out and StateChanged event firing with NewState index as "Show". However, when the PaletteSet's work area automatically hides back, no StateChanged event fires.
So, if you need to do something when the PaletteSet becomes fully invisible (clicked "x") or partially (auto-hiding), you need to do it depending on if the PaletteSet is docked or not, by examing PaletteSet.Dock property.
Thanks for your reply.
I did the same testing. if the paletteset is docked. the first time I click "-" fires statechange and make the paletteset autohide. "x" also fires stagechange and make the paletteset fully invisible. There is no way I can tell the different between those 2 clicks. At least I didn't find any.
What I meant is between the first click "hide" and "close" when paletteset docked they both trigger event statechange and both pass new state =hide.
I don't think you can tell the difference between "hide" and "close" events.
Only thing I can think of is to provide your own close button and hide the close button from your PaletteSet. To do this you can set the PaletteSet Style property and omit the PaletteSetStyles.ShowCloseButton enumeration, e.g. in C#:
ps.Style = PaletteSetStyles.NameEditable |
Hope this helps.
Just stumbled across this series of through-the-interface posts. Problem solved!
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register