Guest Posted September 19, 2013 Share Posted September 19, 2013 (edited) hello, i want to create this kind of listview: 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 September 19, 2013 by Guest Link to comment Share on other sites More sharing options...
Guest Posted September 19, 2013 Share Posted September 19, 2013 (edited) ...... Edited September 19, 2013 by Guest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 19, 2013 Moderators Share Posted September 19, 2013 gil900,How about sticking to one thread at a time. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Guest Posted September 19, 2013 Share Posted September 19, 2013 gil900, How about sticking to one thread at a time. M23 ok sorry.. i waiting for help Link to comment Share on other sites More sharing options...
BrewManNH Posted September 19, 2013 Share Posted September 19, 2013 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 GudeHow 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 Link to comment Share on other sites More sharing options...
Guest Posted September 20, 2013 Share Posted September 20, 2013 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. Link to comment Share on other sites More sharing options...
FireFox Posted September 20, 2013 Share Posted September 20, 2013 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. Link to comment Share on other sites More sharing options...
LarsJ Posted September 21, 2013 Share Posted September 21, 2013 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. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted September 22, 2013 Share Posted September 22, 2013 (edited) This is an example. Copied from the help file. You will find the checkbox images and code in the zip. expandcollapse popup#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 EndFuncLV.7z Edited September 22, 2013 by LarsJ Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted September 22, 2013 Share Posted September 22, 2013 Added complete example in previous post. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2013 Share Posted September 22, 2013 (edited) Thank you very much LarsJ. but i don't want images that will come with the exe file. do you have a solution? Edited September 22, 2013 by Guest Link to comment Share on other sites More sharing options...
BrewManNH Posted September 22, 2013 Share Posted September 22, 2013 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 GudeHow 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 Link to comment Share on other sites More sharing options...
LarsJ Posted September 23, 2013 Share Posted September 23, 2013 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. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted September 23, 2013 Share Posted September 23, 2013 @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 Link to comment Share on other sites More sharing options...
LarsJ Posted September 23, 2013 Share Posted September 23, 2013 gil900, Here the bitmaps are included directly in code: expandcollapse popup#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", 2) EndIf EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func FillImageList( $hImageList ) Local $aCheckboxUnChecked[822] = [ _ 66,77,54,3,0,0,0,0,0,0,54,0,0,0,40,0,0,0,16,0,0,0,16,0,0,0,1,0,24,0,0,0,0,0,0,0,0,0,196,14,0,0,196,14,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81, _ 28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,239,241,241,241,243,243,244,245,245, _ 246,247,247,248,249,249,250,251,251,252,253,253,254,254,254,255,255,255,255,255,255,255,255,255,8364,81,28,255,255,255,255,255,255,255,255,255, _ 8364,81,28,236,239,239,239,241,241,241,243,243,244,245,245,246,247,247,248,249,249,250,251,251,252,253,253,254,254,254,255,255,255,255,255,255, _ 8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,233,236,236,236,239,239,239,241,241,241,243,243,244,245,245,246,247,247,248,249,249, _ 250,251,251,252,253,253,254,254,254,255,255,255,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,229,232,232,233,236,236,236,239,239, _ 239,241,241,241,243,243,244,245,245,246,247,247,248,249,249,250,251,251,252,253,253,254,254,254,8364,81,28,255,255,255,255,255,255,255,255,255, _ 8364,81,28,226,229,229,229,232,232,233,236,236,236,239,239,239,241,241,241,243,243,244,245,245,246,247,247,248,249,249,250,251,251,252,253,253, _ 8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,222,226,226,226,229,229,229,232,232,233,236,236,236,239,239,239,241,241,241,243,243, _ 244,245,245,246,247,247,248,249,249,250,251,251,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,219,224,224,222,226,226,226,229,229, _ 229,232,232,233,236,236,236,239,239,239,241,241,241,243,243,244,245,245,246,247,247,248,249,249,8364,81,28,255,255,255,255,255,255,255,255,255, _ 8364,81,28,217,222,222,219,224,224,222,226,226,226,229,229,229,232,232,233,236,236,236,239,239,239,241,241,241,243,243,244,245,245,246,247,247, _ 8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,215,220,220,217,222,222,219,224,224,222,226,226,226,229,229,229,232,232,233,236,236, _ 236,239,239,239,241,241,241,243,243,244,245,245,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,215,220,220,215,220,220,217,222,222, _ 219,224,224,222,226,226,226,229,229,229,232,232,233,236,236,236,239,239,239,241,241,241,243,243,8364,81,28,255,255,255,255,255,255,255,255,255, _ 8364,81,28,215,220,220,215,220,220,215,220,220,217,222,222,219,224,224,222,226,226,226,229,229,229,232,232,233,236,236,236,239,239,239,241,241, _ 8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81, _ 28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255 ] Local $aCheckboxChecked[822] = [ _ 66,77,54,3,0,0,0,0,0,0,54,0,0,0,40,0,0,0,16,0,0,0,16,0,0,0,1,0,24,0,0,0,0,0,0,0,0,0,196,14,0,0,196,14,0,0,0,0,0,0,0,0,0,0,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364, _ 81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,241,243,243,243,245, _ 245,246,247,247,248,249,249,249,250,250,251,252,252,253,253,253,254,254,254,255,255,255,255,255,255,255,255,255,8364,81,28,255,255,255,255, _ 255,255,255,255,255,8364,81,28,239,241,241,241,243,243,243,245,245,246,247,247,248,249,249,249,250,250,251,252,252,253,253,253,254,254,254, _ 255,255,255,255,255,255,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,236,239,239,239,241,241,241,243,243,243,245,245,33,161,33, _ 248,249,249,249,250,250,251,252,252,253,253,253,254,254,254,255,255,255,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,233,236,236, _ 236,239,239,239,241,241,33,161,33,33,161,33,33,161,33,248,249,249,249,250,250,251,252,252,253,253,253,254,254,254,8364,81,28,255,255,255,255, _ 255,255,255,255,255,8364,81,28,230,234,234,233,236,236,33,161,33,33,161,33,33,161,33,33,161,33,33,161,33,248,249,249,249,250,250,251,252,252, _ 253,253,253,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,227,231,231,230,234,234,33,161,33,33,161,33,239,241,241,33,161,33,33,161, _ 33,33,161,33,248,249,249,249,250,250,251,252,252,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,225,229,229,227,231,231,33,161,33, _ 233,236,236,236,239,239,239,241,241,33,161,33,33,161,33,33,161,33,248,249,249,249,250,250,8364,81,28,255,255,255,255,255,255,255,255,255,8364, _ 81,28,223,227,227,225,229,229,227,231,231,230,234,234,233,236,236,236,239,239,239,241,241,33,161,33,33,161,33,246,247,247,248,249,249,8364,81, _ 28,255,255,255,255,255,255,255,255,255,8364,81,28,221,226,226,223,227,227,225,229,229,227,231,231,230,234,234,233,236,236,236,239,239,239,241, _ 241,33,161,33,243,245,245,246,247,247,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28,221,226,226,221,226,226,223,227,227,225,229,229, _ 227,231,231,230,234,234,233,236,236,236,239,239,239,241,241,241,243,243,243,245,245,8364,81,28,255,255,255,255,255,255,255,255,255,8364,81,28, _ 221,226,226,221,226,226,221,226,226,223,227,227,225,229,229,227,231,231,230,234,234,233,236,236,236,239,239,239,241,241,241,243,243,8364,81,28, _ 255,255,255,255,255,255,255,255,255,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81,28,8364,81, _ 28,8364,81,28,8364,81,28,8364,81,28,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, _ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 ] _GDIPlus_Startup() Local $binImage = StringToBinary( StringFromASCIIArray( $aCheckboxUnChecked ) ) ; 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 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
PhoenixXL Posted September 23, 2013 Share Posted September 23, 2013 (edited) 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 expandcollapse popup#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 September 25, 2013 by PhoenixXL LarsJ 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. Link to comment Share on other sites More sharing options...
Guest Posted September 24, 2013 Share Posted September 24, 2013 (edited) 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:The checkboxes do not looking right.PhoenixXL, you also have a problem in your GUI. your checkboxes also not look good. 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 September 24, 2013 by Guest Link to comment Share on other sites More sharing options...
LarsJ Posted September 24, 2013 Share Posted September 24, 2013 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? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Guest Posted September 25, 2013 Share Posted September 25, 2013 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 .. Link to comment Share on other sites More sharing options...
PhoenixXL Posted September 25, 2013 Share Posted September 25, 2013 (edited) 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 With my script this is the output I get exactly the same as your image displayed(again download the script) ...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 September 25, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now