Sign in to follow this  
Followers 0
Dieuz

Lock GUI Windows

15 posts in this topic

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)

Share this post


Link to post
Share on other sites



$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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Dieuz

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by smashly

Share this post


Link to post
Share on other sites

#8 ·  Posted (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_POPUPWINDOW

That makes GUI a pop up and unable to move.

Maybe when user click Lock

GUIDelete orginal one,

Create new GUI exactly like that but have $WS_POPUP or $WS_POPUPWINDOW

Along assigning all the events.

Hope that helped.

Edited by Generator

Share this post


Link to post
Share on other sites

Learned!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

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 not

Dude, your answer still sounds weird. no offense.

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

You could try making AutoIt find the coordinates of the window upon locking, then resetting it to those coordinates every millisecond.

Share this post


Link to post
Share on other sites

$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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0