Jump to content

How to get Close option on taskbar when using $WS_POPUP?


qwert
 Share

Recommended Posts

I use GUICreate with the $WS_POPUP option to build a frameless draggable image ... and it works well.

The problem is, there's no clear way for the user to close the window. I don't want to use the ESC/GetMessage method that is often used for testing. Is there a way to enable the Close option of the window's taskbar entry? Apparently for popups, those options are defaulted to NONE, which I can understand for Maximize and Minimize ... but what about Close?

Thanks for any help with this.

post-29172-0-25841700-1331613465_thumb.p

Link to comment
Share on other sites

Strange enough the right click taskbar menu exists on Win7 but not on XP using $WS_POPUP :oops: . Using this style combo the behavior is the same for both OS.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("My GUI", Default, Default, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP))
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
Link to comment
Share on other sites

KaFu, that's definitely on the right track. Adding $WS_SYSMENU activated the taskbar menu. But I running with On Event Mode, and adding GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunction") doesn't cause the xClose to be acted upon.

If I place a Close Button on the image (GUI) and add a GUICtrlSetOnEvent, that Close Button works ... but xClose still doesn't.

Any ideas?

Edit: One more thing: I added a second button to bring up a MsgBox from the image GUI ... and the xClose can close the MsgBox, so there's definitely an active association from the taskbar entry to the GUI.

Edited by qwert
Link to comment
Share on other sites

Link to comment
Share on other sites

KaFu, thanks for looking into this. Indeed, I think your suggestion is the right one for all normal GUIs.

But the particular one I'm working on is compounded by $WS_EX_LAYERED AND $WS_EX_MDICHILD, so there are really two GUIs. I'll bet the xClose is "connected" to the wrong GUI ... the child instead of the parent, for example.

I'll just have to start disecting until I can get some simple case that reveals the answer. But you've put me on the right track.

Thanks, again for you help.

Link to comment
Share on other sites

Solved! ... by one of the first things I tried. I moved the GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunction") statement to be immediately after the GUICreate Parent. It was down after the Create Child statement, just before the While 1 loop.

I didn't know that OnEvent's were associated this way. Indeed, it may only be in certain circumstances ... but this seems to be one of them

Anyway, it works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...