Jump to content

how to make the gui resizable?


Allow2010
 Share

Recommended Posts

Hi all,

i have a small problem making a gui, and i hope someone might be so kind to help me out:

The following GUI works for me, but i would like it to be resizable (so when i resize the main gui also the Listview and the Edit are resized) and also i would like it to remember its size and position...

How can this be done? Thanks in advance fo any hint...

BTW: i have one other problem: When i select a listview entry by mouse the edit is updated, but when i do this by keaboard (up down) it is not. How can this be done?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>
$hGUI = GUICreate("My GUI", 540, 500)
$loglistview = GUICtrlCreateListView("Info1|Info2|Info3|Info4|Info5", 10, 10, 520, 200, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetColumnWidth($loglistview, 0, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 1, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 2, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 3, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 4, 300)
GUICtrlCreateListViewItem("Some1|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some2|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some3|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some4|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some5|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some6|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some7|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some8|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some9|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some10|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some11|info|will|be|added", $loglistview)

$logedit = GUICtrlCreateEdit("", 10, 255, 520, 245, $WS_VSCROLL + $WS_HSCROLL + $ES_READONLY)
GUICtrlSetBkColor($logedit, "0xffffff")
$dellog = GUICtrlCreateButton("&Delete", 20, 220, 160)
$emaillog = GUICtrlCreateButton("&Mail", 190, 220, 160)
$printlog = GUICtrlCreateButton("&Print", 360, 220, 160)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GUICtrlListView_ClickItem($loglistview, 0)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
  Case $GUI_EVENT_CLOSE
   ExitLoop
  Case $dellog
   processlogs("delete")
  Case $printlog
   processlogs("print")
  Case $emaillog
   processlogs("mail")
EndSwitch
WEnd
GUIDelete()
Exit
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $loglistview
If Not IsHWnd($loglistview) Then $hWndListView = GUICtrlGetHandle($loglistview)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
  Case $hWndListView
   Switch $iCode
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
     $item = _GUICtrlListView_GetItemTextArray($loglistview, -1)
     GUICtrlSetData($logedit, $item[1])
   EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func processlogs($action)
MsgBox(0,"To be done",$action)
EndFunc   ;==>processlogs
Link to comment
Share on other sites

You have a couple of choices, have a look in the Help file for GUICtrlSetResizing as well as ControlGetPos/WinGetPos to get the position of the controls as well as the GUI window. About the Up/Down arrows perhaps GUISetAccelerators is what you're looking for e.g. {UP} & {DOWN}.

You seem like a user who is willing to try, so I have no doubt you shouldn't find it a problem to implement these into your code.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

You're welcome and good luck.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

OK, now the gui resizes as i want it to, but i still have an issue with the space between listview and edit (where the buttons are),

This space should be fixed and now the space get bigger or smaller depending on how i resize the window...could not figure out how to fix that...

Also setting a minimal heigth and width would be good...how can i limit that?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>
$hGUI = GUICreate("My GUI", 540, 500,-1,-1,BitOR($WS_SIZEBOX,$WS_SYSMENU))
$loglistview = GUICtrlCreateListView("Info1|Info2|Info3|Info4|Info5", 10, 10, 520, 200, $LVS_SHOWSELALWAYS)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT + $GUI_DOCKTOP)
_GUICtrlListView_SetColumnWidth($loglistview, 0, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 1, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 2, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 3, 70)
_GUICtrlListView_SetColumnWidth($loglistview, 4, 300)
GUICtrlCreateListViewItem("Some1|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some2|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some3|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some4|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some5|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some6|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some7|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some8|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some9|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some10|info|will|be|added", $loglistview)
GUICtrlCreateListViewItem("Some11|info|will|be|added", $loglistview)

$logedit = GUICtrlCreateEdit("", 10, 255, 520, 210, $WS_VSCROLL + $WS_HSCROLL + $ES_READONLY)
GUICtrlSetBkColor($logedit, "0xffffff")
$dellog = GUICtrlCreateButton("&Delete", 20, 220, 160)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKHCENTER)
$emaillog = GUICtrlCreateButton("&Mail", 190, 220, 160)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKHCENTER)
$printlog = GUICtrlCreateButton("&Print", 360, 220, 160)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKHCENTER)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GUICtrlListView_ClickItem($loglistview, 0)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
  Case $GUI_EVENT_CLOSE
   ExitLoop
  Case $dellog
   processlogs("delete")
  Case $printlog
   processlogs("print")
  Case $emaillog
   processlogs("mail")
EndSwitch
WEnd
GUIDelete()
Exit
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $loglistview
If Not IsHWnd($loglistview) Then $hWndListView = GUICtrlGetHandle($loglistview)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
  Case $hWndListView
   Switch $iCode
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
     $item = _GUICtrlListView_GetItemTextArray($loglistview, -1)
     GUICtrlSetData($logedit, $item[1])
   EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func processlogs($action)
MsgBox(0,"To be done",$action)
EndFunc   ;==>processlogs

post-5062-0-60029400-1323697454_thumb.jp

Edited by WPA-Fan
Link to comment
Share on other sites

Right now I don't have the time but you could play around with the docking values or have a look at WM_SIZE (search the forum for examples.)

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Did you try WM_SIZE?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

WPA-Fan & guinness,

I am working on a WM_SIZE example at the moment. Stick around for a while. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Thanks Melba, next time it's my turn.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

WPA-Fan,

That was harder than i thought it was going to be" :)

The answer seems to be to let the top control resize itself automatically and then we move the lower controls within the WM_SIZE handler to fit into the rest of the GUI. This is what I came up with: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>

; Create the GUI
$hGUI = GUICreate("My GUI", 540, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU))

; Create the ListView
$hLV = GUICtrlCreateListView("", 10, 10, 520, 190)
GUICtrlSetBkColor(-1, 0xFFCCCC)
; Allow this to resize automatically
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP)

; Create buttons
$hButton_1 = GUICtrlCreateButton("Test 1", 10, 210, 160, 30)
$hButton_2 = GUICtrlCreateButton("Test 2", 190, 210, 160, 30)
$hButton_3 = GUICtrlCreateButton("Test 3", 370, 210, 160, 30)

; Create Edit
$hEdit = GUICtrlCreateEdit("", 10, 250, 520, 210)
GUICtrlSetBkColor(-1, 0xCCFFCC)

GUISetState()

; Register the SIZE message
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Get the new size of the GUI
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        ; Find position of ListView
        $aLVPos = ControlGetPos($hGUI, "", $hLV)
        ; Determine width of buttons
        $iButton_Width = Int(($iGUIWidth - 60) / 3)
        ; Work out positions for the buttons and edit
        $iY_Button = $aLVPos[1] + $aLVPos[3] + 10
        $iY_Edit = $iY_Button + 40
        $iButtonX_1 = 10
        $iButtonX_2 = 30 + $iButton_Width
        $iButtonX_3 = 50 + $iButton_Width + $iButton_Width
        ; Determine Height if Edit
        $iEdit_Ht = $iGUIHeight - $iY_Edit - 10
        ; Move buttons and Edit
        GUICtrlSetPos($hButton_1, $iButtonX_1, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hButton_2, $iButtonX_2, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hButton_3, $iButtonX_3, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hEdit, 10, $iY_Edit, $iGUIWidth - 20, $iEdit_Ht)
    EndIf

EndFunc

Let me know if it not what you want. By the way, if you want to limit the max and min sizes of the GUI, that is really easy. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

WPA-Fan,

I obviously did not test it enough! Very interesting - let me have a look into it. :)

Any thoughts on size limits? :D

M23

Edit:

It seems to work perfectly if you limit the width of the buttons! ;)

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>
#include <staticconstants.au3>
#include <constants.au3>
#include <guilistview.au3>

; Create the GUI
$hGUI = GUICreate("My GUI", 540, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU))

; Create the ListView
$hLV = GUICtrlCreateListView("", 10, 10, 520, 190)
GUICtrlSetBkColor(-1, 0xFFCCCC)
; Allow this to resize automatically
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP)

; Create buttons
$hButton_1 = GUICtrlCreateButton("Test 1", 10, 210, 160, 30)
$hButton_2 = GUICtrlCreateButton("Test 2", 190, 210, 160, 30)
$hButton_3 = GUICtrlCreateButton("Test 3", 370, 210, 160, 30)

; Create Edit
$hEdit = GUICtrlCreateEdit("", 10, 250, 520, 210)
GUICtrlSetBkColor(-1, 0xCCFFCC)

GUISetState()

; Register the SIZE message
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Get the new size of the GUI
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        ; Find position of ListView
        $aLVPos = ControlGetPos($hGUI, "", $hLV)
        ; Determine width of buttons
        $iButton_Width = Int(($iGUIWidth - 60) / 3)
        $iButton_Width_Limit = 262 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<
        If $iButton_Width > $iButton_Width_Limit Then
            $iButton_Width = $iButton_Width_Limit
        EndIf
        ; Work out positions for the buttons and edit
        $iY_Button = $aLVPos[1] + $aLVPos[3] + 10
        $iY_Edit = $iY_Button + 40
        $iButtonX_1 = 10
        $iButtonX_2 = Int(($iGUIWidth / 2) - ($iButton_Width / 2))
        ;$iButtonX_3 = 50 + $iButton_Width + $iButton_Width
        $iButtonX_3 = $iGUIWidth - $iButton_Width - 10
        ; Determine Height if Edit
        $iEdit_Ht = $iGUIHeight - $iY_Edit - 10
        ; Move buttons and Edit
        GUICtrlSetPos($hButton_1, $iButtonX_1, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hButton_2, $iButtonX_2, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hButton_3, $iButtonX_3, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hEdit, 10, $iY_Edit, $iGUIWidth - 20, $iEdit_Ht)
    EndIf

EndFunc

Set the limit (<<<<<<<) any higher and the button misbehaves when you move it. I shall try and find out why - but I hope this help in the meantime.

See post #19 below for correct solution!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

This works quite well and the complete gui is resizable...

After playing with it for a while i was thinking that it might be better if the buttons coud keep their inital size (they look very big and strange if i resize the gui).

Also i did not figure out how i can limit the size of the window (without making it flicker very much)...any hints on how this can be achieved would be nice...thank you !

Link to comment
Share on other sites

  • Moderators

WPA-Fan,

Here is a version with fixed size button and limits on the GUI max/min size: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>

; Create the GUI
$hGUI = GUICreate("My GUI", 540, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU))

; Create the ListView
$hLV = GUICtrlCreateListView("", 10, 10, 520, 190)
GUICtrlSetBkColor(-1, 0xFFCCCC)
; Allow this to resize automatically
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP)

; Create buttons
$hButton_1 = GUICtrlCreateButton("Test 1", 10, 210, 160, 30)
$hButton_2 = GUICtrlCreateButton("Test 2", 190, 210, 160, 30)
$hButton_3 = GUICtrlCreateButton("Test 3", 370, 210, 160, 30)

; Create Edit
$hEdit = GUICtrlCreateEdit("", 10, 250, 520, 210)
GUICtrlSetBkColor(-1, 0xCCFFCC)

GUISetState()

; Register the SIZE and MINMAX messages
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Get the new size of the GUI
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        ; Find position of ListView
        $aLVPos = ControlGetPos($hGUI, "", $hLV)
        ; Set width of buttons
        $iButton_Width = 160
        ; Work out positions for the buttons and edit
        $iY_Button = $aLVPos[1] + $aLVPos[3] + 10
        $iY_Edit = $iY_Button + 40
        $iButtonX_1 = 10
        $iButtonX_2 = ($iGUIWidth - $iButton_Width) / 2
        $iButtonX_3 = $iGUIWidth - $iButton_Width - 10
        ; Determine Height of Edit
        $iEdit_Ht = $iGUIHeight - $iY_Edit - 10
        ; Move buttons and Edit
        GUICtrlSetPos($hButton_1, $iButtonX_1, $iY_Button)
        GUICtrlSetPos($hButton_2, $iButtonX_2, $iY_Button)
        GUICtrlSetPos($hButton_3, $iButtonX_3, $iY_Button)
        GUICtrlSetPos($hEdit, 10, $iY_Edit, $iGUIWidth - 20, $iEdit_Ht)
    EndIf

EndFunc

Func _WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    If $hWnd = $hGUI Then
        $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($tagMaxinfo, 7,  540) ; min X
        DllStructSetData($tagMaxinfo, 8,  230) ; min Y
        DllStructSetData($tagMaxinfo, 9,  800) ; max X
        DllStructSetData($tagMaxinfo, 10, 600) ; max Y
        Return 0
    EndIf
EndFunc   ;==>WM_GETMINMAXINFO

Obviously you can set the limits to suit you - but the current min X value prevents the buttons from overlapping. ;)

And thanks for the original question. You have got a couple of us scratching our heads over the misplaced button problem - which keeps us off the streets at night. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

And thanks for the original question. You have got a couple of us scratching our heads over the misplaced button problem - which keeps us off the streets at night. :)

:-)

Thank YOU very much for your help. I got much more than i expected and i am really happy that my gui now works...

I am still studying the details and i am sure i will learn quite a bit from your example...

Edited by WPA-Fan
Link to comment
Share on other sites

  • Moderators

WPA-Fan,

Do ask if you have questions - that is why we are here! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

WPA-Fan,

I found (or rather was told) the solution to the crazy buttons. Windows was running its own resizing code along with ours - I needed to tell it not to bother: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>

; Create the GUI
$hGUI = GUICreate("My GUI", 540, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU))

; Create the ListView
$hLV = GUICtrlCreateListView("", 10, 10, 520, 190)
GUICtrlSetBkColor(-1, 0xFFCCCC)

; Create buttons
$hButton_1 = GUICtrlCreateButton("Test 1", 10, 210, 160, 30)
$hButton_2 = GUICtrlCreateButton("Test 2", 190, 210, 160, 30)
$hButton_3 = GUICtrlCreateButton("Test 3", 370, 210, 160, 30)

; Create Edit
$hEdit = GUICtrlCreateEdit("", 10, 250, 520, 210)
GUICtrlSetBkColor(-1, 0xCCFFCC)

GUISetState()

; Register the SIZE message
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Get the new size of the GUI
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)
        ; Determine height of ListView
        $iLV_Ht = Int(($iGUIHeight / 2) - 25)
        ; Determine width of buttons
        $iButton_Width = Int(($iGUIWidth - 60) / 3)
        ; Work out positions for the buttons and edit
        $iY_Button = 10 + $iLV_Ht + 10
        $iY_Edit = $iY_Button + 40
        $iButtonX_1 = 10
        $iButtonX_2 = Int(($iGUIWidth / 2) - ($iButton_Width / 2))
        $iButtonX_3 = $iGUIWidth - $iButton_Width - 10
        ; Determine height of Edit
        $iEdit_Ht = $iGUIHeight - $iY_Edit - 10
        ; Move controls
        GUICtrlSetPos($hLV, 10, 10, $iGUIWidth - 20, $iLV_Ht)
        GUICtrlSetPos($hButton_1, $iButtonX_1, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hButton_2, $iButtonX_2, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hButton_3, $iButtonX_3, $iY_Button, $iButton_Width, 30)
        GUICtrlSetPos($hEdit, 10, $iY_Edit, $iGUIWidth - 20, $iEdit_Ht)

        Return 0 ; Tell Windows not to run its own resizing code <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    EndIf

EndFunc

My learning point for today - well the first one at least! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • 3 months later...

My learning point for today - well the first one at least! ;)

Hi Melba23,

I'm newbie and really thanks for the codes, I'm learning from you now.

I add $WS_CLIPCHILDREN to main GUI so to stop it from flickering, but it's no use and the list view now scrolled up. Maybe because we work the script with control IDs

So I re-write it with _WinAPI_ ... to get a handles to work with, and it works - sort of. It's not flickering but the colors doesn't works and now when the mouse moves the main GUI just a little move, the list view jump down only once for the first time.

Maybe I should look into it more, but thanks for the codes anyway.

Your :bye: , solve my :oops: .

Thank you. :doh:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>
#include <GuiListView.au3>
#include <GuiButton.au3>

OnAutoItExitRegister("EXIT_STATE")

; Create the GUI
$hGUI = GUICreate("My GUI", 540, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CLIPCHILDREN))

; Create the ListView
$hLV = _GUICtrlListView_Create ($hGUI, "", 10, 10, 520, 190);190 - 245 <<== heigth of this list view is "jump down" when resizing
_GUICtrlListView_SetBkColor   ($hLV, 0xFFCCCC) ; <<== does not works. the color are supposed to be something like light red not light blue

; Create buttons
$hButton_1 = _GUICtrlButton_Create ($hGUI, "Test 1", 10, 210, 160, 30)
$hButton_2 = _GUICtrlButton_Create ($hGUI, "Test 2", 190, 210, 160, 30)
$hButton_3 = _GUICtrlButton_Create ($hGUI, "Test 3", 370, 210, 160, 30)

; Create Edit
$hEdit = _GUICtrlRichEdit_Create ($hGUI, "", 10, 250, 520, 210)
_WinAPI_SetBkColor ($hEdit, 0xCCFFCC) ; <<== does not works, no color
GUISetState()

; Register the SIZE message
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

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

Func EXIT_STATE()
_GUICtrlRichEdit_Destroy($hEdit) ; <<== must have for rich edit
EndFunc   ;==>EXIT_STATE

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    ; If it is our GUI
    If $hWnd = $hGUI Then

        ; Get the new size of the GUI
        $iGUIWidth = BitAND($lParam, 0xFFFF)
        $iGUIHeight = BitShift($lParam, 16)

        ; Determine height of ListView
        $iLV_Ht = Int(($iGUIHeight / 2) - 25)

        ; Determine width of buttons
        $iButton_Width = Int(($iGUIWidth - 60) / 3)

        ; Work out positions for the buttons and edit
        $iY_Button = 10 + $iLV_Ht + 10
        $iY_Edit = $iY_Button + 40
        $iButtonX_1 = 10
        $iButtonX_2 = Int(($iGUIWidth / 2) - ($iButton_Width / 2))
        $iButtonX_3 = $iGUIWidth - $iButton_Width - 10

        ; Determine height of Edit
        $iEdit_Ht = $iGUIHeight - $iY_Edit - 10

        ; Move controls
        WinMove ($hLV, "", 10, 10, $iGUIWidth - 20, $iLV_Ht)
        WinMove ($hButton_1, "", $iButtonX_1, $iY_Button, $iButton_Width, 30)
        WinMove ($hButton_2, "", $iButtonX_2, $iY_Button, $iButton_Width, 30)
        WinMove ($hButton_3, "",$iButtonX_3, $iY_Button, $iButton_Width, 30)
        WinMove ($hEdit, "", 10, $iY_Edit, $iGUIWidth - 20, $iEdit_Ht)
        Return $GUI_RUNDEFMSG ; >>>> This tells AutoIt to process the message itself
                                                      ; >>>> http://www.autoitscript.com/wiki/GUIRegisterMsg <<<
    EndIf
EndFunc
Edited by phinuts
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...