DickG

Treeview vs Listbox height

3 posts in this topic

I ran into something really strange: If I set the Treeview GUI height and the Listbox GUI height exactly the same, they appear differently.

I've tried testing with different values, and can't get them to be exactly the same.

Here's my test code. Try changing $LV_height and $LB_height to see what happens. Bumping $LB_height from 285 to 291 doesn't change the height of the listbox. It's still too short relative to the Treeview. Changing it to 292 makes it too tall. I'm baffled. Anyone know what the problem is?

#include-once
#include "WindowsConstants.au3"
#include "ListBoxConstants.au3"
#include "TreeViewConstants.au3"

Dim $GUI_Main, $Functions_TV, $FunctionCode_LB_style, $FunctionCode_LB, $Close_btn
Dim $LV_height = 285
Dim $LB_height = 285;291 is too short, 292 is too tall. WTF?

$GUI_Main = GuiCreate("LV vs LB height test", 700, 520, 200, 200, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

GUICtrlCreateLabel("Treeview", 20, 30, 70, 20) 
$Functions_TV = GUICtrlCreateTreeView(20, 60, 300, $LV_height, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)

GUICtrlCreateLabel("Listbox", 330, 30, 60, 20) 
$FunctionCode_LB_style = BitOR($WS_HSCROLL, $WS_VSCROLL, $LBS_NOTIFY, $WS_BORDER, $LBS_MULTIPLESEL)
$FunctionCode_LB = GUICtrlCreateList("", 330, 60, 300, $LB_height, $FunctionCode_LB_style)

$Close_btn = GuiCtrlCreateButton("Close", 300, 400, 60 , 30)

GUISetState(@SW_SHOW, $GUI_Main)

While 1
    $Msg = GUIGetMsg()
    
    Switch $Msg
        Case $Close_btn
            Exit
            
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites



I believe that the height of the listbox is determined by the height of the lines in it. Which means it's a multiple of the row height, that's why you see such a big jump between 291 and 292. If you set the TreeView to 292 and the ListBox to 292, you'll see that they're the same height.


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

Aha! I knew there was something I was missing!

Thanks a lot, BrewMan.

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