Jump to content

Multi-line column headings in GUICtrlCreateListView?


deparys
 Share

Recommended Posts

In order to conserve column width, is it possible to have ListView column headings split over two or more lines?

I have tried embedding @CRLF macros (e.g. GUICtrlCreateListView("Column 1 " & @CRLF & "heading | Column 2 " & @CRLF & "heading" ...) but this displays the headings on one line interspersed with small rectangular characters.

Any suggestions?

Link to comment
Share on other sites

deparys

conserve column width

Example:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global Const $HDN_FIRST = -300
Global Const $HDN_ITEMCHANGINGA = $HDN_FIRST - 0
Global Const $HDN_ITEMCHANGINGW = $HDN_FIRST - 20
Global Const $HDN_BEGINTRACKA = $HDN_FIRST - 6
Global Const $HDN_BEGINTRACKW = $HDN_FIRST - 26

$GUI = GUICreate("Static Columns Demo!", 420, 240)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

$ListView = GUICtrlCreateListView("Column1|Column2", 20, 20, 380, 200, $LVS_NOSORTHEADER)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS")

GUICtrlCreateListViewItem("Item 1|SubItem 1", $ListView)
GUICtrlCreateListViewItem("Item 2|SubItem 2", $ListView)

GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, 80)
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 1, 80)

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Quit()
    Exit
EndFunc

Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam)
    Local $TagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    
    Local $iEvent = DllStructGetData($TagNMHDR, 3)
    If $iEvent = $HDN_BEGINTRACKA Or $iEvent = $HDN_BEGINTRACKW Or _
        $iEvent = $HDN_ITEMCHANGINGA Or $iEvent = $HDN_ITEMCHANGINGW Then Return 1
    
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

Thanks for the reply rasim.

I probably did not explain my question very well, but as a picture is probably worth a thousand words, here is an example (created with my graphics editor) of what I am trying to achieve:

post-38769-1221419253_thumb.jpg

i.e. I would like the words in each column heading to appear on two or more lines withing the grey column heading.

Edited by deparys
Link to comment
Share on other sites

  • 7 years later...
  • Moderators

kjuenke,

Did you notice that the first post in this thread dates from over 7 years ago and that the OP has not been online since then?

Please do not necro-post like this again - just open a new thread and link to the old one if it is absolutely necessary for understanding the problem. We ask you to do this for two main reasons:

  • The language advances and the functionality might well be included in core or UDF code by now
  • The changes in language syntax mean that it is likely that code from more than a couple of years ago may well not run under the current release interpreter without significant modification.

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

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