Jump to content

Enable Window Without Minimizing It


Sunaj
 Share

Recommended Posts

Hi, I have a slight problem with my application, I need to open a child window & disable the mother window while the child is open (i.e. force the user to react to the opened window). The thing is that when using @SW_ENABLE to bring mother window back to life the window is automatically moved '1 window' back in the z-order (?!).. this forces me to use @SW_RESTORE - and the end-result is that there is quite a bit of unnessary GUI flickering on the screen, do any of you have an idea as to how to avoid this situation?! (btw, flicker does not appear in this example due to minimal GUI but I think it illustrates problem well enough...)

Guess the optimal solution would be a disable/enable parameter pair that simply does not minimize the mother GUI..? Anyway, here is the code!

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$tabbed_options = GUICreate("Motherwindow", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUISetState(@SW_SHOW)

$NoticeBox=0

While 1
  Sleep(500)
WEnd

Func OKButton()
  _NoticeBox("ChildWindow", "Child Window Opened")
EndFunc

Func CLOSEClicked()
  Exit
EndFunc

Func _NoticeBox($s_Caption,$s_Text)
    $size = WinGetPos ($tabbed_options)
    GUISetState (@SW_DISABLE, $tabbed_options) ; Mother is disabled
    $NoticeBox = GUICreate($s_Caption,335,118,($size[2]/2)-(335 / 2),($size[3]/2)-(118 / 2),"",$WS_EX_MDICHILD,$tabbed_options)
    $NoticeBox_Ok_Button = GUICtrlCreateButton ("OK",126,57,70)
    GUICtrlSetOnEvent($NoticeBox_Ok_Button, "NoticeBox_Ok_Button")
    GUICtrlCreateLabel($s_Text,40,23)
    GUISetState(@SW_SHOW,$NoticeBox)
EndFunc

Func NoticeBox_Ok_Button()
    GUIDelete($NoticeBox)
    GUISetState (@SW_ENABLE, $tabbed_options) ; Mother is enabled
    ; GUISetState (@SW_RESTORE, $tabbed_options) ; When not set Motherwindow stays moved '1 window' back in the z-order
EndFunc

Edit: bold on main problem..

Edit: emphasized z-order aspect..

Edited by Sunaj
Link to comment
Share on other sites

Hi Icekirby1, I know that msgbox will pause the script. Try and go into SciTE and press "Open File" - you see how the OpenFileBox is enabled and still tied to the overall SciTE app (which is disabled) and when u try and click the disabled SciTE app the OpenFileBox flashes a few times - that is the -exact- effect I'm trying to mimic, almost all Windows XP..etc applications uses this approach. The problem outlined in my first posting is still unsolved.

Seems the @SW_DISABLE/@SW_ENABLE combo causes a mess up in the z-order of the opened windows.. a bug in AutoIt? (possibly verify it through example provided, I'll check back on subject tomorrow morning, so far its the same whether i use the beta or not)

MsgBox will pause the script until a response is chosen. I don't understand you disabling an entire window, and I didn't even think that would work.

Edited by Sunaj
Link to comment
Share on other sites

:whistle: I really need someone to look at this.. at least to verify whether it should be filed as a bug or its just a odd thing in my code causing it! ;)

Seems the @SW_DISABLE/@SW_ENABLE combo causes a mess up in the z-order of the opened windows.. a bug in AutoIt? (possibly verify it through example provided (if example is opened from SciTE it will be easy to observe), so far the issue remains whether i use the beta or not).

Link to comment
Share on other sites

I do not know what you mean by flicker or "the window is automatically moved '1 window' back in the z-order" but i thinkI also have a similar problem with my main gui minimizing after a messagebox.

I m currently not using the beta but i suspect that its a problem with my coding because Ive never really understood most of the GUI control styles. I remember reading about using a Gui style to avoid flicker.

Edited by Cue
Link to comment
Share on other sites

Guess I would recommend just to use GUISetState(@SW_HIDE,$NoticeBox) since then no data is lost, instead of GUIDelete($NoticeBox), if this is not what you want explane it the way anyone can understand you.

Func _NoticeBox($s_Caption,$s_Text)
    $size = WinGetPos ($tabbed_options)
    $NoticeBox = GUICreate($s_Caption,335,118,($size[2]/2)-(335 / 2),($size[3]/2)-(118 / 2),"",$WS_EX_MDICHILD,$tabbed_options)
    $NoticeBox_Ok_Button = GUICtrlCreateButton ("OK",126,57,70)
    GUICtrlSetOnEvent($NoticeBox_Ok_Button, "NoticeBox_Ok_Button")
    GUICtrlCreateLabel($s_Text,40,23)
    GUISetState(@SW_SHOW,$NoticeBox)
EndFunc

Func NoticeBox_Ok_Button()
    GUISetState(@SW_HIDE,$NoticeBox) ; simply Hide the NoticeBox
EndFunc
Link to comment
Share on other sites

Thanks for your input chie (I think we understand each other just fine) - I think this topic thread can be considered closed since I found a much cleaner and better solution in this thread (involves DllCall, so anyone trying to avoid DllCalls (?..) may want to try your proposed solution)!

Guess I would recommend just to use GUISetState(@SW_HIDE,$NoticeBox) since then no data is lost, instead of GUIDelete($NoticeBox), if this is not what you want explane it the way anyone can understand you.

Func _NoticeBox($s_Caption,$s_Text)
    $size = WinGetPos ($tabbed_options)
    $NoticeBox = GUICreate($s_Caption,335,118,($size[2]/2)-(335 / 2),($size[3]/2)-(118 / 2),"",$WS_EX_MDICHILD,$tabbed_options)
    $NoticeBox_Ok_Button = GUICtrlCreateButton ("OK",126,57,70)
    GUICtrlSetOnEvent($NoticeBox_Ok_Button, "NoticeBox_Ok_Button")
    GUICtrlCreateLabel($s_Text,40,23)
    GUISetState(@SW_SHOW,$NoticeBox)
EndFunc

Func NoticeBox_Ok_Button()
    GUISetState(@SW_HIDE,$NoticeBox) ; simply Hide the NoticeBox
EndFunc
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...