Dieuz Posted April 25, 2007 Share Posted April 25, 2007 Hi, How can I set a GUI windows to be lock on the screen (the user cannot move it)? I thought of this but it doesnt work! $GUI = GuiCreate("", 200, 230,336, 4,$WS_CAPTION) GuiSetstate(@SW_LOCK) Link to comment Share on other sites More sharing options...
BillLuvsU Posted April 25, 2007 Share Posted April 25, 2007 $pos = WinGetPos If $pos[0] <> $desiredx or $pos[1] <> $desiredy Then WinMove( $desiredx, $desiredy ) [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
Dieuz Posted April 25, 2007 Author Share Posted April 25, 2007 (edited) Is there anything simple than that? I have a Menu and when the user select "Lock", I want that the selected window to be locked. That mean the user cannot move it around until he unlock it. Im looking for something simple as GuiSetState. Edited April 25, 2007 by Dieuz Link to comment Share on other sites More sharing options...
evilertoaster Posted April 25, 2007 Share Posted April 25, 2007 GUICreate("test") GUISetState(@SW_SHOW) GUISetState(@SW_DISABLE) while 1 WEnd Although you can't interact with it anymore Link to comment Share on other sites More sharing options...
Dieuz Posted April 26, 2007 Author Share Posted April 26, 2007 Hmmm... that wont fit my need. The only thing I want is that the user cannot move the window but he have to be able to interact with it. Link to comment Share on other sites More sharing options...
Bert Posted April 26, 2007 Share Posted April 26, 2007 ummm...why? sounds like you want to put a ad in their face and force them to interact with it. no offense....but it does sound suspicious .... The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
smashly Posted April 26, 2007 Share Posted April 26, 2007 (edited) I think fear1313's suggestion would do close to what your after. I just tried an example using his advice and it works ok. #include <GUIConstants.au3> Global $State[3] $gui = GUICreate('Window Unlocked',220, 70 -1, -1 ) $Button = GUICtrlCreateButton('Lock Window', 64, 10, 88, 50) GUISetState(@SW_SHOW, $gui) While 1 If $State[0] = 1 Then $winpos = WinGetPos($gui) If $winpos[0] <> $State[1] Or $winpos[1] <> $State[2] Then WinMove($gui,'', $State[1], $State[2]) EndIf EndIf $msg = GUIGetMsg() Select Case $msg = $Button If $State[0] = 0 Then $State[0] = 1 $pos = WinGetPos($gui) $State[1] = $Pos[0] $State[2] = $Pos[1] GUICtrlSetData($Button, 'Unlock Window') WinSetTitle($gui, '', 'Window Locked') Else $State[0] = 0 GUICtrlSetData($Button, 'Lock Window') WinSetTitle($gui, '', 'Window Unlocked') EndIf Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Cheers. Edited April 26, 2007 by smashly Link to comment Share on other sites More sharing options...
Generator Posted April 29, 2007 Share Posted April 29, 2007 (edited) @Volly: I dont wanna do anything suspicious. I just want the user to decide if he want to lock thee Gui window or not@Smashly: Thx! The only problem is that you can move the window but it bring it back to it original place after you move it.Is there a way to make the window impossible to move?I got an idea.In GUICreation, you can choose style $WS_POPUP or $WS_POPUPWINDOWThat makes GUI a pop up and unable to move.Maybe when user click LockGUIDelete orginal one,Create new GUI exactly like that but have $WS_POPUP or $WS_POPUPWINDOWAlong assigning all the events.Hope that helped. Edited April 29, 2007 by Generator Link to comment Share on other sites More sharing options...
chenxian00 Posted April 29, 2007 Share Posted April 29, 2007 Learned! Link to comment Share on other sites More sharing options...
martin Posted April 29, 2007 Share Posted April 29, 2007 Learned!Can't you just change the styles rather than delete and recreate? 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...
Dieuz Posted April 29, 2007 Author Share Posted April 29, 2007 @Volly: I dont wanna do anything suspicious. I just want the user to decide if he want to lock thee Gui window or not @Smashly: Thx! The only problem is that you can move the window but it bring it back to it original place after you move it. Is there a way to make the window impossible to move? If I use $WS_POPUP, it delete the title bar so that wont work Link to comment Share on other sites More sharing options...
Bert Posted April 29, 2007 Share Posted April 29, 2007 If you are giving the user a choice, then why make it so they can't move it? If the user doesn't want to move it, they won't. If you give them a button, an they don't click it, the GUI can be moved. So, what's the point?I just want the user to decide if he want to lock thee Gui window or notDude, your answer still sounds weird. no offense. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
gsb Posted April 29, 2007 Share Posted April 29, 2007 Perhaps you could do away with the title bar completely and draw your own "look-alike" in its place. Then you could easily enable/disable the drag functionality. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
Tomohashi Posted April 29, 2007 Share Posted April 29, 2007 You could try making AutoIt find the coordinates of the window upon locking, then resetting it to those coordinates every millisecond. Link to comment Share on other sites More sharing options...
Generator Posted April 29, 2007 Share Posted April 29, 2007 $pos = WinGetPos If $pos[0] <> $desiredx or $pos[1] <> $desiredy Then WinMove( $desiredx, $desiredy ) You could try making AutoIt find the coordinates of the window upon locking, then resetting it to those coordinates every millisecond.You are repeating his idea. Use AdibeEnable to check the WinPos every 100 ms, or use my way. Delete GUI when select lock and recreate 1 with popup style, just try to get your menu back in. 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