Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Remove listbox content Visual C++ ???

Featured Replies

Posted

Remove listbox content Visual C++ ???
I wanna remove all items from listbox,

Already tried ResetContent but it doesn't work:

        CWnd *pWnd = GetDlgItem(IDC_LIST1);
        CListBox* listbox = static_cast<CListBox*>(pWnd); //dynamic_cast does not work
        listbox->ResetContent();

 

If you are using MFC you don't use GetDlgItem API, you use the parent dialog as the owner to get its child with its sub-call for GetDlgItem, such as:

CListBox* pListBox = pDialog->GetDlgItem(IDC_LIST1);

Where pDialog is the pointer to your dialog object.

  • Author

@atom0s: GetDlgItem returns 'class CWnd *' or HWND
and not CListBox*,
so your code is wrong and won't work.

The first part code works ok, the listbox->ResetContent(); is the one which doesn't make what I want!
 

  • Author

Found a solution, is not very elegant but it works:
 

    CWnd *pWnd = GetDlgItem(IDC_LIST1);
	CListCtrl* clist = static_cast<CListCtrl*>(pWnd);
	// CListCtrl* clist = (CListCtrl*)(pWnd);

	int numOfItems = clist->GetItemCount();

	for (int i = numOfItems - 1; i >= 0; i--)
	clist->DeleteItem(i);

 

You're not using GetDlgItem the way I mentioned which is why you think its wrong.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.