Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6000213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:39:41+00:00 2026-05-23T00:39:41+00:00

I am wondering how I can handle an event for a dynamically created variable,

  • 0

I am wondering how I can handle an event for a dynamically created variable, e.g. a list control.

CListCtrl* pList = new CListCtrl();<br/>
pList->Create(...);

How can I handle the event LVN_ITEMCHANGED for pList?

OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult)
{
   //do stuff
}

Do I have to create an extended CListCtrl or is there some other way? I would prefer not creating a extended class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:39:42+00:00Added an answer on May 23, 2026 at 12:39 am

    LVN_ITEMCHANGED is sent through WM_NOTIFY message from control to its parent so you just need to add LVN_ITEMCHANGE handler function in parent’s class (e.g. CMyDlg):

    In header file:

    class CMyDlg : public CDialog
    {
       ...
    protected:
       afx_msg void OnLvnItemChanged(NMHDR *pNMHDR, LRESULT *pResult);
       ...
    }
    

    In source file:

    BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
       ...
       ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, &CMyDlg::OnLvnItemChanged)  
       ...
    END_MESSAGE_MAP()
    
    ...
    
    void CMyDlg::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
    {
       LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); 
       *pResult = 0;
       ... // examine *pNMLV members for item's information
    }
    

    It does not matter how CListCtrl control is created (through resource editor or dynamically), approach is the same. Just make sure you are using correct control ID in ON_NOTIFY message map entry. (ID passed to Create/CreateEx or defined in Properties in resource editor).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering if I can handle a session timeout event. I need to
I was wondering how can I list the user tables name with its primary
I'm new to JQuery and was wondering how can I have Changes saved! displayed
I recently discovered that different browsers handle the onclick event differently when the Control
I'm wondering how to handle an event on NSButton click, I've searched all over
I'm wondering how big of a data can UITableViewController handle... I understand that most
I'm wondering if I can have a individual component in a control have an
I was wondering where I can find some information how IE8 actually handles xml
I was wondering how can I set a timeout on a socket_read call? The
I'm wondering how can I submit a form via Ajax (using prototype framework) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.