Jump to content

GUI dragging and resizing


LimeSeed
 Share

Recommended Posts

Any way to make a gui expand with the mouse and have the controls in the gui resize proportionately to the size of the gui window?

There are various ways to set resizing with GuiCtrlSetResizing but none of them expand the controls to be in proprtion to the window. I think you would have to adjust each control with ControlMove whenever the window is resized.
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

There are various ways to set resizing with GuiCtrlSetResizing but none of them expand the controls to be in proprtion to the window. I think you would have to adjust each control with ControlMove whenever the window is resized.

aww man :-(

global $warming = true
Link to comment
Share on other sites

There are various ways to set resizing with GuiCtrlSetResizing but none of them expand the controls to be in proprtion to the window. I think you would have to adjust each control with ControlMove whenever the window is resized.

just curious to know which kind of resizing is not done when you use GUICtrlSetResizing() and guistyle=$WS_SIZEBOX.

X,y,w,h are adjusted, Font is not.

Link to comment
Share on other sites

just curious to know which kind of resizing is not done when you use GUICtrlSetResizing() and guistyle=$WS_SIZEBOX.

X,y,w,h are adjusted, Font is not.

Yes the x,y,w,h are adjusted but that is in relation to the sides of the gui. It does not resize in proportion so that a bigger gui gives a magnified version of a smaller gui. If you design a gui at a small size and use $GUI_DOCKALL then the controls will soon start to overlap as the gui is expanded.

For example, no resize option will do what this script does (I think)

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

Global Const $WS_EX_COMPOSITED = 0x2000000

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 422, 237, 193, 125, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS),$WS_EX_COMPOSITED))
$Edit1 = GUICtrlCreateEdit("", 56, 24, 345, 145)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Button1", 112, 200, 75, 25, 0)
$startBtnFontSize = 8
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$stbt = ControlGetPos($Form1, "", $Button1)
$sted = ControlGetPos($Form1, "", $Edit1)
$stGui = WinGetClientSize($Form1)
GUIRegisterMsg($WM_MOVE, "SetControlSize")
GUIRegisterMsg($WM_SIZE, "SetControlSize")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
    EndSwitch
WEnd


Func SetControlSize()
    $newgui = WinGetClientSize($Form1)
    ControlMove($Form1, "", $Button1, $newgui[0] * $stbt[0] / $stGui[0], $newgui[1] * $stbt[1] / $stGui[1], $newgui[0] * $stbt[2] / $stGui[0], $newgui[1] * $stbt[3] / $stGui[1])
    ControlMove($Form1, "", $Edit1, $newgui[0] * $sted[0] / $stGui[0], $newgui[1] * $sted[1] / $stGui[1], $newgui[0] * $sted[2] / $stGui[0], $newgui[1] * $sted[3] / $stGui[1])
    GUICtrlSetFont($Button1,$startBtnFontSize *$newgui[1] / $stGui[1])
    GUICtrlSetFont($Edit1,$startBtnFontSize *$newgui[1] / $stGui[1])
    Return 1
EndFunc

A little udf could easily be written to resize a gui and its controls in proprtion like that.

Edited by martin
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

yea i was thinking of something like that for my calculator, but im way too lazy to implement that into my script :) Thanks for your awesomeness!

Well thanks, but unfortunately, now I look at it, it's not so smart at all.

The resizing can be achieved with just the line

opt("GUIResizeMode",$GUI_DOCKAUTO)

and then it only remains to resize the fonts.

I have also added a method to keep the aspect ratio of the window constant.

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

Global Const $WS_EX_COMPOSITED = 0x2000000
Global Const $WMSZ_BOTTOM = 6
Global Const $WMSZ_BOTTOMLEFT = 7
Global Const $WMSZ_BOTTOMRIGHT = 8
Global Const $WMSZ_LEFT = 1
Global Const $WMSZ_RIGHT = 2
Global Const $WMSZ_TOP = 3
Global Const $WMSZ_TOPLEFT = 4
Global Const $WMSZ_TOPRIGHT = 5
Opt("GUIResizeMode", $GUI_DOCKAUTO)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 422, 237, 193, 125, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_COMPOSITED)
$Edit1 = GUICtrlCreateEdit("Line 1" & @CRLF & "line 2", 56, 24, 345, 145)
$Button1 = GUICtrlCreateButton("Button1", 112, 200, 75, 25, 0)
$startBtnFontSize = 8
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$gp = WinGetPos($Form1)
Global $HtoW = $gp[3] / $gp[2]
$stGui = WinGetClientSize($Form1)
GUIRegisterMsg($WM_SIZE, "SetFontSizes")
GUIRegisterMsg($WM_SIZING, "SetAspect")

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

    EndSwitch
WEnd


Func SetFontSizes()
    $newgui = WinGetClientSize($Form1)
    GUICtrlSetFont($Button1, $startBtnFontSize * $newgui[1] / $stGui[1])
    GUICtrlSetFont($Edit1, $startBtnFontSize * $newgui[1] / $stGui[1])
EndFunc  ;==>SetFontSizes

Func SetAspect($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)
    
    Switch $wparam;drag side or corner


        Case $WMSZ_LEFT, $WMSZ_RIGHT
            $newHt = ($Right - $left) * $HtoW
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $newHt, 4)
        Case Else
            $newWid = ($bottom - $top) / $HtoW
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $newWid, 3)
    EndSwitch
    
    

;Return 1
EndFunc  ;==>SetAspect

That can be improved a lot but it gives the idea.

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

What if you set the font size relevant to the y of the gui. So you have it pull the y from the gui and for every 10 up in size it adds a point to the font. something of that sorts? I'm not sure if that would be right, of course if you just pulled the top up the text would eventually run wide of the controls... Ok scratch that replace your text with images :-P

Giggity

Link to comment
Share on other sites

What if you set the font size relevant to the y of the gui. So you have it pull the y from the gui and for every 10 up in size it adds a point to the font. something of that sorts? I'm not sure if that would be right, of course if you just pulled the top up the text would eventually run wide of the controls... Ok scratch that replace your text with images :-P

My script does make the font size relative to the gui height. Also, my script keeps the width to height ratio so that larger fonts won't cause text to be too long to fit the control. If you just pull the top up or the bottom down the width will change as well. Using a pic would not look so good IMO.
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

  • 3 months later...

Is there a way to LOCK Horizontal scrolling.

Can you show an example where you want the scrolling locked? (The smaller the better.)
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

  • Moderators

@martin... did you try your resize method with owner drawn UDF controls (like listview_create/edit_create)? I find often I use a mixture of both ... unfortunately that method I believe won't work with those.

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

@martin... did you try your resize method with owner drawn UDF controls (like listview_create/edit_create)? I find often I use a mixture of both ... unfortunately that method I believe won't work with those.

Well I haven't tried it until now. In fact I think the post above was the only time I've tried it on anything.

This is just put together to try it and I hope you will excuse the mess!

I don't know how to change the header height, and the whole thing is very flickery, so it's not very satisfactory.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <winapi.au3>
#include <FontConstants.au3>

Global Const $WS_EX_COMPOSITED = 0x2000000
Global Const $WMSZ_BOTTOM = 6
Global Const $WMSZ_BOTTOMLEFT = 7
Global Const $WMSZ_BOTTOMRIGHT = 8
Global Const $WMSZ_LEFT = 1
Global Const $WMSZ_RIGHT = 2
Global Const $WMSZ_TOP = 3
Global Const $WMSZ_TOPLEFT = 4
Global Const $WMSZ_TOPRIGHT = 5

Global $hFont = _WinAPI_CreateFont(12, 6, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')


Opt("GUIResizeMode", $GUI_DOCKAUTO)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 422, 437, 193, 125, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS));, $WS_EX_COMPOSITED)
$Edit1 = GUICtrlCreateEdit("Line 1" & @CRLF & "line 2", 56, 24, 345, 145)
$Button1 = GUICtrlCreateButton("Button1", 112, 200, 75, 25, 0)
$startBtnFontSize = 8
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$hListView = _GUICtrlListView_Create($Form1, "", 12, 250, 394, 168)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
;GUISetState()
_WinAPI_SetFont($hListView, $hFont, True)
;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

; Add items
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)




$gp = WinGetPos($Form1)
Global $HtoW = $gp[3] / $gp[2]
$stGui = WinGetClientSize($Form1)
GUIRegisterMsg($WM_SIZE, "SetFontSizes")
GUIRegisterMsg($WM_SIZING, "SetAspect")

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


Func SetFontSizes();might be better to register this for wm_exitsizemove
    $newgui = WinGetClientSize($Form1)
    GUICtrlSetFont($Button1, $startBtnFontSize * $newgui[1] / $stGui[1])
    GUICtrlSetFont($Edit1, $startBtnFontSize * $newgui[1] / $stGui[1])
    
    
;adjust the listview?
    $newLVwid = 394 * $newgui[1] / $stGui[1]
    
    $newLVht = 168 * $newgui[1] / $stGui[1]
    _WinAPI_DeleteObject($hFont)
    $hFont = _WinAPI_CreateFont(12 * $newgui[1] / $stGui[1], 6* $newgui[1] / $stGui[1], 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
   ;adjust the col widths
    _GUICtrlListView_SetColumnWidth($hListView,0,100 * $newgui[1] / $stGui[1])
    _GUICtrlListView_SetColumnWidth($hListView,1,100 * $newgui[1] / $stGui[1])
    _GUICtrlListView_SetColumnWidth($hListView,2,100 * $newgui[1] / $stGui[1])
    
    
    _WinAPI_SetFont($hListView, $hFont, True)
    ControlMove($Form1, "", "[CLASS:SysListView32;INSTANCE:1]", 12, (418 * $newgui[1] / $stGui[1]) - $newLVht, $newLVwid, $newLVht)
    
EndFunc  ;==>SetFontSizes

Func SetAspect($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)

    Switch $wparam;drag side or corner


        Case $WMSZ_LEFT, $WMSZ_RIGHT
            $newHt = ($Right - $left) * $HtoW
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $newHt, 4)
        Case Else
            $newWid = ($bottom - $top) / $HtoW
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $newWid, 3)
    EndSwitch

    

;Return 1
EndFunc  ;==>SetAspect
Edited by martin
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

post-12971-1229110034_thumb.jpg

When the mouse reachest the red portion of the gui, you cannot click and drag.

when it reaches the green section, you can resize verticaly.

hope this helps

In post #7 in the function SetAspect, I guess you have the constant $WMSZ_RIGHT either missing or incorrectly defined.
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

I don't know how to change the header height

@Martin

I came up with this solution to the listview header control not resizing with font change (MicroSoft bug, not AutoIt)

Font size and weight with _GUICtrlListView_Create

http://www.autoitscript.com/forum/index.php?showtopic=83113

Edit: changed to code from codebox

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <winapi.au3>
#include <FontConstants.au3>

Global Const $WS_EX_COMPOSITED = 0x2000000
Global Const $WMSZ_BOTTOM = 6
Global Const $WMSZ_BOTTOMLEFT = 7
Global Const $WMSZ_BOTTOMRIGHT = 8
Global Const $WMSZ_LEFT = 1
Global Const $WMSZ_RIGHT = 2
Global Const $WMSZ_TOP = 3
Global Const $WMSZ_TOPLEFT = 4
Global Const $WMSZ_TOPRIGHT = 5

Global $hFont = _WinAPI_CreateFont(12, 6, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')


Opt("GUIResizeMode", $GUI_DOCKAUTO)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 422, 437, 193, 125, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS));, $WS_EX_COMPOSITED)
$Edit1 = GUICtrlCreateEdit("Line 1" & @CRLF & "line 2", 56, 24, 345, 145)
$Button1 = GUICtrlCreateButton("Button1", 112, 200, 75, 25, 0)
$startBtnFontSize = 8
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$hListView = _GUICtrlListView_Create($Form1, "", 12, 250, 394, 168)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
;GUISetState()
_WinAPI_SetFont($hListView, $hFont, True)
;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

; Add items
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)




$gp = WinGetPos($Form1)
Global $HtoW = $gp[3] / $gp[2]
$stGui = WinGetClientSize($Form1)
GUIRegisterMsg($WM_SIZE, "SetFontSizes")
GUIRegisterMsg($WM_SIZING, "SetAspect")

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


Func SetFontSizes();might be better to register this for wm_exitsizemove
    $newgui = WinGetClientSize($Form1)
    GUICtrlSetFont($Button1, $startBtnFontSize * $newgui[1] / $stGui[1])
    GUICtrlSetFont($Edit1, $startBtnFontSize * $newgui[1] / $stGui[1])
    
    
;adjust the listview?
    $newLVwid = 394 * $newgui[1] / $stGui[1]
    
    $newLVht = 168 * $newgui[1] / $stGui[1]
    _WinAPI_DeleteObject($hFont)
    $hFont = _WinAPI_CreateFont(12 * $newgui[1] / $stGui[1], 6* $newgui[1] / $stGui[1], 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
  ;adjust the col widths
    _GUICtrlListView_SetColumnWidth($hListView,0,100 * $newgui[1] / $stGui[1])
    _GUICtrlListView_SetColumnWidth($hListView,1,100 * $newgui[1] / $stGui[1])
    _GUICtrlListView_SetColumnWidth($hListView,2,100 * $newgui[1] / $stGui[1])
    
    
   ;_WinAPI_SetFont($hListView, $hFont, True)
    _GUICtrlListView_SetFont($hListView, $hFont)
    ControlMove($Form1, "", "[CLASS:SysListView32;INSTANCE:1]", 12, (418 * $newgui[1] / $stGui[1]) - $newLVht, $newLVwid, $newLVht)
    
EndFunc ;==>SetFontSizes

Func SetAspect($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)

    Switch $wparam;drag side or corner


        Case $WMSZ_LEFT, $WMSZ_RIGHT
            $newHt = ($Right - $left) * $HtoW
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $newHt, 4)
        Case Else
            $newWid = ($bottom - $top) / $HtoW
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $newWid, 3)
    EndSwitch

    

;Return 1
EndFunc ;==>SetAspect


; =========================================================================================
; Name...........: _GUICtrlListView_SetFont
; Description ...: Set font for a list-view controls items and header text
; Syntax.........: _GUICtrlListView_SetFont($hWnd, $hFontLV, $hFontHD = 0)
; Parameters ....: $hWnd        - Handle to the control
;                 $hFontLV   - Handle to font
;                 $hFontHD   - Handle to header font (Optional)
; Return values .: Success    - True
;                 Failure     - False
; Author ........: rover
; Remarks .......: Minimum OS Windows XP
;                 Use optional header font parameter for a different font/size of header
;                 Resizes header with font change
; =========================================================================================
Func _GUICtrlListView_SetFont($hWnd, $hFontLV, $hFontHD = 0)
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    Local $aReturn, $hHeader, $hDLL
    
    $hHeader = HWnd(_GUICtrlListView_GetHeader($hWnd)); get handle to header control
    
    If Not IsHWnd($hWnd) Or Not IsPtr($hFontLV) Or Not IsHWnd($hHeader) Then Return SetError(1, 0, False)
    
    _SendMessage($hWnd, $__LISTVIEWCONSTANT_WM_SETREDRAW, 0); disable listview repainting

    $hDLL = DllOpen("UxTheme.dll")
; turn off theme for header control to enable header autosizing
    $aReturn = DllCall($hDLL, "int", "SetWindowTheme", "hwnd", $hHeader, "wstr", "", "wstr", "")
    If @error Or $aReturn[0] Then
        DllClose($hDLL)
        Return SetError(2, 0, False)
    EndIf
    
    If IsPtr($hFontHD) Then; set font for items and if available separate font for header
        _SendMessage($hWnd, $__LISTVIEWCONSTANT_WM_SETFONT, $hFontLV, True, 0, "hwnd")
        _SendMessage($hHeader, $__LISTVIEWCONSTANT_WM_SETFONT, $hFontHD, True, 0, "hwnd")
    Else; set same font for header and items
    ; resizing header down to a smaller font size causes listview repaint problems, so repainting is enabled
        _SendMessage($hWnd, $__LISTVIEWCONSTANT_WM_SETREDRAW, 1); enable repainting
        _SendMessage($hWnd, $__LISTVIEWCONSTANT_WM_SETFONT, $hFontLV, True, 0, "hwnd")
    EndIf
    
; restore control theme painting
    $aReturn = DllCall($hDLL, "int", "SetWindowTheme", "hwnd", $hHeader, "ptr", 0, "ptr", 0)
    If @error Or $aReturn[0] Then
        DllClose($hDLL)
        Return SetError(3, 0, False)
    EndIf
    DllClose($hDLL)
    
    _SendMessage($hWnd, $__LISTVIEWCONSTANT_WM_SETREDRAW, 1); enable listview repainting
    _WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_INVALIDATE)      ; repaint listview
    Return SetError(0, 0, $aReturn[0] <> 1)
EndFunc  ;==>_GUICtrlListView_SetFont
Edited by rover

I see fascists...

Link to comment
Share on other sites

@martin

In post #7 in the function SetAspect, I guess you have the constant $WMSZ_RIGHT either missing or incorrectly defined.

this is how i want it, the user NOT being able to alter the WIDTH of the GUI in any way, but can change the height.

:)

Link to comment
Share on other sites

@martin

this is how i want it, the user NOT being able to alter the WIDTH of the GUI in any way, but can change the height.

:)

Oh, in that case all you need to do is remove $WMSZ_RIGHT from the case statement.
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

@Martin

I came up with this solution to the listview header control not resizing with font change (MicroSoft bug, not AutoIt)

Font size and weight with _GUICtrlListView_Create

http://www.autoitscript.com/forum/index.php?showtopic=83113

That's a very nice function rover, it should be part of GuiListView. Thanks for showing how to do that. :)

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

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