Jump to content

GuiCtrlCreateListViewItem first row, left "margin".


Recommended Posts

example

#include <Constants.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
Opt('MustDeclareVars', 1)

Local $main_GUI, $main_listView

$main_GUI =     GuiCreate ("Sample GUI", 400, 400)
                GuiSetIcon (@SystemDir & "\mspaint.exe", 0)

$main_listView =    GuiCtrlCreateListView ("", 10, 10, 380, 200)
                    _GUICtrlListView_AddColumn ($main_listView, "time", 100)
                    _GUICtrlListView_AddColumn ($main_listView, "description", 100)
                    _GUICtrlListView_SetColumnWidth ($main_listView, 1, $LVSCW_AUTOSIZE_USEHEADER)
                    
                    GuiCtrlCreateListViewItem ("A|One", $main_listView)
                    GuiCtrlCreateListViewItem ("B|Two", $main_listView)
                    GuiCtrlCreateListViewItem ("C|Three", $main_listView)
                    
                    _GUICtrlListView_SetBkColor ($main_listView, $CLR_BLACK)
                    _GUICtrlListView_SetTextColor ($main_listView, $CLR_WHITE)
                    _GUICtrlListView_SetTextBkColor ($main_listView, $CLR_MONEYGREEN)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

as you can see every row got a little margin from left side, how to disable\change it ?

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

I don't know that you can change that margin. It may be hard coded in Microsoft's API, and there is no margin management in the ListView messages available.

You get kudos though for a short, clear, running demo script to show your issue.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

sergeyWolf

Try this and see if this is what you want

Look for the comment Add a dummy and set to far left

#include <Constants.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
Opt('MustDeclareVars', 1)

Local $main_GUI, $main_listView, $item1

$main_GUI =     GuiCreate ("Sample GUI", 400, 400)
                GuiSetIcon (@SystemDir & "\mspaint.exe", 0)

$main_listView =    GuiCtrlCreateListView ("", 10, 10, 380, 200)
_GUICtrlListView_AddColumn ($main_listView, "",-1, 0);<-------------Add a dummy and set to far left
                    _GUICtrlListView_AddColumn ($main_listView, "time",100, 0)
                    _GUICtrlListView_AddColumn ($main_listView, "description", 100, 0)
                    _GUICtrlListView_SetColumnWidth ($main_listView, 1, -1)

                    $item1 = GuiCtrlCreateListViewItem ("A|One", $main_listView)
                     _GUICtrlListView_SetItemIndent($main_listView, 1, 0)

                    GuiCtrlCreateListViewItem ("B|Two", $main_listView)
                    GuiCtrlCreateListViewItem ("C|Three", $main_listView)

                    _GUICtrlListView_SetBkColor ($main_listView, $CLR_BLACK)
                    _GUICtrlListView_SetTextColor ($main_listView, $CLR_WHITE)

 _GUICtrlListView_SetTextBkColor ($main_listView, -1)
 _GUICtrlListView_SetTextBkColor ($main_listView, $CLR_MONEYGREEN)
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Hope this helps!

Link to comment
Share on other sites

If i manage to get throug functions the handle of the Items you can set the rgn for each one.

I do an example with the ListView, it is not very good.

#include <Constants.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <winapi.au3>
Opt('MustDeclareVars', 1)

Local $main_GUI, $main_listView

$main_GUI =     GuiCreate ("Sample GUI", 400, 400)
                GuiSetIcon (@SystemDir & "\mspaint.exe", 0)

$main_listView =    GuiCtrlCreateListView ("A|One", 10, 10, 380, 200)
                    _GUICtrlListView_AddColumn ($main_listView, "time", 100)
                    _GUICtrlListView_AddColumn ($main_listView, "description", 100)
                    _GUICtrlListView_SetColumnWidth ($main_listView, 1, $LVSCW_AUTOSIZE_USEHEADER)

                    GuiCtrlCreateListViewItem ("A|One", $main_listView)
                    GuiCtrlCreateListViewItem ("B|Two", $main_listView)
                    GuiCtrlCreateListViewItem ("C|Three", $main_listView)

                    _GUICtrlListView_SetBkColor ($main_listView, $CLR_BLACK)
                    _GUICtrlListView_SetTextColor ($main_listView, $CLR_WHITE)
                    _GUICtrlListView_SetTextBkColor ($main_listView, $CLR_MONEYGREEN)

_ChopListViewMargin($main_GUI, $main_listView)
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func _ChopListViewMargin($hGUI, $hListView)
    If not HWnd($hListView) Then $hListView = ControlGetHandle($hGUI, "", $hListView)
    Local $Rgn = _winapi_getwindowrect($hListView)
    local $Left = DllStructGetData($Rgn, "Left")
    local $top = DllStructGetData($Rgn, "Top")
    local $Right = DllStructGetData($Rgn, "Right")
    local $Bottom = DllStructGetData($Rgn, "Bottom")
    local $NewRgn = _winapi_CreateRectRgn(6,0,$Right-$Left-12,$Bottom-$top)
    local $ret = _winapi_setwindowRgn($hListView,$NewRgn)
    _WinAPI_DeleteObject($NewRgn)
    return $ret
EndFunc

EDITED: @Newbercase example is far better :)

Edited by monoscout999
Link to comment
Share on other sites

Thank monoscout999 for the kind words! However, I've learned a lot from your codes that you have posted here on the forms :}

Here is the full working version and disregard the top post

#include <Constants.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
Opt('MustDeclareVars', 1)

Local $main_GUI, $main_listView

$main_GUI =     GuiCreate ("Sample GUI", 400, 400)
                GuiSetIcon (@SystemDir & "\mspaint.exe", 0)

$main_listView =    GuiCtrlCreateListView ("", 10, 10, 380, 200)
_GUICtrlListView_AddColumn ($main_listView, "", -1);<-------------Add a dummy and set to far left
                    _GUICtrlListView_AddColumn ($main_listView, "Time", 100)
                    _GUICtrlListView_AddColumn ($main_listView, "Description", 100)
                    _GUICtrlListView_SetColumnWidth ($main_listView, 1, $LVSCW_AUTOSIZE_USEHEADER)

                    GuiCtrlCreateListViewItem ("|A|One", $main_listView)
                    GuiCtrlCreateListViewItem ("|B|Two", $main_listView)
                    GuiCtrlCreateListViewItem ("|C|Three", $main_listView)

                    _GUICtrlListView_SetBkColor ($main_listView, $CLR_BLACK)
                    _GUICtrlListView_SetTextColor ($main_listView, $CLR_WHITE)
                    _GUICtrlListView_SetTextBkColor ($main_listView, $CLR_MONEYGREEN)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd
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...