Sign in to follow this  
Followers 0
JonatanRaven

GUI movable and non-resizable?

21 posts in this topic

#1 ·  Posted (edited)

Dabbling a bit with GUI at the moment and trying to change the looks of the windows I create but I can't seem to get it to work the way I want it to.

I can get it to look the way I want it to but not behave the way I want to.

Posted Image

Basically, I want that frame but still be able to move the window around.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;Opt("GUIOnEventMode", 1)  ;0=disabled, 1=OnEvent mode enabled
Opt("GUICloseOnESC", 1)   ;1=ESC  closes, 0=ESC won't close
TestGui1()
TestGui2()
TestGui3()
TestGui4()
;TestGui5()
Func TestGui1 ()
$MainWindow = GUICreate("Test GUI 1", 250, 140, @DesktopWidth -270, @DesktopHeight -200, BitXOR($WS_THICKFRAME,$WS_POPUP))
;GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Frame = GUICtrlCreateGroup("Test GUI 1", 10, 0, 230, 100)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("&OK", 50, 105, 75, 25)
$Cancel = GUICtrlCreateButton("&Cancel", 135, 105, 75, 25)
GUICtrlSetOnEvent ($Cancel, "Close")
GUISetState(@SW_SHOW)
While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc
Func TestGui2 ()
$MainWindow = GUICreate("Test GUI 2", 250, 140, @DesktopWidth -270, @DesktopHeight -200, BitXOR($WS_POPUP,$WS_CAPTION))
;GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Frame = GUICtrlCreateGroup("Test GUI 2", 10, 0, 230, 100)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("&OK", 50, 105, 75, 25)
$Cancel = GUICtrlCreateButton("&Cancel", 135, 105, 75, 25)
GUICtrlSetOnEvent ($Cancel, "Close")
GUISetState(@SW_SHOW)
While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc
Func TestGui3 ()
$MainWindow = GUICreate("Test GUI 3", 250, 140, @DesktopWidth -270, @DesktopHeight -200, BitXOR($WS_CAPTION,$WS_POPUPWINDOW))
;GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Frame = GUICtrlCreateGroup("Test GUI 3", 10, 0, 230, 100)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("&OK", 50, 105, 75, 25)
$Cancel = GUICtrlCreateButton("&Cancel", 135, 105, 75, 25)
GUICtrlSetOnEvent ($Cancel, "Close")
GUISetState(@SW_SHOW)
While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc
Func TestGui4 ()
$MainWindow = GUICreate("Test GUI 4", 250, 140, @DesktopWidth -270, @DesktopHeight -200, BitXOR($DS_MODALFRAME,$WS_SYSMENU))
;GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Frame = GUICtrlCreateGroup("Test GUI 4", 10, 0, 230, 100)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("&OK", 50, 105, 75, 25)
$Cancel = GUICtrlCreateButton("&Cancel", 135, 105, 75, 25)
GUICtrlSetOnEvent ($Cancel, "Close")
GUISetState(@SW_SHOW)
While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd
EndFunc
Func Close()
Exit
EndFunc

Been trying going through the help file and the forums for quite a while now.

Any pointers are appreciated.

:D

Edited by JonatanRaven

Share this post


Link to post
Share on other sites



JonatanRaven,

You need $WS_THICKFRAME to get the border, but then you need to prevent the resizing. And you need to fool Windows into letting you drag the GUI wherever the mouse is positioned. :oops:

You code it like this:

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

; Eet the size restrictions here
Global $GUIMINWID = 500, $GUIMINHT = 500
Global $GUIMAXWID = 500, $GUIMAXHT = 500

$hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($WS_POPUP, $WS_THICKFRAME))

GUISetState()

GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Check if mouse is over the GUI
        Local $aPos = WinGetPos($hWnd)
        If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 500 Then
            ; Fool Windows into thinking it is the title bar so it drags the GUI
            Return $HTCAPTION
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MY_NCHITTEST

Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    ; Set the values regardless of the resizing
    $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X
    DllStructSetData($tagMaxinfo, 8, $GUIMINHT)  ; min Y
    DllStructSetData($tagMaxinfo, 9, $GUIMAXWID) ; max X
    DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO

I think it is commented sufficiently, but please ask if anything is unclear. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ouch, a bit over my current level I think but thanks for the help. :D

I'll dabble some more ^^

Share this post


Link to post
Share on other sites

JonatanRaven,

Try the GUIRegisterMsg tutorial in the Wiki. Please feel free to ask any questions you might have - that is why we are here after all! :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Well, as far as I could tell, it didn't really accomplish what I wanted to be honest. From the looks of it, it's easier to wrap my head around some other way of accomplishing what I want. :D

Found this:

Share this post


Link to post
Share on other sites

JonatanRaven,

it didn't really accomplish what I wanted to be honest

I though that it was just what you wanted: :D

I want that frame but still be able to move the window around

The topic you link to shows another way of moving a pop-up window. If you want to see all the possibilties then I recommend the Moving and Resizing PopUp GUIs tutorial in the Wiki. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Well, it does do exactly what I requested. But it flickers in size when you move it. Any way to work around that? I can't see why it does that..

Share this post


Link to post
Share on other sites

JonatanRaven

It does not flicker when I move it so I cannot offer any ideas how to stop it. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hmm, ok, where did I go wrong then?

When the window is created it looks just like I want it to look but when I click the window to drag it it suddenly changes size. Only slightly but still.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;SIZE RESTRICTIONS HAD TO BE LARGER THAN THE ACTUAL WINDOW FOR IT TO NOT FLICKER
Global $GUIMINWID = 265, $GUIMINHT = 155
Global $GUIMAXWID = 265, $GUIMAXHT = 155
$hGUI = GUICreate("Test", 250, 140, @DesktopWidth/2 -125, @DesktopHeight/2 -100, BitOR($WS_POPUP, $WS_THICKFRAME))
GUISetState()
GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Check if mouse is over the GUI
        Local $aPos = WinGetPos($hWnd)
        If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 500 Then
            ; Fool Windows into thinking it is the title bar so it drags the GUI
            Return $HTCAPTION
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MY_NCHITTEST
Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    ; Set the values regardless of the resizing
    $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X
    DllStructSetData($tagMaxinfo, 8, $GUIMINHT)  ; min Y
    DllStructSetData($tagMaxinfo, 9, $GUIMAXWID) ; max X
    DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO

Edit: I found a solution, the size restrictions had to be larger than the actual window otherwise the window would resize when I dragged the window.

Edited by JonatanRaven

Share this post


Link to post
Share on other sites

JonatanRaven,

That is because the parameters in GUICreate define the client area - the area inside the borders. The MINMAXINFO values define the whole GUI - including the borders. I get farly thin borders when I use $WS_THICKFRAME so the effect is minimal - you obviously have a differnt theme and so have thicker borders. :D

You could use _WinAPI_GetSystemMetrics to get the actual value for the border size and then add it to the MINMAXINFO values if you wanted to be really fussy. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

JonatanRaven,

That is because the parameters in GUICreate define the client area - the area inside the borders. The MINMAXINFO values define the whole GUI - including the borders.

Here is the way how to simply get desired size of window by WinGetPos() and use it in minmaxinfo message

Edited by Zedna

Share this post


Link to post
Share on other sites

Zedna,

Clever! :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Instead of grabbing the MinMax windows messages, you can always use GUIRegisterMsg with the $WM_SYSCOMMAND windows messages, and prevent Windows from seeing them at all so the window won't ever be able to get resized. No flickering and no need to figure out the size of the GUI.

See the code I posted in In there is an example showing the messages that are sent when you click on various parts of the GUI.


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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Well, after some trial and error I combined those codes you posted/linked to this:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=D:DocumentsLOTROicon.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
Opt("GUIOnEventMode", 0)  ;0=disabled, 1=OnEvent mode enabled
Opt("GUICloseOnESC", 1)   ;1=ESC  closes, 0=ESC won't close
Global $size, $width, $height
$gui = GUICreate("Test GUI",250,140,@DesktopWidth-270,@DesktopHeight-200,BitOR($WS_POPUP, $WS_THICKFRAME))
$size = WinGetPos($gui)
$width = $size[2] ; width of window (GUICreate is ClientSize)
$height = $size[3] ; height of window (GUICreate is ClientSize)
GUISetState (@SW_SHOW)
GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO")
GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    ; If it is our GUI
    If $hWnd = $gui Then
        ; Check if mouse is over the GUI
        Local $aPos = WinGetPos($hWnd)
        If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 500 Then
            ; Fool Windows into thinking it is the title bar so it drags the GUI
            Return $HTCAPTION
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MY_NCHITTEST
Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
$minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam)
DllStructSetData($minmaxinfo,7,$width) ; min X
DllStructSetData($minmaxinfo,8,$height) ; min Y
DllStructSetData($minmaxinfo,9,$width) ; max X
DllStructSetData($minmaxinfo,10,$height) ; max Y
Return 0
EndFunc

Not sure if I included anything that isn't really needed but at least it works the way I want it to.

I'll have to check up that link BrewManNH posted as well, see if I can learn something new. :D

Thx a lot for the help guys.

Edited by JonatanRaven

Share this post


Link to post
Share on other sites

JonatanRaven,

BrewManNH's idea works like this: :D

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

; Eet the size restrictions here
Global $GUIMINWID = 500, $GUIMINHT = 500
Global $GUIMAXWID = 500, $GUIMAXHT = 500

$hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($WS_POPUP, $WS_THICKFRAME))

GUISetState()

GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Check if mouse is over the GUI
        Local $aPos = WinGetPos($hWnd)
        If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 500 Then
            ; Fool Windows into thinking it is the title bar so it drags the GUI
            Return $HTCAPTION
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MY_NCHITTEST

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; If it is our GUI and we are trying to resize it
    If $hWnd = $hGUI And $wParam = 0xF000 Then ; $SC_SIZE
        ; Do not let it happen
        Return 0
    EndIf

EndFunc   ;==>WM_SYSCOMMAND

I hope that solves the problem. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

The problem is solved alright, thank you.

So, if I understand the difference between the two methods, the $WM_SYSCOMMAND version doesn't interrupt loops while the $WM_GETMINMAXINFO version could? Are there any other differences between them? Are both versions dependent on the users current skin?

I'm still very new at this and only scripting because I find it interesting and entertainging. Learning as I go.

Edited by JonatanRaven

Share this post


Link to post
Share on other sites

JonatanRaven,

The 2 methods differ in the manner we intercept the Windows messages. Did you read the GUIRegisterMsg tutorial and understand how Windows uses messages to pass information around? :oops:

In simple terms, the SYSCOMMAND version of the script prevents the SIZE message from being transmitted - the MINMAXINFO version limits the values that the resizing can take when a SIZE message is received. Then end result is the same - the GUI does not change size. :D

Does that make sense? :rip:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yes, admittedly I didn't read the GUIRegisterMsg tutorial very carefully, I understand the concept in general but a lot of what is being said is still gibberish. lol

Syscommand prevents the size message from even being sent while the minmaxinfo still prompts for the info but restricts the values. So the syscommand variant would be preferable as it won't interrupt any long loops. That's how I read it all (without really getting into all the details yet).

Anyways, big thanks.

Now I'll just have to find a use for my GUI as well. :D

Share this post


Link to post
Share on other sites

JonatanRaven,

BrewManNH's idea works like this: :D

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

; Eet the size restrictions here
Global $GUIMINWID = 500, $GUIMINHT = 500
Global $GUIMAXWID = 500, $GUIMAXHT = 500

$hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($WS_POPUP, $WS_THICKFRAME))

GUISetState()

GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Check if mouse is over the GUI
        Local $aPos = WinGetPos($hWnd)
        If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 500 Then
            ; Fool Windows into thinking it is the title bar so it drags the GUI
            Return $HTCAPTION
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MY_NCHITTEST

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; If it is our GUI and we are trying to resize it
    If $hWnd = $hGUI And $wParam = 0xF000 Then ; $SC_SIZE
        ; Do not let it happen
        Return 0
    EndIf

EndFunc   ;==>WM_SYSCOMMAND

I hope that solves the problem. :oops:

M23

Ok, back on this one for a bit, there's something that's confusing me a bit here. What does the following two lines actually do?

Global $GUIMINWID = 500, $GUIMINHT = 500

Global $GUIMAXWID = 500, $GUIMAXHT = 500

If I comment them out of my script, nothing seems to change. Are they not needed or why are they included in the example?

Share this post


Link to post
Share on other sites

JonatanRaven,

Are they not needed

Correct - I forgot to take them out of the example when I modified it. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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