I'm sure this is a dumb question, but I just can't figure out how to do it. 
I've been programming in perl for years, but mainly for CGI scripting under 
linux, and Win32::GUI is quite new to me.

How do I destroy a win32::gui window object once I'm finished with it?

I can delete the reference/handle to it, but I'm not convinced that that 
actually frees up the win32 object that it referred to.

Alternatively, I've got this all wrong in my head, and I don't need to destroy 
the window at all.

Should I create all potential windows at startup, and then show() or hide() them as necessary, or should I create them dynamically as and when needed ?
If I take the latter approach, should I create it the first time it's needed, 
and then reuse it, or create and destroy it as needed each time the user needs 
to see that window ?


Background info:

What I want to do is this: I have a systray icon. For the systray_Click event, I want a window with a listview in it to pop up in the middle of the screen. I've currently got it working with show()/enable() and hide()/disable(), but this creates the problem where the window doesn't get elevated to the top if it is already open. I don't want to use -topmost=>1, because I don't want to force my window on the user if they want to hide it, but having said that, if they click on the systray icon, I want it to come to the front so they can see it.
I've also tried using SetFocus(), but that doesn't seem to work very well 
either - it certainly gives focus, but doesn't raise the window.

I then tried using Change() to set -topmost=>1 on the existing window, and then 
back to 0, but that didn't have any effect either. I even tried calling DoEvents 
after setting it to 1.

The only way I've managed to get it to consistently come to the top is to create a new window object each time. This leads me to believe that I should be destroying the previous one before creating a new one so as to avoid chewing up memory. But.. I can't figure out how to destroy an existing window.
Also, if the window is already on top, and the user clicks on the systray icon, 
I don't really want the window to be destroyed at all, because that makes the 
window flicker as it recreated. It would be tidier to just have it SetFocus in 
that situation, but I don't know how to detect if it is already on top.

And that's what leads me back to the questions at the top of the post.

Thanks.




Reply via email to