Jump to content

reb
 Share

Go to solution Solved by Melba23,

Recommended Posts

Happy New year to all.

when I run the program without using $LVS_EX_GRIDLINES I get the Index and the subitem values correctly.
when I run the program using $LVS_EX_GRIDLINES I get the Index always = -1 and the subitem values are correct.
What do I need to do to get the correct index and subitem using the gridlines?

right click a sub item to view in Console.
REB
 

#Region - Includes
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#EndRegion - Includes

#Region - Variables
Local $width = @DesktopWidth, $wheight = @DesktopHeight - 30, $COLOR_GUI = 0xFFFFFF, $lvtop = 100, $index, $subitem

#Region -Create GUI
GUICreate("Test WM_NOTIFY()", $width, $wheight - 150, 0, 0) ;@DesktopWidth, @DesktopHeight, 0, 0) ;
GUISetBkColor(0xF0F4F9) ; $COLOR_GUI)
GUISetState()
#EndRegion -Create GUI
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
#Region - Create Listview
$g_idListView = GUICtrlCreateListView("", 0, $lvtop, $width, $wheight - $lvtop - 150, $LVS_REPORT, $LVS_EX_GRIDLINES)
;~ $g_idListView = GUICtrlCreateListView("", 0, $lvtop, $width, $wheight - $lvtop - 50, $LVS_REPORT)

#Region - Add Columns
; Add columns
_GUICtrlListView_InsertColumn($g_idListView, 0, 0, 30)
For $i = 1 To 15 Step 3
    _GUICtrlListView_InsertColumn($g_idListView, $i, "TOTAL = 100", 105 + 31)
    _GUICtrlListView_InsertColumn($g_idListView, $i + 2, "PHASE", 65)
    _GUICtrlListView_InsertColumn($g_idListView, $i + 3, "", 22)
Next
_GUICtrlListView_InsertColumn($g_idListView, $i, "TOTAL =", 105 + 31)
_GUICtrlListView_InsertColumn($g_idListView, $i + 2, "PHASE", 65)
GUICtrlSetFont($g_idListView, 13, 700, Default, "Courier New", 4)
;~ GUICtrlSetState($g_idListView, $GUI_SHOW)
For $i = 1 To 50
    _GUICtrlListView_AddItem($g_idListView, $i, 0)
Next
Local $jump = -2
For $i = 1 To 6
    $jump = $jump + 3
    _GUICtrlListView_SetItem($g_idListView, "     100", 0, $jump)
    _GUICtrlListView_SetItem($g_idListView, 1, 0, $jump + 1)
Next
#EndRegion - Add Columns
#EndRegion - Create Listview
#Region - Loop
Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $idOK
            ExitLoop
    EndSwitch
Until $msg = $GUI_EVENT_CLOSE
#EndRegion - Loop
GUIDelete()
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $index, $subitem
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $index = DllStructGetData($tInfo, "Index") ;& @CRLF & _
                    $subitem = DllStructGetData($tInfo, "SubItem") ;& @CRLF & _
            EndSwitch
            ConsoleWrite("Index = " & $index & @CRLF)
            ConsoleWrite("subitem = " & $subitem & @CRLF)

    EndSwitch
EndFunc   ;==>WM_NOTIFY

MEASURE TWICE - CUT ONCE

Link to comment
Share on other sites

  • Moderators
  • Solution

reb,

You need to add the $LVS_EX_FULLROWSELECT style. And I would strongly suggest using _GUICtrlListView_SetExtendedListViewStyle to set extended styles for ListViews - some of the extended styles are numerically identical to $WS_EX_## styles and will be interpreted as that style if used in the creation line. ;)

This works for me: :)

#Region - Create Listview
$g_idListView = GUICtrlCreateListView("", 0, $lvtop, $width, $wheight - $lvtop - 150, $LVS_REPORT)
_GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
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 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

 

Link to comment
Share on other sites

And I would strongly suggest using _GUICtrlListView_SetExtendedListViewStyle to set extended styles for ListViews - some of the extended styles are numerically identical to $WS_EX_## styles and will be interpreted as that style if used in the creation line. ;)

 

Do you have any examples that show this happening? i've seen this repeated several times, but I've never actually seen this happen for me, so it might be that I'm not using the right combination to make a LV setting affect anything other than the LV.

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

Link to comment
Share on other sites

  • Moderators

BrewManNH,

Rover first pointed it out to me several years ago when we trying to debug a ListView problem - I will see if I can find the thread. :)

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

 

Link to comment
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
 Share

×
×
  • Create New...