veronesi Posted July 19, 2012 Share Posted July 19, 2012 (edited) When I use the $LVS_EX_TRANSPARENTBKGND style for a ListView, then it gets correctly a transparent background. But all columns are transformed! Will mean, Column A is right, and Column C is left. Also the scrollbar is on the left side. What's wrong here? (You can remove the $LVS_EX_TRANSPARENTBKGND and then the ListView is as normal!) An other problem is, that the transparent background would only work for GUISetBkColor. But not for GUICtrlCreatePic! Is there an other way for this? #include #include Opt("GuiOnEventMode", 1) GUICreate("Test", 1024, 768, -1, -1) GUISetOnEvent(-3, "_Exit") GUISetBkColor(0xABCDEF) Global $hLV1 = GUICtrlCreateListView("A|B|C", 100, 100, 610, 600, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_TRANSPARENTBKGND)) For $i = 1 To 50 GUICtrlCreateListViewItem("Item: A" & $i, $hLV1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: B" & $i, 1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: C" & $i, 2) Next _GUICtrlListView_SetColumnWidth($hLV1, 0, 200) _GUICtrlListView_SetColumnWidth($hLV1, 1, 200) _GUICtrlListView_SetColumnWidth($hLV1, 2, 200) GUISetState() While True Sleep(1000) WEnd _Exit() Func _Exit() Exit EndFunc Best regards Veronesi Edited July 19, 2012 by veronesi Link to comment Share on other sites More sharing options...
KaFu Posted July 19, 2012 Share Posted July 19, 2012 Strange enough, but it seems that some LV styles can only be applied after creation, otherwise the this is applied to the underlying window too. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("GuiOnEventMode", 1) GUICreate("Test", 1024, 768, -1, -1) GUISetOnEvent(-3, "_Exit") GUISetBkColor(0xABCDEF) ; Global $hLV1 = GUICtrlCreateListView("A|B|C", 100, 100, 610, 600, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_TRANSPARENTBKGND)) ; Const $WS_EX_LAYOUTRTL = 0x400000 ; Global $hLV1 = GUICtrlCreateListView("A|B|C", 100, 100, 610, 600, Default, BitXOR(BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_TRANSPARENTBKGND), $WS_EX_LAYOUTRTL)) Global $hLV1 = GUICtrlCreateListView("A|B|C", 100, 100, 610, 600) _GUICtrlListView_SetExtendedListViewStyle($hLV1, $LVS_EX_TRANSPARENTBKGND) For $i = 1 To 50 GUICtrlCreateListViewItem("Item: A" & $i, $hLV1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: B" & $i, 1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: C" & $i, 2) Next _GUICtrlListView_SetColumnWidth($hLV1, 0, 200) _GUICtrlListView_SetColumnWidth($hLV1, 1, 200) _GUICtrlListView_SetColumnWidth($hLV1, 2, 200) GUISetState() While True Sleep(1000) WEnd _Exit() Func _Exit() Exit EndFunc ;==>_Exit OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
veronesi Posted July 19, 2012 Author Share Posted July 19, 2012 (edited) Hi KaFu Thanks a lot for this "workarround". It's working perfect! But what, when I'd like to change the background color to an background image? Take a look at this code: #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("GuiOnEventMode", 1) GUICreate("Test", 1024, 768, -1, -1) GUISetOnEvent(-3, "_Exit") GUICtrlCreatePic("C:WindowsWebWallpaperWindowsimg0.jpg", 0, 0, 1024, 768) GUICtrlSetState(-1, $GUI_DISABLE) ;~ GUISetBkColor(0xABCDEF) Global $hLV1 = GUICtrlCreateListView("A|B|C", 100, 100, 610, 600) _GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_TRANSPARENTBKGND)) For $i = 1 To 50 GUICtrlCreateListViewItem("Item: A" & $i, $hLV1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: B" & $i, 1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: C" & $i, 2) Next _GUICtrlListView_SetColumnWidth($hLV1, 0, 200) _GUICtrlListView_SetColumnWidth($hLV1, 1, 200) _GUICtrlListView_SetColumnWidth($hLV1, 2, 200) GUISetState() While True Sleep(1000) WEnd _Exit() Func _Exit() Exit EndFunc ;==>_Exit PS: Every time I post here a script, I will lose my formatting or the includes...... Edited July 19, 2012 by veronesi Link to comment Share on other sites More sharing options...
KaFu Posted July 19, 2012 Share Posted July 19, 2012 I've found a reference to this problem here, take a look at the bottom ("Community Additions"), though I did no succeed in implementing a workaround. http://msdn.microsoft.com/en-us/library/windows/desktop/dd145217%28v=vs.85%29.aspx OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
veronesi Posted July 19, 2012 Author Share Posted July 19, 2012 Thanks for the link. Unfortunately I can't get it to work. When I try this, I get some misterious graphic errors #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Opt("GuiOnEventMode", 1) GUICreate("Test", 1024, 768, -1, -1) GUISetOnEvent(-3, "_Exit") GUICtrlCreatePic("C:WindowsWebWallpaperWindowsimg0.jpg", 0, 0, 1024, 768) GUICtrlSetState(-1, $GUI_DISABLE) ;~ GUISetBkColor(0xABCDEF) Global $hLV1 = GUICtrlCreateListView("Column A|Column B|Column C", 100, 100, 610, 600) _GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_TRANSPARENTBKGND, $LVS_EX_FULLROWSELECT)) For $i = 1 To 50 GUICtrlCreateListViewItem("Item: A" & $i, $hLV1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: B" & $i, 1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: C" & $i, 2) Next _GUICtrlListView_SetColumnWidth($hLV1, 0, 200) _GUICtrlListView_SetColumnWidth($hLV1, 1, 200) _GUICtrlListView_SetColumnWidth($hLV1, 2, 189) GUISetState() GUIRegisterMsg($WM_PRINTCLIENT, "WM_PRINTCLIENT") While True Sleep(1000) WEnd _Exit() Func WM_PRINTCLIENT($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local Const $PRF_ERASEBKGND = 0x00000008 If $lParam = $PRF_ERASEBKGND Then Return True Return $GUI_RUNDEFMSG EndFunc ;==>WM_PRINTCLIENT Func _Exit() Exit EndFunc ;==>_Exit Anything else, I can do? Link to comment Share on other sites More sharing options...
UEZ Posted July 19, 2012 Share Posted July 19, 2012 (edited) As another workaround: you can use a 2nd GUI (child GUI) with the listview control and set the 2nd window transparent. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ;~ #include <WindowsConstants.au3>;~~~ Opt("GuiOnEventMode", 1) $hGUI = GUICreate("Test", 1024, 768, -1, -1, Default, $WS_EX_LAYERED) GUICtrlCreatePic("C:WindowsWebWallpaperWindowsimg0.jpg", 0, 0, 1024, 768) GUICtrlSetState(-1, $GUI_DISABLE) Global $hGUI2 = GUICreate("", 1024, 768, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI) Global $iBGColor = 0x909090 GUISetBkColor($iBGColor, $hGUI2) ;~ GUISetBkColor(0xABCDEF) Global $iLV1 = GUICtrlCreateListView("Column A|Column B|Column C", 100, 100, 610, 600) GUICtrlSetBkColor(-1, $iBGColor) Global $hLV1 = GUICtrlGetHandle($iLV1) _GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $LVS_EX_TRANSPARENTBKGND)) For $i = 1 To 50 GUICtrlCreateListViewItem("Item: A" & $i, $iLV1) _GUICtrlListView_AddSubItem($iLV1, $i - 1, "Item: B" & $i, 1) _GUICtrlListView_AddSubItem($iLV1, $i - 1, "Item: C" & $i, 2) Next _GUICtrlListView_SetColumnWidth($iLV1, 0, 200) _GUICtrlListView_SetColumnWidth($iLV1, 1, 200) _GUICtrlListView_SetColumnWidth($iLV1, 2, 189) GUISetState(@SW_SHOW, $hGUI2) GUISetState(@SW_SHOW, $hGUI) _WinAPI_SetLayeredWindowAttributes($hGUI2, $iBGColor) GUISetOnEvent(-3, "_Exit") While True Sleep(1000) WEnd _Exit() Func _Exit() Exit EndFunc ;==>_Exit I personally don't like the 2 GUI solution. Br, UEZ Edited July 19, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
veronesi Posted July 19, 2012 Author Share Posted July 19, 2012 Hi UEZ Thanks for that solution. That's very good (for me) For this project, I use a very bright background and with this it's working! Thank you very much! Kind regards Veronesi Link to comment Share on other sites More sharing options...
veronesi Posted July 19, 2012 Author Share Posted July 19, 2012 Hi UEZ Ok, now I tried an other background image. With this image it's not working perfect. Then I have some graphic errors! What I want to have is a ListView with a background image AND it must be possible to define the color of some rows! I can set the row color. And I can set a background image of a ListView. But when I set the BG Image, then I can't set the row color AT THE SAME TIME! What's wrong? Link to comment Share on other sites More sharing options...
UEZ Posted July 19, 2012 Share Posted July 19, 2012 Is the other image a PNG image? If yes, load it into GDI+ and send it to picture control. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
veronesi Posted July 19, 2012 Author Share Posted July 19, 2012 No, it's also .jpg! Can I set a background image to the ListView AND define the row color? Link to comment Share on other sites More sharing options...
UEZ Posted July 19, 2012 Share Posted July 19, 2012 Here another alternative: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ;~ #include <WindowsConstants.au3>;~~~ Opt("GuiOnEventMode", 1) $iW = 800 $iH = 600 $hGUI = GUICreate("Test", $iW, $iH) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) Global $hLV1 =_GUICtrlListView_Create($hGUI, "Column A|Column B|Column C", 100, 100, $iW - 200, $iH - 200, -1, -1, True) _GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) For $i = 1 To 70 _GUICtrlListView_AddItem($hLV1, "Item: A" & $i) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: B" & $i, 1) _GUICtrlListView_AddSubItem($hLV1, $i - 1, "Item: C" & $i, 2) Next _GUICtrlListView_SetColumnWidth($hLV1, 0, 200) _GUICtrlListView_SetColumnWidth($hLV1, 1, 200) _GUICtrlListView_SetColumnWidth($hLV1, 2, 189) _GUICtrlListView_SetBkImage($hLV1, "C:WindowsWebWallpaperWindowsimg0.jpg") Sleep(250) GUISetState(@SW_SHOW, $hGUI) GUISetOnEvent(-3, "_Exit") While True Sleep(1000) WEnd _Exit() Func _Exit() DllCall('ole32.dll', 'long', 'CoUinitialize') GUIDelete() Exit EndFunc ;==>_Exit Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
veronesi Posted July 20, 2012 Author Share Posted July 20, 2012 (edited) Hi UEZI'm sorry, but yesterday I wrote over my mobile phone, so I could not give some code!What I meant was:I know the command _GUICtrlListView_SetBkImage and I also know the command GUICtrlSetBkColor.What I want to have is a Background Image in the ListView (perhaps with _GUICtrlListView_SetBkImage) AND define the row color with GUICtrlSetBkColor.See attached pictures.In picture 1 I have a ListView with row colors. Thats working. As you can see, I need the row colors, because I have to mark some special software. (License fee applied; paid / not paid; or installed / not installed)In this ListView, I want to have a background picture, with the row color overlaying this picture (with transparency).I tried with _GUICtrlListView_SetBkImage. But then, the GUICtrlSetBkColor doesn't work for setting the row color. (See picture 2)The background picture is just an example! Edited July 20, 2012 by veronesi Link to comment Share on other sites More sharing options...
veronesi Posted July 20, 2012 Author Share Posted July 20, 2012 Here is an example. With this, I have a background image, but no row color. If you disable ONLY the background image (_GUICtrlListView_SetBkImage) then you have row color! But I'd like to have both! #include <GuiListView.au3> Opt("GuiOnEventMode", 1) _GUI1() While True Sleep(1000) WEnd _Exit() Func _GUI1() Local Const $iW = 1024 Local Const $iH = 768 ;The following three lines are needed! Otherwise we don't have an background image in the ListView! ;An other workaround is to use _GUICtrlListView_Create() instead of GUICtrlCreateListView(). ;But then we can't use the GUICtrlCreateListViewItem! And this command is needed, because I want to use the GUICtrlSetBkColor command with the return value of GUICtrlCreateListViewItem! GUICreate("", 0, 0, 0, 0) GUISetState(@SW_SHOW) GUIDelete() Global $hGUI = GUICreate("Test", $iW, $iH, -1, -1) GUISetOnEvent(-3, "_Exit") Local $hLV1 = GUICtrlCreateListView(" - Column A -| - Column B -| - Column C -", 0, 0, $iW, $iH) _GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) _GUICtrlListView_SetBkImage(GUICtrlGetHandle($hLV1), "C:WindowsWebWallpaperWindowsimg0.jpg", 1, 0, 0) For $i = 1 To 70 GUICtrlCreateListViewItem("Item: A" & $i & "|Item: B" & $i & "|Item: C" & $i, $hLV1) GUICtrlSetBkColor(-1, 0xABCDEF) ;============================================> This command doesn't work, when the _GUICtrlListView_SetBkImage is used!!!! => Problem!!!! Next GUISetState(@SW_SHOWNORMAL, $hGUI) EndFunc ;==>_GUI1 Func _Exit() DllCall('ole32.dll', 'long', 'CoUinitialize') Exit EndFunc ;==>_Exit 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