Event Handling for Dynamically created ListBox
-
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.
-
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.
See CWnd::OnCommand().
-
See CWnd::OnCommand().
Please can you explain with simple code?
-
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.
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
-
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.
You can declare each event that you need for your dynamic listbox on the message map.