Announcement

Collapse
No announcement yet.

Listview selections

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Listview selections

    I'm trying to change a view window everytime a listview changes selections. I noticed there is no equivalent to "lbn_selchange", so I'm just trying t trap every event that would move the highlight bar in the listview:

    Code:
           case %wm_notify
    
             dim nmhp as nmhdr ptr
             dim lpnmk as nmkey ptr
    
    
             select case lowrd(wparam&)
               case 101  ''listview
                 nmhp=lparam&
    
                 select case @nmhp.code
                   case %lvn_columnclick
                     ''column header click
                   case %nm_dblclk
                     ''double click
                     postmessage hwnd&,%wm_command,%idok,0
                   case %nm_click
                     gosub switchasbpics
                   case %nm_keydown
                     lpnmk=lparam&
    
                     select case @lpnmk.nvkey
                       case %vk_up,%vk_down,%vk_prior,%vk_next,%vk_home, _
                            %vk_end
                         gosub switchasbpics
                     end select
    
                 end select
    
             end select
    This is working for clicks on the listview, but not on the up/down/pageup/pagedown/home/end keys when they are pressed!
    Any ideas??
    Jim Seekamp

  • #2
    %LVN_ITEMCHANGED ?

    regards, Ian
    :) IRC :)

    Comment


    • #3
      LOL
      OK - now I feel like an IDIOT!!

      (why didn't I find that one???)

      Thanks Ian.
      Case closed.
      Jim Seekamp

      Comment


      • #4
        Remember, you do not have to "do your thing" every time you get a WM_NOTIFY/LVN_ITEMCHANGED notification; you can isolate changes to the selected state....

        Code:
        'Listview Handler UDT
        UNION LvUnion
           NMHDR  AS NMHDR
           NMLV   AS NMLISTVIEW
           NMIA   AS NMITEMACTIVATE
           LVDI   AS LV_DISPINFO
           LVCD   AS NMLVCUSTOMDRAW
           NMTTDI AS NMTTDISPINFO
        END UNION
        
        
             CASE %WM_NOTIFY
                        ' Always use idFrom not LOWRD(wparam)
                         plvu = lparam
                        ' Ctl = @plVU.nmhdr.idfrom
                         SELECT CASE AS LONG @plvu.nmhdr.idfrom
                           CASE %IDPM_LV
                                SELECT CASE AS LONG @plVU.nmhdr.code
        
                                   CASE %LVN_ITEMCHANGED
                                           IF ISTRUE (@plvu.NMLV.uCHANGED AND %LVIS_SELECTED) THEN 
        
                                                The selected state of the item has changed.. it may be 
                                                now selected or now not selected, but it has changed
                                         
                                          IF ISTRUE (@plvu.NMLV.uNewState AND %LVIS_SELECTED) THEN
                                               The item's state is selected 
                                          ELSE
                                               the item's state is NOT selected
                                          ........
        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          This is working for clicks on the listview, but not on the up/down/pageup/pagedown/home/end keys when they are pressed!
          Any ideas??
          FWIW, I know I handled those keys in a listview in this demo:

          Simple Report Viewer Using Listview Control November 23, 2002; updated 5/30/05 to 'greenbar' file viewer

          UPDATE

          I just looked at that, and it was yet another post of mine which got cheesed up during the forum software conversion. YECHH!

          So... I reposted the code as a reply (at post #5). I sent a note to the webmaster to remove the "code" (if you want to call it that) from post #2, so hopefully that will be gone at some near point in the future.


          MCM
          Last edited by Michael Mattias; 14 Mar 2008, 03:17 PM. Reason: Add updated post info
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X