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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Event Handling for Dynamically created ListBox

Event Handling for Dynamically created ListBox

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
5 Posts 4 Posters 0 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.
  • C Offline
    C Offline
    chetanjoshi9
    wrote on last edited by
    #1

    Hi, I am createing new ListBox on dialog box at runtime. it's creating fine but I want to handle the events over that. I want to Handle event as ON_LBN_SELCHANGE(IDC_PREVIEW_LIST, OnSelchangeList) in message map. but id IDC_PREVIEW_LIST is passed by me at run time in as CListBox m_PreviewList; m_PreviewList.Create(WS_CHILD|LVS_ICON|WS_VISIBLE|WS_BORDER|LBS_OWNERDRAWFIXED|LBS_MULTICOLUMN, rect, this, IDC_PREVIEW_LIST); and it's not know in messge map. So please guid me how to handle dynamically created window events.

    M K H 3 Replies Last reply
    0
    • C chetanjoshi9

      Hi, I am createing new ListBox on dialog box at runtime. it's creating fine but I want to handle the events over that. I want to Handle event as ON_LBN_SELCHANGE(IDC_PREVIEW_LIST, OnSelchangeList) in message map. but id IDC_PREVIEW_LIST is passed by me at run time in as CListBox m_PreviewList; m_PreviewList.Create(WS_CHILD|LVS_ICON|WS_VISIBLE|WS_BORDER|LBS_OWNERDRAWFIXED|LBS_MULTICOLUMN, rect, this, IDC_PREVIEW_LIST); and it's not know in messge map. So please guid me how to handle dynamically created window events.

      M Offline
      M Offline
      MANISH RASTOGI
      wrote on last edited by
      #2

      See CWnd::OnCommand().

      C 1 Reply Last reply
      0
      • M MANISH RASTOGI

        See CWnd::OnCommand().

        C Offline
        C Offline
        chetanjoshi9
        wrote on last edited by
        #3

        Please can you explain with simple code?

        1 Reply Last reply
        0
        • C chetanjoshi9

          Hi, I am createing new ListBox on dialog box at runtime. it's creating fine but I want to handle the events over that. I want to Handle event as ON_LBN_SELCHANGE(IDC_PREVIEW_LIST, OnSelchangeList) in message map. but id IDC_PREVIEW_LIST is passed by me at run time in as CListBox m_PreviewList; m_PreviewList.Create(WS_CHILD|LVS_ICON|WS_VISIBLE|WS_BORDER|LBS_OWNERDRAWFIXED|LBS_MULTICOLUMN, rect, this, IDC_PREVIEW_LIST); and it's not know in messge map. So please guid me how to handle dynamically created window events.

          K Offline
          K Offline
          Karthik Kalyanasundaram
          wrote on last edited by
          #4

          Handling events of dynamically created controls are not that hard. It should work. Please ensure that IDC_PREVIEW_LIST is #define-d in some header file and included in this source file.

          Do more work Make more mistakes Learn more things

          1 Reply Last reply
          0
          • C chetanjoshi9

            Hi, I am createing new ListBox on dialog box at runtime. it's creating fine but I want to handle the events over that. I want to Handle event as ON_LBN_SELCHANGE(IDC_PREVIEW_LIST, OnSelchangeList) in message map. but id IDC_PREVIEW_LIST is passed by me at run time in as CListBox m_PreviewList; m_PreviewList.Create(WS_CHILD|LVS_ICON|WS_VISIBLE|WS_BORDER|LBS_OWNERDRAWFIXED|LBS_MULTICOLUMN, rect, this, IDC_PREVIEW_LIST); and it's not know in messge map. So please guid me how to handle dynamically created window events.

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            You can declare each event that you need for your dynamic listbox on the message map.

            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