How to insert data into ListBox(Something Different)
-
Hi All, I am using Win32 Application. In that I have created resource as Dialog and also in this Dialog I have added onr ListBox control. Now I want to insert data in to this Dialog. In this I have added one C++ class in which I am using like below to open Dialog.....
void CCurrentWnd::Open() { DialogBoxParam(hAppInstance,MAKEINTRESOURCE(IDD_CURWND),NULL,(DLGPROC)CurrntWndDlgProc,(LONG)this); }
As shown in above code my CurrentDlgProc is shown as below....BOOL CCurrentWnd::CurrntWndDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CCurrentWnd * _this = (CCurrentWnd *)GetWindowLong(hwnd,GWL_USERDATA); switch(uMsg) { case WM_INITDIALOG: { HWND m_list1; m_list1 = GetDlgItem(hwnd,IDC_WNDLIST); //Now here I got the handle of the ListBox // Now How to insert data in //this ListBox from here within this class. } //Any code } }
Here IDC_WNDLIST is the ID of the ListBox control. Is there any method for ListBox control as in Tab control like TabCtrl_InsertItem().? If you know any other alternative then plz reply me. Thanks in Advance.Ashish Bhatt
-
Hi All, I am using Win32 Application. In that I have created resource as Dialog and also in this Dialog I have added onr ListBox control. Now I want to insert data in to this Dialog. In this I have added one C++ class in which I am using like below to open Dialog.....
void CCurrentWnd::Open() { DialogBoxParam(hAppInstance,MAKEINTRESOURCE(IDD_CURWND),NULL,(DLGPROC)CurrntWndDlgProc,(LONG)this); }
As shown in above code my CurrentDlgProc is shown as below....BOOL CCurrentWnd::CurrntWndDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CCurrentWnd * _this = (CCurrentWnd *)GetWindowLong(hwnd,GWL_USERDATA); switch(uMsg) { case WM_INITDIALOG: { HWND m_list1; m_list1 = GetDlgItem(hwnd,IDC_WNDLIST); //Now here I got the handle of the ListBox // Now How to insert data in //this ListBox from here within this class. } //Any code } }
Here IDC_WNDLIST is the ID of the ListBox control. Is there any method for ListBox control as in Tab control like TabCtrl_InsertItem().? If you know any other alternative then plz reply me. Thanks in Advance.Ashish Bhatt
You can use of these messages
LB_ADDSTRING
orLB_INSERTSTRING
. -
You can use of these messages
LB_ADDSTRING
orLB_INSERTSTRING
.Ya You are absolutely right. Using these messages I can add String to ListBox. But my problem is that how to insert string in to ListBox??
Ashish Bhatt
-
Ya You are absolutely right. Using these messages I can add String to ListBox. But my problem is that how to insert string in to ListBox??
Ashish Bhatt
Sorry, I tried as you told and I got the solution. If I will get some problem then I will contact you. Thank you very much.
Ashish Bhatt
-
You can use of these messages
LB_ADDSTRING
orLB_INSERTSTRING
.Hi,, I got little much problem with same.I am using SendMessage() function to set the value for the ListBox using LB_ADDSTRING message. But I got not perfect value as pass here in the parameter lParam of Sendmessage() function. I am passing such like this.
char *str ="Desktop"; SendMessage(m_list1,LB_ADDSTRING,NULL,(LPARAM)(str));
And I got undefined value in listbox like square rectangles. If you have any other way to pass then tell me. Thanks.Ashish Bhatt
-
Hi,, I got little much problem with same.I am using SendMessage() function to set the value for the ListBox using LB_ADDSTRING message. But I got not perfect value as pass here in the parameter lParam of Sendmessage() function. I am passing such like this.
char *str ="Desktop"; SendMessage(m_list1,LB_ADDSTRING,NULL,(LPARAM)(str));
And I got undefined value in listbox like square rectangles. If you have any other way to pass then tell me. Thanks.Ashish Bhatt
TCHAR str[120] =_T("Desktop"); ::SendMessage(GetDlgItem(IDC_LIST1)->m_hWnd,LB_ADDSTRING,0,(LPARAM)(str));