Jump to content

Fix CheckBox position for ListView


Go to solution Solved by mike2003,

Recommended Posts

Posted (edited)

I found that if you change the font size, the CheckBox position look wrong. like they are between the lines.

this is confusing...
post-38353-0-62735600-1415121137_thumb.j

How can I fix this?

PS

CheckBox alignment should be at the center or on the bottom, but not on top of the text

post-38353-0-90443900-1415121385.jpg

Edited by mike2003
  • Moderators
Posted

mike2003,

I have just checked on one of my scripts and I do not get the same "offset" effect when I change the font of a ListView. Can you please post a reproducer script. :)

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

 

Posted

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$ListView1 = GUICtrlCreateListView("", 40, 32, 457, 297, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_SMALLICON), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$ListView1_0 = GUICtrlCreateListViewItem("aaaaaa", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("bbbbbbbb", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("ccccccccc", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("dddddddddd", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("eeeeeeeee", $ListView1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

  • Moderators
Posted

mike2003,

You are setting the ListView styles incorrectly - this works fine for me. :)

$ListView1 = GUICtrlCreateListView("Column 1", 40, 32, 457, 297)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, $LVS_EX_CHECKBOXES)
You do not want to add the $LVS_SMALLICON style if you are using checkboxes (you need the default $LVS_REPORT mode). And always set the ListView extended styles as I have above - many of them share numeric values with the $WS_EX_* styles (an MS problem, not AutoIt) and you can get unwanted results if you add them in the creation line. ;)

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

 

Posted (edited)

you use COLUMN mode. in this mode auto-wrap dont work.

in my code i have auto page split.

post-38353-0-14504600-1415127043_thumb.j

this is not exactly what i need

i have more horizontal space and dont want extra scroll

Edited by mike2003
  • Moderators
Posted

mike2003,

It does help if you explain everything at the beginning of a thread. :whistle:

If you want to use checkboxes in other ListView modes then I cannot help you as I have very little experience of them, sorry. :(>

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

 

Posted

Why not just make an extra column and then use $LVS_NOCOLUMNHEADER. I'm betting it will look exactly the same as what Melba so graciously provided you. ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

Then why not make two listviews and put them next to each other with no column headers and no scrollbars?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

If your not going to try different solutions, then why should we give them to you?

Done trying to help you.  :bye:

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted (edited)

The question was "how to correctly position the checkbox?"

I do not need a general discussion as it might be at all
Edited by mike2003
Posted

I know what your question was, I can read thank you.  :closedeyes:

I've tried this and it is due to the spacing in the fonts. Seemingly I have tried doing this with the $LVS_SMALLICON, $LVS_LIST, $LVS_ICON, and $LVS_REPORT. It seems this is not possible without reprogramming how the checkboxes are made and centered on the item.  :whistle:

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted (edited)

Dont know if something like this catagorize as bug at all... but my main question is where are your icons?

 

Sloppy edited a random script from AutoIt forum for this purpose: 

#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#Include <GuiImageList.au3>
#include <GuiListView.au3>
#NoTrayIcon
Opt("GUIOnEventMode", 1)

_Singleton(@ScriptName)

$hGUI=GUICreate ("test", 500,300,-1,-1)

GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiMsg")

$hListView = GUICtrlCreateListView("", 0, 0,500, 300)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_CHECKBOXES)

GUICtrlSetStyle($hListView, $LVS_SMALLICON)

;~ $hImage = _GUIImageList_Create(32, 32, 5, 3)
$hImage = _GUIImageList_Create(1, 32, 5, 3);use upper to fully display icons

;~ _GUIImageList_AddIcon($hImage, "shell32.dll", "15", True) ;Extract large icons;ennable this line to display icons
_GUICtrlListView_SetImageList($hListView, $hImage, 1)     ;but use as small icons

For $x = 0 To 99
    _GUICtrlListView_AddItem($hListView, 'Testtttt'&$x + 1 , 0)
Next

_GUICtrlListView_SetView($hListView, 2) ;Set the view mode (2 = List)

GUISetState()

While 1
  Sleep(100)
Wend

Func _GuiMsg()
  Switch @GUI_CTRLID
        Case  $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            guisetstate(@SW_MINIMIZE)
    EndSwitch
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted

Very cool bogQ :D

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

  • Solution
Posted

works well. these two lines of code helped me

$hImage = _GUIImageList_Create(1, 28)
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)

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