Jump to content

Can A Window Be Made Unmoveable?


Recommended Posts

I want to create a Window that pops up in the middle of the screen and is also non-moveable (like the Windows Shut Down Dialog). Is this possible?

Thanks,

Steve

Yes you can do this, but you have to mess with WM_MOVE and similar messages in your messageloop.
Link to comment
Share on other sites

I can get it centered, but the window is moveable to anywhere on the screen. The $WS_POPUP makes it non-moveable, but I still need the TITLE BAR and the CLOSE "X". What I need is the $WS_SYSMENU style with the $WS_POPUP nonmoveability. I can't find any combination of styles that gives me what I want.

Steve

Link to comment
Share on other sites

this will always snap to the centre

#include <GUIConstants.au3>
GUICreate("Test App", 200, 200, (@DesktopWidth/2)-100, (@DesktopHeight/2)-100)
GUISetState()
While 1
    WinMove("Test App", "", (@DesktopWidth/2)-100, (@DesktopHeight/2)-100)
    Sleep(10)
WEnd

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Razer beat me to it... but this also sets the window on top

#include <GUIConstants.au3>

$main = GUICreate ( "App", 200, 150, (@DesktopWidth/2)-100, (@DesktopHeight/2)-100)

$btn = GUICtrlCreateButton ( "Close", 20, 100, 150)
GUISetState (@SW_SHOW)   ; will display an empty dialog box

WinSetOnTop("App", "", 1)

While 1
    
    WinMove("App", "", (@DesktopWidth/2)-100, (@DesktopHeight/2)-100)
    
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Or $msg = $btn then Exit
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

my pathetic attempt

Opt("MouseCoordMode", 0)
#include <GuiConstants.au3>
GUICreate("", 200, 200, (@DesktopWidth/2)-100, (@DesktopHeight/2)-100, $WS_POPUP)
GUISetFont(13, 700)
GUICtrlCreateLabel("Title", 0, 0, 170, 30, $SS_CENTERimage)
GUICtrlSetBkColor(-1, 0x3333FF)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlCreateLabel("X", 170, 0, 30, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER))
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetFont(-1, 19, 700)
GUISetState()
While 1
    $MSG = GUIGetMsg()
    $POS = MouseGetPos()
    If $POS[0] > 170 And $POS[0] < 200 And $POS[1] > 0 And $POS[1] < 30 And _Ispressed('01') = 1 Then Exit
WEnd

Func _IsPressed($hexKey)
; _IsPressed will return 0 if the key is not pressed, 1 if it is.
 Local $aR
 $hexKey = '0x' & $hexKey
 $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
 If Not @error And BitAND($aR[0],0x8000) = 0x8000 Then Return 1
 Return 0
EndFunc;==>_IsPressed

no laughing please

edit: eliminated boarder

Edited by pecloe
Link to comment
Share on other sites

  • 3 weeks later...
  • Moderators

I saw someone reading this, so took a peek, it seemed like Gary hadn't seen it yet... so I thought I'd give it a try, I'm sure he will change it when he has seen it :) but here's an an attempt:

Global Const $WM_MOVING = 0x3
#include <GUIConstants.au3>

$main = GUICreate ( "App", 200, 150, (@DesktopWidth/2)-100, (@DesktopHeight/2)-100)

$btn = GUICtrlCreateButton ( "Close", 20, 100, 150)

GUIRegisterMsg($WM_MOVING, "_MY_WM_MOVE")

GUISetState ()

While 1 
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Or $msg = $btn then Exit
WEnd

Func _MY_WM_MOVE($hWndGUI, $MsgID, $WParam, $LParam)
    If $hWndGUI = $main Then
        Local $aWinPos = WinGetPos($hWndGUI, '')
        Local $iXPos = (@DesktopWidth / 2) - 100, $iYPos = (@DesktopHeight / 2) - 100
        If IsArray($aWinPos) And ($aWinPos[0] <> $iXPos Or $aWinPos[1] <> $iXPos) Then
            WinMove($hWndGUI, '', $iXPos, $iYPos)
        EndIf
    EndIf
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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