Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

[MFC] Objekte in einer CComboBox speichern und darstellen

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe folgendes Problem:

Ich hab ein Dialogfenster (MFC) mit einer CComboBox usw.

Jetzt möchte ich, dass beim Start des Dialoges automatisch Objekte aus einer Datei geladen und in der Combobox angezeigt werden.

Ich dachte mir, dass ich die gleich im Konstruktor der Dialogklasse fülle. Das ganze sieht in etwa so aus:


CBZRDlg::CBZRDlg(CWnd* pParent /*=NULL*/)

	: CDialog(CBZRDlg::IDD, pParent)

{

	//{{AFX_DATA_INIT(CBZRDlg)

	//}}AFX_DATA_INIT

	// Beachten Sie, dass LoadIcon unter Win32 keinen nachfolgenden DestroyIcon-Aufruf benötigt

	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	m_pAutoProxy = NULL;

	p_SetFileProperties();

	auto CList<CUser, CUser&> a_oUsers;

	CUser::s_p_GetUsers(a_oUsers);	

	auto CUser a_oUser = a_oUsers.GetTail();

	auto POSITION a_sePosition = a_oUsers.GetTailPosition();

	for (int a_nIndex=0;a_nIndex < a_oUsers.GetCount();a_nIndex++)

	{

		TRACE("FOR: %s\r\n", a_oUser.p_lpGetFName().c_str());

		const char* test = a_oUser.p_lpToString(false).c_str();

		m_oeCtrlMainStiUser.AddString(a_oUser.p_lpToString(false).c_str());

		a_oUser = a_oUsers.GetPrev(a_sePosition);

	}

}

An sich eigentlich nichts besonderes, die Variable m_oeCtrlMainStiUser ist ein Control für die Combobox und soll die Objekte (zu Testzwecken erstmal nur Strings) aus einer CList in die Box eintragen. Leider funktioniert das nicht so wie ich mir das gedacht habe. Beim Programmstart (Konstruktoraufruf) klappt alles reibungslos bis zur Zeile:

m_oeCtrlMainStiUser.AddString(a_oUser.p_lpToString(false).c_str());

Ich bekomme da immer folgende Fehlermeldung:

Debug Assertion Failed

...

File: afxwin2.inl

Line: 735

For Informationen [...] see your C++ documentation on asserts

mein Frage jetzt:

Wie krieg ich da ein Objekt rein ?

btw: VSC++ 6.0

  • Autor

*an Kopf klatsch*

Ich sollte mehr die TODOs von Microsoft lesen...

-> verschoben nach OnInitDialog

Strings hinzufügen klappt jetzt, wie kann ich ganze Objekte dort reinbringen ?

Es müsste dann via Memberfunktion auch die Darstellungsform (der anzuzeigende Text) repräsentierbar sein.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.