Jump to content
Sign in to follow this  
KaFu

[Solved] Listview in Tile mode - Height not correct

Recommended Posts

HiHo Forum,

I've been playing around with Listview in Tile mode. Populating and switching style works fine, but (at least on the XP machine tested on) the tiles still seem to overlap. Row1 and Row2 look fine, but when you click Row3 you'll see that it overlaps with Row1.

Anyone :)? Maybe as a bonus question, how do I change to amount of tiles per row (I've not started to look into that)?

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
$GUI = GUICreate("ListView Example - Tile View", 400, 300)
$hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)
For $i = 0 To 2
_GUICtrlListView_AddItem($hListView, "Row " & $i + 1 & ": Col 1")
_GUICtrlListView_AddSubItem($hListView, $i, "Row " & $i + 1 & ": Col 2", 1)
_GUICtrlListView_AddSubItem($hListView, $i, "Row " & $i + 1 & ": Col 3", 2)
Next
_GUICtrlListView_SetView($hListView, 4)
; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774768(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb774768(v=vs.85).aspx[/url]
Global $tag_LVTILEVIEWINFO = "UINT cbSize;DWORD dwMask;DWORD dwFlags;STRUCT;LONG Size_cx;LONG Size_cy;ENDSTRUCT;INT cLines;STRUCT;LONG RECT_left;LONG RECT_top;LONG RECT_right;LONG RECT_bottom;ENDSTRUCT;"
$t_Struct2 = DllStructCreate($tag_LVTILEVIEWINFO)
DllStructSetData($t_Struct2, "cbSize", DllStructGetSize($t_Struct2))
#cs
Const LVTVIM_TILESIZE = &H00000001
Const LVTVIM_COLUMNS     = &H00000002
Const LVTVIM_LABELMARGIN = &H00000004
#ce
DllStructSetData($t_Struct2, "dwMask", BitOR(0x2, 0x4))
#cs
public const int LVTVIF_AUTOSIZE = 0;
public const int LVTVIF_FIXEDWIDTH = 1;
public const int LVTVIF_FIXEDHEIGHT = 2;
public const int LVTVIF_FIXEDSIZE = 3;
#endregion
#ce
DllStructSetData($t_Struct2, "dwFlags", 0)
DllStructSetData($t_Struct2, "Size_cx", 160) ; Width
DllStructSetData($t_Struct2, "Size_cy", 50) ; Height
DllStructSetData($t_Struct2, "cLines", 2) ; cLines
DllStructSetData($t_Struct2, "RECT_left", 1) ; Margin Left
DllStructSetData($t_Struct2, "RECT_top", 10) ; Margin Top
DllStructSetData($t_Struct2, "RECT_right", 1) ; Margin Right
DllStructSetData($t_Struct2, "RECT_bottom", 10) ; Margin Bottom
$p_Struct2 = DllStructGetPtr($t_Struct2)
; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb761212(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb761212(v=vs.85).aspx[/url]
ConsoleWrite(_SendMessage($hListView, $LVM_SETTILEVIEWINFO, 0, $p_Struct2) & @CRLF)
For $iItem = 0 To 2
; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774766(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb774766(v=vs.85).aspx[/url]
Global $tag_LVTILEINFO = "UINT cbSize;INT iItem;UINT cColumns;PTR puColumns;" ;PTR piColFmt;"
$t_Struct = DllStructCreate($tag_LVTILEINFO)
DllStructSetData($t_Struct, "cbSize", DllStructGetSize($t_Struct)) ; cbSize
DllStructSetData($t_Struct, "iItem", $iItem) ; 0-based
DllStructSetData($t_Struct, "cColumns", 2) ; cColumns
$t_Struct_Cols = DllStructCreate("int;int")
DllStructSetData($t_Struct_Cols, 1, 2) ; show third column first
DllStructSetData($t_Struct_Cols, 2, 1) ; show second column last
DllStructSetData($t_Struct, "puColumns", DllStructGetPtr($t_Struct_Cols))
$p_Struct = DllStructGetPtr($t_Struct)
; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb761210(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb761210(v=vs.85).aspx[/url]
ConsoleWrite(_SendMessage($hListView, $LVM_SETTILEINFO, 0, $p_Struct) & @CRLF)
Next
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Regards

Edited by KaFu

Share this post


Link to post
Share on other sites

Have a look here:

Maybe it will solve your problems.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Ah, I've seen that in the past, forgot it and reinvented the wheel :lol:.. thanks for the hint, but no, sadly it does not seem to work properly (on XP) with that UDF either.

Share this post


Link to post
Share on other sites

Reordered the calls to

LVM_SETTILEVIEWINFO

_GUICtrlListView_SetView

LVM_SETTILEINFO

and now it works :)...

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

$GUI = GUICreate("ListView Example - Tile View", 400, 300)

$hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT))

; Load images
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))

_GUICtrlListView_SetImageList($hListView, $hImage, 1)
_GUICtrlListView_SetImageList($hListView, $hImage, 0) ; for Tile View

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

For $i = 0 To 19
    _GUICtrlListView_AddItem($hListView, "Row " & $i + 1 & ": Col 1", mod($i,3))
    _GUICtrlListView_AddSubItem($hListView, $i, "Row " & $i + 1 & ": Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, $i, "Row " & $i + 1 & ": Col 3", 2)
Next


; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774768(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb774768(v=vs.85).aspx[/url]
Global $tag_LVTILEVIEWINFO = "UINT cbSize;DWORD dwMask;DWORD dwFlags;STRUCT;LONG Size_cx;LONG Size_cy;ENDSTRUCT;INT cLines;STRUCT;LONG RECT_left;LONG RECT_top;LONG RECT_right;LONG RECT_bottom;ENDSTRUCT;"
$t_Struct2 = DllStructCreate($tag_LVTILEVIEWINFO)
DllStructSetData($t_Struct2, "cbSize", DllStructGetSize($t_Struct2))
#cs
    Const LVTVIM_TILESIZE    = &H00000001
    Const LVTVIM_COLUMNS    = &H00000002
    Const LVTVIM_LABELMARGIN = &H00000004
#ce
DllStructSetData($t_Struct2, "dwMask", 7)
#cs
    public const int LVTVIF_AUTOSIZE = 0;
    public const int LVTVIF_FIXEDWIDTH = 1;
    public const int LVTVIF_FIXEDHEIGHT = 2;
    public const int LVTVIF_FIXEDSIZE = 3;
    #endregion
#ce
DllStructSetData($t_Struct2, "dwFlags", 3)
DllStructSetData($t_Struct2, "Size_cx", 180) ; Width
DllStructSetData($t_Struct2, "Size_cy", 80) ; Height

DllStructSetData($t_Struct2, "cLines", 2) ; cLines

DllStructSetData($t_Struct2, "RECT_left", 10) ; Margin Left
DllStructSetData($t_Struct2, "RECT_top", 5) ; Margin Top
DllStructSetData($t_Struct2, "RECT_right", 10) ; Margin Right
DllStructSetData($t_Struct2, "RECT_bottom", 5) ; Margin Bottom
$p_Struct2 = DllStructGetPtr($t_Struct2)
; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb761212(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb761212(v=vs.85).aspx[/url]
ConsoleWrite(_SendMessage($hListView, $LVM_SETTILEVIEWINFO, 0, $p_Struct2) & @CRLF)

_GUICtrlListView_SetView($hListView, 4)

For $iItem = 0 To 19
    ; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774766(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb774766(v=vs.85).aspx[/url]
    Global $tag_LVTILEINFO = "UINT cbSize;INT iItem;UINT cColumns;PTR puColumns;" ;PTR piColFmt;"
    $t_Struct = DllStructCreate($tag_LVTILEINFO)
    DllStructSetData($t_Struct, "cbSize", DllStructGetSize($t_Struct)) ; cbSize
    DllStructSetData($t_Struct, "iItem", $iItem) ; 0-based
    DllStructSetData($t_Struct, "cColumns", 2) ; cColumns
    $t_Struct_Cols = DllStructCreate("int;int")
    DllStructSetData($t_Struct_Cols, 1, 2) ; show third column first
    DllStructSetData($t_Struct_Cols, 2, 1) ; show second column last
    DllStructSetData($t_Struct, "puColumns", DllStructGetPtr($t_Struct_Cols))
    $p_Struct = DllStructGetPtr($t_Struct)
    ; [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb761210(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb761210(v=vs.85).aspx[/url]
    ConsoleWrite(_SendMessage($hListView, $LVM_SETTILEINFO, 0, $p_Struct) & @CRLF)
Next

_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE )

GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Edited by KaFu

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  

  • Similar Content

    • By Miliardsto
      I have the following code. You can see there are $color_normal and $color_trans
      In my case normal is too dark . And color trans is to much violet.
      If you run it you will see how its looks. I want gui with listView have the same color like taskbar in windows 10.
      How to achieve that?
       
       
      #include <Date.au3> #include <MsgBoxConstants.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> HotKeySet("{ESC}", "Terminate") $color_normal = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) $color_trans = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) $trans = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") ConsoleWrite("Transpart = " & $trans & @CRLF) ConsoleWrite("Color normal = " & $color_normal & @CRLF) ConsoleWrite("Color trans = " & $color_trans & @CRLF) ConsoleWrite(_Get_taskbar_color()); It return AARRGGBB $taskbarColor = _Get_taskbar_color() Global $gui = GUICreate("Test", 150, 58,@DesktopWidth-300,@DesktopHeight-58,$WS_POPUP,BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Global $idListview = GUICtrlCreateListView("", 0, 0, 150, 58,BitOR($LBS_NOTIFY,$LBS_SORT), 0) ;_GuiCtrlMakeTrans(-1,100) ; Add column _GUICtrlListView_AddColumn($idListview, "Msgs", 100) GUICtrlSetFont(-1, 7, 400, 0, "Segoe UI") GUICtrlSetColor(-1, 0x470C4F) GUICtrlSetBkColor($idListview, 0x310638) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Terminate() Exit EndFunc Func _Get_taskbar_color() If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "ColorPrevalence") Then If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) Else Return "0xFF" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) EndIf Else If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9000000" Else Return "0xFF000000" EndIf EndIf EndFunc  
    • By Xandy
      What's new section:
      Snowman_Sky is game using MapIt engine.  MapIt will evolve here for a little bit.
      Download: [ http://songersoft.com/programming/Snowman_Sky.zip ]
      Video demonstrating new sprite_sheet class and weather effect.
      Working on the Class section of the Character Sheet.
      Which is what makes multiclassing possible.

      Changing the value of Class will load the stored value for XP.  Lvl will be updated to the XP tier.
      Hit points are then rolled for each level of all learned classes.  Hit dice are specific to each class and a Constitution modifier is added to each roll of hit die.
       
    • By Slipk
      Hello everybody,
      #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListViewEx.au3> $Form1 = GUICreate("Form1", 539, 350, 192, 124) $ListView1 = GUICtrlCreateListView("CLM1|CLM2", 0, 0, 538, 326) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) Local $dynamic = GUICtrlCreateListViewItem("Example1|Example2", $ListView1) $SubMenu = GUICtrlCreateContextMenu($dynamic) $Run = GUICtrlCreateMenuItem("Run", $SubMenu) $Edit = GUICtrlCreateMenuItem("Edit", $SubMenu) $Delete = GUICtrlCreateMenuItem("Delete", $SubMenu) Local $dynamic2 = GUICtrlCreateListViewItem("Example3|Example6", $ListView1) $SubMenu = GUICtrlCreateContextMenu($dynamic2) $Run = GUICtrlCreateMenuItem("Run", $SubMenu) $Edit = GUICtrlCreateMenuItem("Edit", $SubMenu) $Delete = GUICtrlCreateMenuItem("Delete", $SubMenu) _GUIListViewEx_Init($ListView1, "", 0, 0, True, 64) _GUIListViewEx_MsgRegister() GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I use GUIListViewEx.au3 for position of items in listview but when I move one the context menu disappear. Any solution of this?
      Any method than array it is possible?
      Thank you, appreciate it.
       
       
    • By Slipk
      Hello everybody,
      I download the GUIListViewEx.au3 by Melba23 in order to move up or down my items from a listview.
      Everything it's looking good in script but when I move an item it will crash.
      Any suggestions?
      Thank you! 

    • By Slipk
      Hello everybody,
      Sorry for my bad english.
       
      I try to figure out if I have a dynamic listview with as many items as I want, how to save to a text file all the data listview contains in the same form that you put when you create a listviewitem. I will give you an example.
      When the script is running it will show you the listview and some items. How to take the items data "Data1|Data1_Sub1|Data1_Sub2" in this format and paste into a text file? All of them.
      I tried to explain as good as I can.
      Thank you for your attention!
      #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> $Form_Menu = GUICreate("Form Example", 351, 234, -1, -1) $Form_Menu_ListView1 = GUICtrlCreateListView("Column #1|Column #2|Column #3", 0, 0, 346, 230) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 75) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75) GUICtrlCreateListViewItem("Data1|Data1_Sub1|Data1_Sub2", $Form_Menu_ListView1) GUICtrlCreateListViewItem("Data2|Data2_Sub1|Data2_Sub2", $Form_Menu_ListView1) GUICtrlCreateListViewItem("DataN|DataN_SubN|DataN_SubN", $Form_Menu_ListView1) ;The data that appear in the listview be saved in a file like that : #cs Data1|Data1_Sub1|Data1_Sub2 Data2|Data2_Sub1|Data2_Sub2 DataN|DataN_SubN|DataN_SubN #ce GUISetState(@SW_SHOW, $Form_Menu) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
×
×
  • Create New...