HighGuy Posted January 7, 2005 Share Posted January 7, 2005 Hi, if I disabe and enable a window with GuiSetState() my window is in the background afterwards. Is this a bug or a feature ? Here is the code of the ListView-sample with two lines added by me. Click on the Value?-button when this example is running in the forground of two windows. #include <GUIConstants.au3> GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES) GUISetBkColor (0x00E0FFFF) ; will change background color $listview = GuiCtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING) $button = GuiCtrlCreateButton ("Value?",75,170,70,20) $item1=GuiCtrlCreateListViewItem("item2|col22|col23",$listview) $item2=GuiCtrlCreateListViewItem("item1|col12|col13",$listview) $item3=GuiCtrlCreateListViewItem("item3|col32|col33",$listview) $input1=GuiCtrlCreateInput("",20,200, 150) GuiCtrlSetState(-1,$GUI_ACCEPTFILES) ; to allow drag and dropping GuiSetState() GUICtrlSetData($item2,"ITEM1") GUICtrlSetData($item3,"||COL33") GUICtrlDelete($item1) Do $msg = GuiGetMsg () Select Case $msg = $button GuiSetState (@SW_DISABLE ); --> added by me MsgBox(0,"listview item",GuiCtrlRead(GuiCtrlRead($listview)),2) GuiSetState (@SW_ENABLE ); --> added by me Case $msg = $listview MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2) EndSelect Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
jpm Posted January 7, 2005 Share Posted January 7, 2005 The problem comes from the msgbox not from the GuiSetState. I see that each time I put an msgbox not sure it is a bug or a window behavior. Link to comment Share on other sites More sharing options...
idbirch Posted April 28, 2009 Share Posted April 28, 2009 Is anyone else still getting this behaviour? Running everything from Windows XP to Windows 7, I still get this and it's very frustrating. In some sample code, removing a message box does fix it but so does removing the GuiSetState enable/disables so it's not just the message box's fault. #include <GUIConstants.au3> $Form_Main = GUICreate("Test", 219, 212, 303, 219) $Button1 = GUICtrlCreateButton("Test", 48, 152, 115, 41, 0) $ListView1 = GUICtrlCreateListView("", 8, 8, 202, 134) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _FocusScrewed() EndSwitch WEnd Func _FocusScrewed() GUISetState ( @SW_DISABLE, $Form_Main ) MsgBox(262160,"Information","I will now screw your focus") GUISetState ( @SW_ENABLE, $Form_Main ) EndFunc In a full app I have written, it does this with no message box at all and in that case, removing the GuiSetState enable/disable solves the problem so GuiSetState must be playing some part in this. I can't work out what it is in my app that GuiSetState doesn't like but I can PM the full source code to someone if they're willing to take look. Link to comment Share on other sites More sharing options...
martin Posted April 28, 2009 Share Posted April 28, 2009 Is anyone else still getting this behaviour? Running everything from Windows XP to Windows 7, I still get this and it's very frustrating. In some sample code, removing a message box does fix it but so does removing the GuiSetState enable/disables so it's not just the message box's fault. #include <GUIConstants.au3> $Form_Main = GUICreate("Test", 219, 212, 303, 219) $Button1 = GUICtrlCreateButton("Test", 48, 152, 115, 41, 0) $ListView1 = GUICtrlCreateListView("", 8, 8, 202, 134) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _FocusScrewed() EndSwitch WEnd Func _FocusScrewed() GUISetState ( @SW_DISABLE, $Form_Main ) MsgBox(262160,"Information","I will now screw your focus") GUISetState ( @SW_ENABLE, $Form_Main ) EndFunc In a full app I have written, it does this with no message box at all and in that case, removing the GuiSetState enable/disable solves the problem so GuiSetState must be playing some part in this. I can't work out what it is in my app that GuiSetState doesn't like but I can PM the full source code to someone if they're willing to take look.I think it's a WIndows characteristic perhaps, I get the same sort of problem with all sorts of non AutoIt applications. You can easily fix it by adding the parent to the MsgBox MsgBox(262160,"Information","I will now screw your focus",0,$Form_Main);no you won't! Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
idbirch Posted April 28, 2009 Share Posted April 28, 2009 Thanks, that will solve the cases where a messagebox is causing the issue but the problem remains that GuiSetState is capable of causing this with no messagebox present. Does anyone now why this might be? Link to comment Share on other sites More sharing options...
martin Posted April 29, 2009 Share Posted April 29, 2009 Thanks, that will solve the cases where a messagebox is causing the issue but the problem remains that GuiSetState is capable of causing this with no messagebox present. Does anyone now why this might be?You could just add WinActivate after the GuiSetState. It fixes the problem maybe but doesn't explain why it happens, although I think you only get the problem if the focus moves to another window after it's set to disabled. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
YellowLab Posted May 2, 2009 Share Posted May 2, 2009 (edited) Check out this thread:http://www.autoitscript.com/forum/index.ph...mp;hl=SW_ENABLEI found out how to prevent it...Use a custom box and disable the main, enable the custom. On return, enable the main first and disable the custom.Bob Edited May 2, 2009 by YellowLab You can't see a rainbow without first experiencing the rain. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now