Jump to content

Recommended Posts

Posted (edited)

Hi,

I have a problem with a list control. I've used $WS_SIZEBOX because I want to be able to change the width as necessary. However if I make it wider and then set the list control font-size it shrinks to its original size. Even worse, the larger version remains visible underneath.

Anyone know why this is happening, or where I'm going wrong?

Thanks!

#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiListBox.au3>
#include <GuiEdit.au3>
#include <String.au3>
#include <Array.au3>
#include <File.au3>
#include <Misc.au3>

; ===============================================
; set mode
; ===============================================

Opt("GUIOnEventMode",1)
Opt("TrayIconHide",1)

; ===============================================
; set up variables
; ===============================================


Dim $winsize[4]

Global $hWindow,$hEdit,$hList,$winw,$winh,$fontfamily,$fontsize,$fontweight,$fontcolor,$colorref

; ===============================================
; create main window
; ===============================================

$hWindow=GUICreate("Xemit",750,460,-1,-1,$WS_OVERLAPPEDWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE,"CloseWindow")
GUISetOnEvent($GUI_EVENT_MINIMIZE,"ControlResize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE,"ControlResize")
GUISetOnEvent($GUI_EVENT_RESTORE,"ControlResize")
GUISetOnEvent($GUI_EVENT_RESIZED,"ControlResize")

; ===============================================
; create main window edit controls
; ===============================================

$hEdit=GUICtrlCreateEdit("",0,0,610,460,BitOR($WS_SIZEBOX,$ES_MULTILINE,$WS_VSCROLL,$ES_WANTRETURN,$ES_NOHIDESEL))
GUICtrlSendMsg($hEdit,$EM_SETLIMITTEXT,4000000,0)
GUICtrlSetState($hEdit,$GUI_ENABLE)
GUICtrlSetState($hEdit,$GUI_FOCUS)

$hList=GUICtrlCreateList("",610,0,140,460,BitOR($WS_SIZEBOX,$WS_VSCROLL))
GUICtrlSetState($hList,$GUI_ENABLE)
GUICtrlSetData($hList,"Item 1|Item 2|Item 3 ")

; ===============================================
; set up options menu
; ==============================================

$optionsmenu=GUICtrlCreateMenu("&Options")
$optionsfont=GUICtrlCreateMenuitem("Set font",$optionsmenu)

GUICtrlSetOnEvent($optionsfont,"SetFont")

; ===============================================
; show main window
; ===============================================

GUISwitch($hWindow)
WinSetState($hWindow,"",@SW_MAXIMIZE)
ControlResize()
GUISetState(@SW_SHOW,$hWindow)

; ===============================================
; functions
; ===============================================

Func ControlResize()
  $winsize=WinGetClientSize($hWindow)
  $winw=$winsize[0]
  $winh=$winsize[1]
  GUICtrlSetPos($hEdit,0,0,$winw*0.7,$winh)
  GUICtrlSetPos($hList,$winw*0.8,0,$winw-($winw*0.8),$winh)
EndFunc

; -----------------------------------------------

Func CloseWindow()
  Exit
EndFunc

; ===============================================
; options functions
; ===============================================

Func SetFont()
  $userfont=_ChooseFont($fontfamily,$fontsize,$colorref)
  If Not @error Then
    $fontfamily=$userfont[2]
    $fontsize=$userfont[3]
    $fontweight=$userfont[4]
    $fontcolor=$userfont[7]
    $colorref=$userfont[5]
    GUICtrlSetFont($hEdit,$fontsize,$fontweight,0,$fontfamily)
    GUICtrlSetFont($hList,$fontsize,$fontweight,0,$fontfamily)
    GUICtrlSetColor($hEdit,$fontcolor)
    GUICtrlSetColor($hList,$fontcolor)
  EndIf
EndFunc

; ===============================================
; idle loop
; ===============================================

While 1
  Sleep(100)
WEnd

; -----------------------------------------------
Edited by philw
Posted

Change the Setfont() function to:

Func SetFont()
  $userfont=_ChooseFont($fontfamily,$fontsize,$colorref)
  If Not @error Then
    GUICtrlSetResizing($hEdit, $GUI_DOCKALL)
    GUICtrlSetResizing($hList, $GUI_DOCKALL)
    $fontfamily=$userfont[2]
    $fontsize=$userfont[3]
    $fontweight=$userfont[4]
    $fontcolor=$userfont[7]
    $colorref=$userfont[5]
    GUICtrlSetFont($hEdit,$fontsize,$fontweight,0,$fontfamily)
    GUICtrlSetFont($hList,$fontsize,$fontweight,0,$fontfamily)
    GUICtrlSetColor($hEdit,$fontcolor)
    GUICtrlSetColor($hList,$fontcolor)
    GUICtrlSetResizing($hEdit, $GUI_DOCKAUTO)
    GUICtrlSetResizing($hList, $GUI_DOCKAUTO)
  EndIf
EndFunc

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...