Jump to content

How to make this window (with a special style) unresizable?


Recommended Posts

Hello big-minds... too many questions i'm sorry :D

i have this simple form:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 345, 368, 192, 146, BitOR($WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_POPUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

i need to make the window unresizable keeping the same style, is that possible? :huh:

Link to comment
Share on other sites

You want to make the window not able to be resized, yet you included 2 style settings that do just that? Who wrote this for you?

Remove the $WS_SIZEBOX,$WS_THICKFRAME style settings from the GUICreate line and that should do it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Try this:

#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global Const $SC_DRAGMOVE = 0xF012
Global Const $iW = 345
Global Const $iH = 368
Global Const $hGUI = GUICreate("Unresizable Thickframe Window", $iW, $iH, -1, -1, BitOR($WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_POPUP))
GUISetState(@SW_SHOW)

Global Const $iWFrame = _WinAPI_GetSystemMetrics(32) * 2 - 2
Global Const $iHFrame = _WinAPI_GetSystemMetrics(33) * 2 - 2

GUIRegisterMsg($WM_SIZING, "WM_SIZING")
GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIRegisterMsg($WM_SIZING, "")
            GUIRegisterMsg($WM_LBUTTONDOWN, "")
            GUIDelete()
            Exit
    EndSwitch
WEnd

Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Local $sRect = DllStructCreate("Int[4]", $lParam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)
    Local $aWinPos = WinGetPos($hWnd)

    Switch $wParam
        Case 1 ;left
            DllStructSetData($sRect, 1, $aWinPos[0], 1)
        Case 2 ;right
            DllStructSetData($sRect, 1, $aWinPos[0] + $iW + $iWFrame, 3)
        Case 3 ;top
            DllStructSetData($sRect, 1, $aWinPos[1], 2)
        Case 6 ;buttom
            DllStructSetData($sRect, 1, $aWinPos[1] + $iH + $iHFrame, 4)

        Case 4 ;left upper corner
            DllStructSetData($sRect, 1, $aWinPos[0], 1)
            DllStructSetData($sRect, 1, $aWinPos[1], 2)
        Case 5 ;right upper corner
            DllStructSetData($sRect, 1, $aWinPos[1], 2)
            DllStructSetData($sRect, 1, $aWinPos[0] + $iW + $iWFrame, 3)
        Case 7 ;left buttom corner
            DllStructSetData($sRect, 1, $aWinPos[0], 1)
            DllStructSetData($sRect, 1, $aWinPos[1] + $iH + $iHFrame, 4)
        Case 8 ;right buttom corner
            DllStructSetData($sRect, 1, $aWinPos[0] + $iW + $iWFrame, 3)
            DllStructSetData($sRect, 1, $aWinPos[1] + $iH + $iHFrame, 4)
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_SIZING

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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