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.

Empfohlene Antworten

Veröffentlicht

Hi Leute....

Ich habe eine Variable m_control vom Typ: CWnd*

je nach programmablauf, kann es nun sein dass sich entweder ein CButton oder ein CListCtrl, oder ein CListBox Objekt darin befindet....

Weiß jemand wie ich per If Abfrage feststellen kann, ob sich in ein objekt vom Typ CListBox darin befindet?

Wär echt super!!!

Danke SwordMaster

Dafür gibt es dynamic_cast:

CListCtrl* list = dynamic_cast<CListCtrl*>(m_control);
Falls m_control kein CListCtrl* ist, bekommst du einen Nullzeiger. Dazu musst du allerdings in den Projekteinstellungen RTTI aktivieren. MFC hat aber auch einen eigenen Mechanismus dafür:
if(m_control->IsKindOf(RUNTIME_CLASS(CListCtrl)))
{
// usw...[/code]

Man kann den Klartext einer Klasse so erhalten (RTTI aktiviert), was allerdings nicht unbedingt beim Herausfinden der Klassentypen hilft, aber zu Debugzwecken sinnvoll sein kann:

#include <typeinfo.h>

	CWnd * pw = new CWnd;

	CListCtrl * pw2 = new CListCtrl;

	CString name;

	name = typeid(pw).name();

	MessageBox(x);

	name = typeid(pw2).name();

	MessageBox(x);

	delete pw;

	delete pw2;

Fehler erzeugen eine Exception vom Typ "bad_typeid"

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.