Jump to content
Sign in to follow this  
gil900

how can i create listview like in the following example?

Recommended Posts

gil900

hello,

i want to create this kind of listview:

2hd06mr.jpg

i didn't found the example i'm looking for so i did this in photoshop.. sory if i did a bad job.

i need to create exactly this example and i also need a "add" button for adding new things to the list and "delete" button for deleting the selected line in the list.

thanks for helpers

Edited by gil900

Share this post


Link to post
Share on other sites
gil900

Share this post


Link to post
Share on other sites
Melba23

gil900,

How about sticking to one thread at a time. ;)

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

 

Share this post


Link to post
Share on other sites
gil900

gil900,

How about sticking to one thread at a time. ;)

M23

ok sorry..

i waiting for help

Share this post


Link to post
Share on other sites
BrewManNH

If you create a list view using the $LVS_EX_CHECKBOXES extended style you can get the checkboxes. While it won't be exactly like the one you posted, it should be close enough to get the job done.


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
gil900

If you create a list view using the $LVS_EX_CHECKBOXES extended style you can get the checkboxes. While it won't be exactly like the one you posted, it should be close enough to get the job done.

Does the checkboxs will be in the same place as in my example?

If so, can you give me an example code?

if not then i know what you talking about. I did a search on this forum before I opened this thread and i saw that example..

I strongly prefer that the checkboxs will be in the same place as in my example..

I would love if someone will build code/udf that makes it and give an example.

thanks.

Share this post


Link to post
Share on other sites
FireFox

AFAIK, the checkboxes can only be set on the first column.

Maybe with a custom drawn listview you can do it, but I don't know how.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
LarsJ

You can use images in subitems ($LVS_EX_SUBITEMIMAGES). It should be possible to create two small images that looks like a checked and unchecked checkbox and change the image when an item is clicked.

Share this post


Link to post
Share on other sites
LarsJ

This is an example. Copied from the help file. You will find the checkbox images and code in the zip.

LVwithcheckboxincol2_zps360a7f1c.jpg

 

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

Global $hListView, $LVchecked[4]

MainFunction()

Func MainFunction()
    Local $hGui, $hImage, $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    $hGui = GUICreate("ListView with Checkbox in Column 2", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    $hListView = ControlGetHandle( $hGui, "", $hListView )
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_AddBitmap($hImage, "CheckboxUnChecked.bmp")
    _GUIImageList_AddBitmap($hImage, "CheckboxChecked.bmp")
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 0", 0)
    _GUICtrlListView_AddColumn($hListView, "Column 1", 200)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 0, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "False", 2, 0)
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 1, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "True", 2, 1)
    $LVchecked[1] = 1
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 2, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 2, "False", 2, 0)
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 3, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 3, "True", 2, 1)
    $LVchecked[3] = 1

    ; Disable column resize
    ControlDisable($hGui, "", HWnd(_GUICtrlListView_GetHeader($hListView)))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    GUISetState()

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR, $hWndFrom, $iCode, $aHitTest, $item
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CLICK
                    $aHitTest = _GUICtrlListView_SubItemHitTest($hListView)
                    If $aHitTest[1] = 2 And $aHitTest[3] Then ; Col 2 and image
                        $item = $aHitTest[0]
                        $LVchecked[$item] = 1 - $LVchecked[$item]
                        _GUICtrlListView_SetItemImage($hListView, $item, $LVchecked[$item], 2)
                        If $LVchecked[$item] Then
                            _GUICtrlListView_SetItemText($hListView, $item, "True", 2)
                        Else
                            _GUICtrlListView_SetItemText($hListView, $item, "False", 2)
                        EndIf
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

LV.7z

Edited by LarsJ

Share this post


Link to post
Share on other sites
LarsJ
gil900

Thank you very much LarsJ.

but i don't want images that will come with the exe file. do you have a solution?

Edited by gil900

Share this post


Link to post
Share on other sites
BrewManNH

I believe what your picture is showing is a gridview, and not a listview control. You have more options using a gridview than you do with a listview. I'm pretty sure you can't have a checkbox in the second column short of using an ownerdrawn listview, but that's a lot harder to work with. I have no experience using an owner drawn listview so I can't give examples but you might be able to find some on here.


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
LarsJ

gil900, If it's only the BMP-files that are the problem it should be possible to represent these files as text strings directly in code. This should be possible to do with GDIPlus commands. It should also be possible to create bitmaps from the text strings and add these bitmaps to the image list.

Share this post


Link to post
Share on other sites
DatMCEyeBall

@gil900 - Could you use the Autoit Window Info tool on the control in the OP, so we can see what it is?


"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
LarsJ

gil900, Here the bitmaps are included directly in code:

 

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>
#include <Memory.au3>

Global $hListView, $aLVchecked[4]

MainFunction()

Func MainFunction()
    Local $hGui, $hImageList, $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    $hGui = GUICreate("ListView with Checkbox in Column 2", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    $hListView = ControlGetHandle( $hGui, "", $hListView )
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)

    ; Load images
    $hImageList = _GUIImageList_Create()
    FillImageList( $hImageList )
    _GUICtrlListView_SetImageList($hListView, $hImageList, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 0", 0)
    _GUICtrlListView_AddColumn($hListView, "Column 1", 200)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 0, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "False", 2, 0)
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 1, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "True", 2, 1)
    $aLVchecked[1] = 1
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 2, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 2, "False", 2, 0)
    _GUICtrlListView_AddItem($hListView, "")
    _GUICtrlListView_AddSubItem($hListView, 3, "Checkbox in column 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 3, "True", 2, 1)
    $aLVchecked[3] = 1

    ; Disable column resize
    ControlDisable($hGui, "", HWnd(_GUICtrlListView_GetHeader($hListView)))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    GUISetState()

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR, $hWndFrom, $iCode, $aHitTest, $item
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CLICK
                    $aHitTest = _GUICtrlListView_SubItemHitTest($hListView)
                    If $aHitTest[1] = 2 And $aHitTest[3] Then ; Col 2 and image
                        $item = $aHitTest[0]
                        $aLVchecked[$item] = 1 - $aLVchecked[$item]
                        _GUICtrlListView_SetItemImage($hListView, $item, $aLVchecked[$item], 2)
                        If $aLVchecked[$item] Then
                            _GUICtrlListView_SetItemText($hListView, $item, "True", 2)
                        Else
                            _GUICtrlListView_SetItemText($hListView, $item, "False"; Create stream object from image
    Local $tSize = StringLen( $binImage ) + 1
    Local $imgData = DllStructCreate( "byte[" & $tSize & "]" )
    DllStructSetData( $imgData, 1, $binImage )
    Local $iLength = DllStructGetSize( $imgData )
    Local $hMemory = _MemGlobalAlloc( $iLength, $GMEM_MOVEABLE )
    Local $pDest = _MemGlobalLock( $hMemory )
    Local $pSource = DllStructGetPtr( $imgData )
    _MemMoveMemory( $pSource, $pDest, $iLength )
    Local $pStream = _WinAPI_CreateStreamOnHGlobal( $pDest )

    ; Create bitmap from stream object
    Local $hImage = _GDIPlus_BitmapCreateFromStream( $pStream )
    Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap( $hImage )

    _GUIImageList_Add( $hImageList, $hBitmap )

    ; Cleanup
    _WinAPI_ReleaseStream( $pStream )
    _GDIPlus_ImageDispose( $hImage )
    _WinAPI_DeleteObject( $hBitmap )

    Local $binImage = StringToBinary( StringFromASCIIArray( $aCheckboxChecked ) )

    ; Create stream object from image
    Local $tSize = StringLen( $binImage ) + 1
    Local $imgData = DllStructCreate( "byte[" & $tSize & "]" )
    DllStructSetData( $imgData, 1, $binImage )
    Local $iLength = DllStructGetSize( $imgData )
    Local $hMemory = _MemGlobalAlloc( $iLength, $GMEM_MOVEABLE )
    Local $pDest = _MemGlobalLock( $hMemory )
    Local $pSource = DllStructGetPtr( $imgData )
    _MemMoveMemory( $pSource, $pDest, $iLength )
    Local $pStream = _WinAPI_CreateStreamOnHGlobal( $pDest )

    ; Create bitmap from stream object
    Local $hImage = _GDIPlus_BitmapCreateFromStream( $pStream )
    Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap( $hImage )

    _GUIImageList_Add( $hImageList, $hBitmap )

    ; Cleanup
    _WinAPI_ReleaseStream( $pStream )
    _GDIPlus_ImageDispose( $hImage )
    _WinAPI_DeleteObject( $hBitmap )

    _GDIPlus_Shutdown()
EndFunc

Func _GDIPlus_BitmapCreateFromStream( $pStream )
    Local $Ret = DllCall( $ghGDIPDll, 'uint', 'GdipCreateBitmapFromStream', 'ptr', $pStream, 'ptr*', 0 )
    If (@error) OR ($Ret[0]) Then
        Return SetError(@error, @extended, 0)
    EndIf
    Return $Ret[2]
EndFunc

Share this post


Link to post
Share on other sites
PhoenixXL

Don't want to use Bitmaps, the only option left is Owner Drawn ListView then, I simplified it by using Webdings(font containing many symbols), you can do it with GDI+ even. I have even changed the color of the selection. Modify as you need

Here is the example

#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <Misc.au3>

Global Const $ODT_LISTVIEW = 102
Global Const $ODA_DRAWENTIRE = 0x1
Global Const $ODS_SELECTED = 0x0001

Global $GUI_main = GUICreate("Phoenix XL | 09.23.2013", 300, 300)
Global $hGUI_tab_listview[2][10]
Global $hNewFont = -1

GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM") ;place before listview creation - message sent once for each ownerdrawn control created
GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

Global $iCheckboxItem = 1 ;first subitem is the checkitem
Global $aCheckBoxStates[11]

$hGUI_tab_listview[0][0] = GUICtrlCreateListView("", 15, 20, 250, 260, _
        BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_OWNERDRAWFIXED)) ; + $LVS_EX_CHECKBOXES + $LVS_SINGLESEL
Global $hListView = GUICtrlGetHandle(-1)

_GUICtrlListView_AddColumn(-1, "Name")
_GUICtrlListView_SetColumnWidth(-1, 0, 155)
_GUICtrlListView_AddColumn(-1, "Count")
_GUICtrlListView_SetColumnWidth(-1, 1, 72)

For $i = 0 To 10 ; populate the listview for testing purposes
    _GUICtrlListView_AddItem(-1, "test " & $i)
    _GUICtrlListView_AddSubItem(-1, $i, $i, 1)
Next

GUISetState(@SW_SHOW)

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_WinAPI_DeleteObject($hNewFont)

For $i = 0 To 10
    ConsoleWrite("Item:  " & $i & @TAB & "CheckBox Toggled? " & _Iif($aCheckBoxStates[$i], "True", "False") & @CRLF)
Next

Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam)
    Local $tMEASUREITEMS = DllStructCreate("uint cType;uint cID;uint itmID;uint itmW;uint itmH;ulong_ptr itmData", $lParam)
    If DllStructGetData($tMEASUREITEMS, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG
    GUIRegisterMsg($WM_MEASUREITEM, "") ;call this after last ownerdrawn listview created
    Return 1
EndFunc   ;==>WM_MEASUREITEM

Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)

    Local $tagDRAWITEMSTRUCT, $iBrushColor, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $bSelected
    $tagDRAWITEMSTRUCT = DllStructCreate( _
            "uint cType;" & _
            "uint cID;" & _
            "uint itmID;" & _
            "uint itmAction;" & _
            "uint itmState;" & _
            "hwnd hItm;" & _
            "handle hDC;" & _
            "long itmRect[4];" & _
            "ulong_ptr itmData" _
            , $lParam)
    If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG

    $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID")
    $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID")
    $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction")
    $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState")
    $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm")
    $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC")
    $bSelected = BitAND($itmState, $ODS_SELECTED)
    Switch $cID ; will look for ControlID, not window handle.
        Case $hGUI_tab_listview[0][0]
            Switch $itmAction
                Case $ODA_DRAWENTIRE

                    ; don't forget, this is BGR, not RGB
                    If $itmState = $bSelected Then ; item is not selected
                        $iBrushColor = 0xFFFFFF
                    Else ; item is selected
                        $iBrushColor = 0xC0CDEF
                    EndIf

                    Local $aBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $iBrushColor)
                    Local $aBrushOld = _WinAPI_SelectObject($hDC, $aBrush[0])
                    Local $iLeft = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1)
                    DllStructSetData($tagDRAWITEMSTRUCT, "itmRect", $iLeft + 1, 1) ; rectangle coordinates for coloring
                    ; +1 is the left margin
                    _WinAPI_FillRect($hDC, DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), $aBrush[0])
                    _WinAPI_SelectObject($hDC, $aBrushOld)
                    _WinAPI_DeleteObject($aBrush[0])

                    ; for all columns of the row:
                    Local $iIndent_Checkbox = 18, $iSubItmText, $aSubItmRect, $iSubItmRect, $hOldFont
                    $local_alignment = $DT_LEFT

                    For $i = 0 To _GUICtrlListView_GetColumnCount($hGUI_tab_listview[0][0]) - 1

                        ; 1. get subitem text:
                        $iSubItmText = _GUICtrlListView_GetItemText($hGUI_tab_listview[0][0], $itmID, $i)

                        ; 2. get subitem coordinates for drawing its respective text
                        $aSubItmRect = _GUICtrlListView_GetSubItemRect($hGUI_tab_listview[0][0], $itmID, $i)
                        ; the function above accepts not only subitems (one-based index), but also main item (index=0)

                        ; 3. pass the coordinates to a DLL struct
                        $iSubItmRect = DllStructCreate("long[4]")
                        DllStructSetData($iSubItmRect, 1, $aSubItmRect[0] + 2, 1) ; +2 is left margin (X)

                        If $i = $iCheckboxItem Then DllStructSetData($iSubItmRect, 1, $aSubItmRect[0] + 2 + $iIndent_Checkbox, 1) ;indentation for the checkbox

                        DllStructSetData($iSubItmRect, 1, $aSubItmRect[1], 2) ;
                        DllStructSetData($iSubItmRect, 1, $aSubItmRect[2], 3)
                        DllStructSetData($iSubItmRect, 1, $aSubItmRect[3], 4)
                        _WinAPI_DrawText($hDC, $iSubItmText, $iSubItmRect, $local_alignment)

                        If $i = $iCheckboxItem Then ;subitem

                            If $hNewFont = -1 Then
                                Local $LOGFONT, $tFont, $pFont

                                $hNewFont = _WinAPI_CreateFont(10, 10) ;create a temp font
                                $hOldFont = _WinAPI_SelectObject($hDC, $hNewFont) ;get the current selected font
                                $LOGFONT = _
                                        'LONG lfHeight;' & _
                                        'LONG lfWidth;' & _
                                        'LONG lfEscapement;' & _
                                        'LONG lfOrientation;' & _
                                        'LONG lfWeight;' & _
                                        'BYTE lfItalic;' & _
                                        'BYTE lfUnderline;' & _
                                        'BYTE lfStrikeOut;' & _
                                        'BYTE lfCharSet;' & _
                                        'BYTE lfOutPrecision;' & _
                                        'BYTE lfClipPrecision;' & _
                                        'BYTE lfQuality;' & _
                                        'BYTE lfPitchAndFamily;' & _
                                        'WCHAR lfFaceName [32];'
                                $tFont = DllStructCreate($LOGFONT)

                                $pFont = DllStructGetPtr($tFont)
                                _WinAPI_GetObject($hOldFont, DllStructGetSize($tFont), $pFont) ;get the logfont of the selected font
                                _WinAPI_DeleteObject($hNewFont) ;delete the temporary font

                                DllStructSetData($tFont, "lfFaceName", "Wingdings")
                                DllStructSetData($tFont, "lfHeight", DllStructGetData($tFont, "lfHeight") - 3)

                                $hNewFont = _WinAPI_CreateFontIndirect($tFont) ;create the new font having the same properties as the old font had
                            EndIf

                            _WinAPI_SelectObject($hDC, $hNewFont) ;select the new font

                            DllStructSetData($iSubItmRect, 1, $aSubItmRect[0] + 2, 1) ; +2 is left margin (X)
                            DllStructSetData($iSubItmRect, 1, $aSubItmRect[1], 2) ;
                            DllStructSetData($iSubItmRect, 1, $aSubItmRect[0] + 2 + $iIndent_Checkbox, 3)
                            DllStructSetData($iSubItmRect, 1, $aSubItmRect[3], 4)

                            ;check = 254, blank = 168
                            _WinAPI_DrawText($hDC, ChrW(_Iif($aCheckBoxStates[$itmID], 254, 168)), $iSubItmRect, $local_alignment) ;wingdings 168 character is an empty box

                            _WinAPI_SelectObject($hDC, $hOldFont)
                        EndIf

                    Next


            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DRAWITEM

Func WM_DESTROY($hWnd, $iMsg, $iwParam, $ilParam)
    ;for releasing the static objects from the memory.
    _SendMessage($hWnd, $WM_DRAWITEM, -1, -1)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DESTROY


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR, $hWndFrom, $iCode, $aHitTest, $item
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CLICK
                    $aHitTest = _GUICtrlListView_SubItemHitTest($hListView)
                    If $aHitTest[0] >= 0 And $aHitTest[1] = $iCheckboxItem Then ; if checkbox item is clicked
                        $aCheckBoxStates[$aHitTest[0]] = Not $aCheckBoxStates[$aHitTest[0]]
                        _GUICtrlListView_RedrawItems($hListView, $aHitTest[0], $aHitTest[0])
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY 

Keypoints of Basic Framework

  • WM_DRAWITEM and WM_MEASUREITEM are used for custom drawing
  • The Text is drawn with the default font.
  • The Font is changed to Webdings and the respective symbol resembling a check box is drawn.
  • WM_NOTIFY is used to detect user clicks on the items for toggling the states of the checkboxes.

 

Let me know what you think about it

Thumbs up if it helped

Regards :)

Edited by PhoenixXL
  • Like 1

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
gil900

Thank you very much for the help!
You really helping me.

LarsJ, there is a problem with your GUI (which gave in post #15 ). Look:
2yvqxzb.jpg

The checkboxes do not looking right.

PhoenixXL, you also have a problem in your GUI. your checkboxes also not look good.
w86lbo.jpg


if you will fix it then i will prefer your example because you do not use pictures and your example demonstrates the process better so it will be more easy to work with your example and you also change the names of the columns and this is very important.

Edited by gil900

Share this post


Link to post
Share on other sites
LarsJ

gil900, I have testet the code in post 15 on XP 32 bit and Win 7 64 bit under AutoIt 3.3.8.1. In both cases the images looks as the images in post 9. In which environment are you running the script?

Share this post


Link to post
Share on other sites
gil900

gil900, I have testet the code in post 15 on XP 32 bit and Win 7 64 bit under AutoIt 3.3.8.1. In both cases the images looks as the images in post 9. In which environment are you running the script?

i am using windows 7 64bit. the script runing under autoIt 3.3.8.1 .

i compiled the script to 32bit ..

Share this post


Link to post
Share on other sites
PhoenixXL

Surely there is some issue on your computer, please check the theme settings on your computer

For Me - Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)

With LarsJ script this is the output I get

post-67952-0-62435900-1380115273_thumb.p

With my script this is the output I get exactly the same as your image displayed(again download the script)

post-67952-0-95911900-1380115294_thumb.p

...and you also change the names of the columns and this is very important.

 

You should do it, its rather easy if you try. When you stop to try none will help you..!

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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  

×