AlienStar Posted November 22, 2020 Share Posted November 22, 2020 (edited) hello everybody I need to set a pic to be shown on a listview I've set the pic after the listview but the listview is still ontop and the pic is at the back $listview_st = GUICtrlCreateListView("#|sections", 200, 54, 585, 243) GUICtrlCreatePic("head_main.jpg",200, 54,579,25) please help Edited November 22, 2020 by AlienStar Link to comment Share on other sites More sharing options...
pixelsearch Posted November 22, 2020 Share Posted November 22, 2020 Hi Alienstar, This should do it, covering your listview headers by the pic (tested) $listview_st = GUICtrlCreateListView("#|sections", 200, 54, 585, 243) $idPic = GUICtrlCreatePic("head_main.jpg",200, 54,579,25) GuiCtrlSetState($idPic, $GUI_ONTOP) Link to comment Share on other sites More sharing options...
AlienStar Posted November 22, 2020 Author Share Posted November 22, 2020 5 minutes ago, pixelsearch said: Hi Alienstar, This should do it, covering your listview headers by the pic (tested) $listview_st = GUICtrlCreateListView("#|sections", 200, 54, 585, 243) $idPic = GUICtrlCreatePic("head_main.jpg",200, 54,579,25) GuiCtrlSetState($idPic, $GUI_ONTOP) not works Link to comment Share on other sites More sharing options...
pixelsearch Posted November 22, 2020 Share Posted November 22, 2020 (edited) Strange... this script works for me, pic "head_main.jpg" provided below #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 620, 290) $listview_st = GUICtrlCreateListView("#|sections", 20, 20, 579, 243) $idPic = GUICtrlCreatePic("head_main.jpg",20, 20,579,25) GuiCtrlSetState($idPic, $GUI_ONTOP) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) downloadable pic below, to be renamed "head_main.jpg" Edited November 22, 2020 by pixelsearch Link to comment Share on other sites More sharing options...
AlienStar Posted November 22, 2020 Author Share Posted November 22, 2020 also I don't know why ! I changed both horizontally to show the arrangement and here is the result Link to comment Share on other sites More sharing options...
pixelsearch Posted November 22, 2020 Share Posted November 22, 2020 So I guess we need a couple of readers to tell us if it works on their computer or not, let's wait a bit... Thanks guys for testing the script and please tell us the results Link to comment Share on other sites More sharing options...
Nine Posted November 22, 2020 Share Posted November 22, 2020 Does not work for me either. Need to investigate, but not tonight “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted November 22, 2020 Share Posted November 22, 2020 Thanks Nine, going to sleep right now as I have to wake up very early Link to comment Share on other sites More sharing options...
Musashi Posted November 22, 2020 Share Posted November 22, 2020 It does not work for me either. I have added a colored .jpg (a bit shifted) so it can be better visualized. Win7 Pro SP1 64 / AutoIt 3.3.12.0 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
AlienStar Posted November 22, 2020 Author Share Posted November 22, 2020 really strange!!! Link to comment Share on other sites More sharing options...
pixelsearch Posted November 23, 2020 Share Posted November 23, 2020 (edited) Does this other way of doing it satisfy your needs ? (Main GUI is less high in this script, so the resulting pic takes less place when displayed below) Also, what should happen when the user clicks on the "now-hidden" listview header ? #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 620, 140) $listview_st = GUICtrlCreateListView("#|sections", 30, 20, 579, 93) ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($listview_st))) ; Melba23's way GUICtrlCreateListViewItem("1|100", $listview_st) GUICtrlCreateListViewItem("2|200", $listview_st) $hGUI_Child = GUICreate("", 579, 25, 30, 20, $WS_CHILD, -1, $hGUI) $idPic = GUICtrlCreatePic("head_main.jpg", 0, 0, 579, 25) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Child) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI_Child) GUIDelete($hGUI) Edited November 23, 2020 by pixelsearch typo AlienStar and Musashi 1 1 Link to comment Share on other sites More sharing options...
Musashi Posted November 23, 2020 Share Posted November 23, 2020 This works ! The functionality of the "now-hidden" listview header is preserved. In case the graphic extends into the area of the list view items, it will be overwritten by clicked fields. I do not know the intention of the OP, but for me this is ok (and is also logic). Otherwise this area would be deprived of its meaning. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
AlienStar Posted November 23, 2020 Author Share Posted November 23, 2020 2 hours ago, pixelsearch said: Does this other way of doing it satisfy your needs ? (Main GUI is less high in this script, so the resulting pic takes less place when displayed below) Also, what should happen when the user clicks on the "now-hidden" listview header ? #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 620, 140) $listview_st = GUICtrlCreateListView("#|sections", 30, 20, 579, 93) ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($listview_st))) ; Melba23's way GUICtrlCreateListViewItem("1|100", $listview_st) GUICtrlCreateListViewItem("2|200", $listview_st) $hGUI_Child = GUICreate("", 579, 25, 30, 20, $WS_CHILD, -1, $hGUI) $idPic = GUICtrlCreatePic("head_main.jpg", 0, 0, 579, 25) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Child) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI_Child) GUIDelete($hGUI) thanks so much my friend it works Link to comment Share on other sites More sharing options...
mikell Posted November 23, 2020 Share Posted November 23, 2020 If the final purpose is to make some kind of custom header, you might also have a look to these master scripts by LarsJ - particularly the "Custom drawn\Icons and bitmaps.au3" part https://www.autoitscript.com/forum/topic/178680-customowner-drawn-multi-line-header-in-listview/?tab=comments#comment-1282279 AlienStar 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted November 23, 2020 Share Posted November 23, 2020 @AlienStar & Musashi : glad the 2nd way worked for you As you can see in the pic of my precedent post (zoomed below) the green selection of 1st row overlaps just a bit above the pic. To avoid this, may I suggest to retrieve the exact height of the listview header with this kind of line in the script : $iHeaderHeight = _WinAPI_GetWindowHeight($hHeader) Now that we got the exact height in the variable $iHeaderHeight, it's easy to use this variable as the height of the child gui and as the height of the pic, leading us to : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 620, 140) $listview_st = GUICtrlCreateListView("#|sections", 30, 20, 579, 93) GUICtrlCreateListViewItem("1|100", $listview_st) GUICtrlCreateListViewItem("2|200", $listview_st) $hHeader = _GUICtrlListView_GetHeader($listview_st) $iHeaderHeight = _WinAPI_GetWindowHeight($hHeader) ; ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($listview_st))) ; Melba23's way. ControlDisable($hGUI, "", $hHeader) ; seems ok without HWnd($hHeader) as in line before ? $hGUI_Child = GUICreate("", 579, $iHeaderHeight, 30, 20, $WS_CHILD, -1, $hGUI) $idPic = GUICtrlCreatePic("head_main.jpg", 0, 0, 579, $iHeaderHeight) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Child) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI_Child) GUIDelete($hGUI) No more overlap : AlienStar 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted November 26, 2020 Share Posted November 26, 2020 (edited) Hi AlienStar Sooner or later, you will need to resize your GUI, maximize it, restore it etc... When this day comes, you won't be able to do it with the script above because the pic won't cover the listview headers anymore (tested right now), also style $WS_CHILD will then create some display issues after the parent GUI is resized. To prevent this, here is an amended script taking care of a resizable / maximizable parent GUI. It requires : * A child window created with $WS_POPUP style and $WS_EX_MDICHILD extended style. * A pic control which resizes and repositions itself according to any new child window size. * Message WM_SIZE needs to be registered. * Events $GUI_EVENT_MAXIMIZE and $GUI_EVENT_RESTORE are added inside the While... Wend loop. Thanks to Melba23 & Nine for some ideas in the script and I hope it will work for you. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> ;====================== $hGUI = GUICreate("Test", 620, 140, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) $idListView = GUICtrlCreateListView("#|sections", 30, 20, 579, 93) $hListView = GUICtrlGetHandle($idListView) $hHeader = _GUICtrlListView_GetHeader($idListView) $iHeaderHeight = _WinAPI_GetWindowHeight($hHeader) ; ControlDisable($hGUI, "", $hHeader) For $i = 1 To 20 GUICtrlCreateListViewItem($i & "|" & $i*100, $idListView) Next ;====================== $hGUI_Child = GUICreate("", 579, $iHeaderHeight, 30, 20, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $idPic = GUICtrlCreatePic("head_main.jpg", 0, 0, 579, $iHeaderHeight) GUICtrlSetResizing($idPic, $GUI_DOCKAUTO) ; +++ ; GUICtrlSetState($idPic, $GUI_DISABLE) _Resize() ; prevent pic from overlapping above an eventual vertical scrollbar arrow GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Child) GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE _Resize() Case $idPic ConsoleWrite("Pic clicked" & @lf) ; GUISetState(@SW_HIDE, $hGUI_Child) ; Sleep(1000) ; GUISetState(@SW_SHOW, $hGUI_Child) EndSwitch WEnd GUIDelete($hGUI) GUIDelete($hGUI_Child) ;============================================ Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd = $hGUI Then _Resize() EndIf EndFunc ;============================================ Func _Resize() Local $aTag = _WinAPI_GetWindowRect($hHeader) Local $Left = DllStructGetData($aTag, "Left"), _ $Top = DllStructGetData($aTag, "Top"), _ $Right = DllStructGetData($aTag, "Right"), _ $Bottom = DllStructGetData($aTag, "Bottom") ; WinMove($hGUI_Child, "", $Left, $Top, $Right - $Left, $Bottom - $Top) ; a more precise way (pic won't overlap above an eventual vertical scrollbar arrow) Local $aLVPos = WinGetPos($hListView) ; including eventual scrollbars Local $aClientSize = WinGetClientSize($hListView) ; excluding eventual scrollbars WinMove($hGUI_Child, "", $Left, $Top, _ $Right - $Left - ($aLVPos[2] - $aClientSize[0] - 4), _ $Bottom - $Top) EndFunc Edited November 26, 2020 by pixelsearch prevent pic from overlapping above an eventual vertical scrollbar arrow AlienStar 1 Link to comment Share on other sites More sharing options...
AlienStar Posted November 26, 2020 Author Share Posted November 26, 2020 7 hours ago, pixelsearch said: Hi AlienStar Sooner or later, you will need to resize your GUI, maximize it, restore it etc... When this day comes, you won't be able to do it with the script above because the pic won't cover the listview headers anymore (tested right now), also style $WS_CHILD will then create some display issues after the parent GUI is resized. To prevent this, here is an amended script taking care of a resizable / maximizable parent GUI. It requires : * A child window created with $WS_POPUP style and $WS_EX_MDICHILD extended style. * A pic control which resizes and repositions itself according to any new child window size. * Message WM_SIZE needs to be registered. * Events $GUI_EVENT_MAXIMIZE and $GUI_EVENT_RESTORE are added inside the While... Wend loop. Thanks to Melba23 & Nine for some ideas in the script and I hope it will work for you. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> ;====================== $hGUI = GUICreate("Test", 620, 140, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) $idListView = GUICtrlCreateListView("#|sections", 30, 20, 579, 93) $hListView = GUICtrlGetHandle($idListView) $hHeader = _GUICtrlListView_GetHeader($idListView) $iHeaderHeight = _WinAPI_GetWindowHeight($hHeader) ; ControlDisable($hGUI, "", $hHeader) For $i = 1 To 20 GUICtrlCreateListViewItem($i & "|" & $i*100, $idListView) Next ;====================== $hGUI_Child = GUICreate("", 579, $iHeaderHeight, 30, 20, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $idPic = GUICtrlCreatePic("head_main.jpg", 0, 0, 579, $iHeaderHeight) GUICtrlSetResizing($idPic, $GUI_DOCKAUTO) ; +++ ; GUICtrlSetState($idPic, $GUI_DISABLE) _Resize() ; prevent pic from overlapping above an eventual vertical scrollbar arrow GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Child) GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE _Resize() Case $idPic ConsoleWrite("Pic clicked" & @lf) ; GUISetState(@SW_HIDE, $hGUI_Child) ; Sleep(1000) ; GUISetState(@SW_SHOW, $hGUI_Child) EndSwitch WEnd GUIDelete($hGUI) GUIDelete($hGUI_Child) ;============================================ Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd = $hGUI Then _Resize() EndIf EndFunc ;============================================ Func _Resize() Local $aTag = _WinAPI_GetWindowRect($hHeader) Local $Left = DllStructGetData($aTag, "Left"), _ $Top = DllStructGetData($aTag, "Top"), _ $Right = DllStructGetData($aTag, "Right"), _ $Bottom = DllStructGetData($aTag, "Bottom") ; WinMove($hGUI_Child, "", $Left, $Top, $Right - $Left, $Bottom - $Top) ; a more precise way (pic won't overlap above an eventual vertical scrollbar arrow) Local $aLVPos = WinGetPos($hListView) ; including eventual scrollbars Local $aClientSize = WinGetClientSize($hListView) ; excluding eventual scrollbars WinMove($hGUI_Child, "", $Left, $Top, _ $Right - $Left - ($aLVPos[2] - $aClientSize[0] - 4), _ $Bottom - $Top) EndFunc you are so amazing my friend thanks so much 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