Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. LVN_ITEMCHANGED - CListCtrl

LVN_ITEMCHANGED - CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelp
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sankar
    wrote on last edited by
    #1

    I have a Dialog Box "AAA" which consists of a command button ( let's say "DISPLAY" ). On clicking this button another dialog box "BBB" is displayed which consists of a CListctrl among others. Now, I wanted to catch a notification when ever the item is changed. So, I implemented the OnNotify (LVN_ITEMCHANGED,IDC_LISTCTRL, FnHandler) like this : void CClass :: OnItemCHanged(NMHDR* pNMHDR, LRESULT* pResult ) { NM_LISTVIEW* pNMListView = ( NM_LISTVIEW)pNMHDR; int len = 0; LPTSTR str; myListCtrl.GetItemText(pNMListView ->iItem, 2, str, len) *pResult = 0; } Now, Coming to my doubt, when i try to debug with the break point inside this function, I observe that it breaks when I click the button DISPLAY. why's this when I haven't changed the state of the item yet, also, the application crashes saying "User BreakPoint Exception" after teh GetItemText call. I do see an error saying that " HEAP ALLOCATION EXCEEDED". what's wrong in the whole issue. PL. explain. regards Sankar

    M 2 Replies Last reply
    0
    • S sankar

      I have a Dialog Box "AAA" which consists of a command button ( let's say "DISPLAY" ). On clicking this button another dialog box "BBB" is displayed which consists of a CListctrl among others. Now, I wanted to catch a notification when ever the item is changed. So, I implemented the OnNotify (LVN_ITEMCHANGED,IDC_LISTCTRL, FnHandler) like this : void CClass :: OnItemCHanged(NMHDR* pNMHDR, LRESULT* pResult ) { NM_LISTVIEW* pNMListView = ( NM_LISTVIEW)pNMHDR; int len = 0; LPTSTR str; myListCtrl.GetItemText(pNMListView ->iItem, 2, str, len) *pResult = 0; } Now, Coming to my doubt, when i try to debug with the break point inside this function, I observe that it breaks when I click the button DISPLAY. why's this when I haven't changed the state of the item yet, also, the application crashes saying "User BreakPoint Exception" after teh GetItemText call. I do see an error saying that " HEAP ALLOCATION EXCEEDED". what's wrong in the whole issue. PL. explain. regards Sankar

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Your bug is that you don't allocate any space to hold the text. You pass an uninitialized pointer (str). And you give the buffer length as 0. --Mike-- http://home.inreach.com/mdunn/ #include "buffy_sig"

      1 Reply Last reply
      0
      • S sankar

        I have a Dialog Box "AAA" which consists of a command button ( let's say "DISPLAY" ). On clicking this button another dialog box "BBB" is displayed which consists of a CListctrl among others. Now, I wanted to catch a notification when ever the item is changed. So, I implemented the OnNotify (LVN_ITEMCHANGED,IDC_LISTCTRL, FnHandler) like this : void CClass :: OnItemCHanged(NMHDR* pNMHDR, LRESULT* pResult ) { NM_LISTVIEW* pNMListView = ( NM_LISTVIEW)pNMHDR; int len = 0; LPTSTR str; myListCtrl.GetItemText(pNMListView ->iItem, 2, str, len) *pResult = 0; } Now, Coming to my doubt, when i try to debug with the break point inside this function, I observe that it breaks when I click the button DISPLAY. why's this when I haven't changed the state of the item yet, also, the application crashes saying "User BreakPoint Exception" after teh GetItemText call. I do see an error saying that " HEAP ALLOCATION EXCEEDED". what's wrong in the whole issue. PL. explain. regards Sankar

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        when i try to debug with the break point inside this function, I observe that it breaks when I click the button DISPLAY. LVN_ITEMCHANGED gets sent whenever any property of an item changes, including when an item is added/deleted to/from the list. If you want to act only when the selection changes, compare the old and new states of the item (which are sent with the message) and act only if their LVIS_SELECTED bits are opposite. --Mike-- http://home.inreach.com/mdunn/ #include "buffy_sig"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups