Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/07/2021 in all areas

  1. @Nine and @pixelsearch, You really came up with perfect solution while I was asleep. Once again you made me realize this world is worth living. Thank you. Below is my revised code. In fact I used this logic in my zPlayer and I'll have to reflect your solution in my next update. #include <GUIConstants.au3> #include <EditConstants.au3> #include <GuiListView.au3> Local $idListview, $idLabel, $idInput Local $iViewHeight= 237, $iItemCount = 100, $iItemToSelect Local $mainGUI = GUICreate("ListView Scroll", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, $iViewHeight) $idLabel = GUICtrlCreateLabel("Input a number between 1 and " & $iItemCount & " and press Enter:", 20, 260, 300, 20) $idInput = GUICtrlCreateInput("", 325, 256, 30, 18, $ES_CENTER + $ES_NUMBER) GUICtrlSetState($idInput, $GUI_FOCUS) GUISetState(@SW_SHOW) _GUICtrlListView_AddColumn($idListview, "Items", 100) For $iI = 1 To 5000 _GUICtrlListView_AddItem($idListview, "Item " & $iI) Next $iItemCount = _GUICtrlListView_GetItemCount($idListview) GUICtrlSetData($idLabel, "Input a number between 1 and " & $iItemCount & " and press Enter:") Local $aItemRect = _GUICtrlListView_GetItemRect($idListview, 0, 0) Local $iItemHeight = $aItemRect[3] - $aItemRect[1] Local $hHeader = _GUICtrlListView_GetHeader($idListView) Local $iHeaderHeight = _WinAPI_GetWindowHeight($hHeader) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idInput $iItemToSelect = GUICtrlRead($idInput) If $iItemToSelect > 0 And $iItemToSelect <= $iItemCount Then _Scroll() GUICtrlSetState($idListview, $GUI_FOCUS) Else MsgBox(0, "Listview Scroll", "The item number entered is invalid.") GUICtrlSetState($idInput, $GUI_FOCUS) EndIf EndSwitch WEnd GUIDelete() Func _Scroll() ; Scroll $iItemToSelect to the center of listview window _GUICtrlListView_SetItemSelected($idListview, $iItemToSelect-1, True, True) _GUICtrlListView_Scroll($idListview, 0, $iItemCount*-$iItemHeight) _GUICtrlListView_Scroll($idListview, 0, ($iItemToSelect-($iViewHeight-$iHeaderHeight)/$iItemHeight/2)*$iItemHeight) EndFunc
    1 point
  2. What would also be great would be if you could include any of the ConsoleWrite statements generated by the code. To see these you need to compile with the /console option or add the line #pragma compile(Console, True) to the top of the code.
    1 point
  3. Why I just tried it i dont want to insult u
    1 point
  4. Actually you could calculate the line width and the header height. It would make your script independent of OS, styles, theme and Region. #include <WinAPISysWin.au3> #include <WinAPIConv.au3> Example() Func Example() Local $hWnd = GUICreate("test") Local $iHeight = _WinAPI_GetClientHeight($hWnd) Local $iWidth = _WinAPI_GetClientWidth($hWnd) Local $tRECT = _WinAPI_GetWindowRect($hWnd) Local $tPoint1 = DllStructCreate($tagPOINT) $tPoint1.X = 0 $tPoint1.Y = 0 _WinAPI_ClientToScreen($hWnd, $tPoint1) Local $tPoint2 = DllStructCreate($tagPOINT) $tPoint2.X = $iWidth $tPoint2.Y = $iHeight _WinAPI_ClientToScreen($hWnd, $tPoint2) ConsoleWrite("Actual " & $tRECT.left & "/" & $tRECT.top & "/" & $tRECT.right & "/" & $tRECT.bottom & @CRLF) ConsoleWrite("Client " & $tPoint1.X & "/" & $tPoint1.Y & "/" & $tPoint2.X & "/" & $tPoint2.Y & @CRLF) EndFunc ;==>Example
    1 point
×
×
  • Create New...