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

Ich versuche gerade eine AFX-Message, die mir ständig unnötige Exceptions wirft - ist bestimmt kein Fehler drin, ehrlich! - zu übergehen, indem ich sie als nothrow deklariere. Mach ich etwas falsch?

Ich hab schon Verschiedenes probiert, aber alle Exceptions werden normal ausgelöst.


	afx_msg void __declspec(nothrow) OnBnClickedmovealias();

	afx_msg void OnBnClickedmovealias() throw();

	void __declspec(nothrow) Editor::OnBnClickedmovealias()

 	void Editor::OnBnClickedmovealias() throw()

Klappt aber alles irgendwie nicht.

__declspec(nothrow) ist ein Hinweis für den Compiler, dass diese Methode keine Exceptions wirft. Dadurch kann er sich einiges an Code sparen, der sonst für die Überwachung der Lebenszeit bestimmter Objekte benötigt würde. Exceptions unterdrücken kannst Du damit nicht.

Bezüglich throw() in der Deklaration:

Note Microsoft C++ does not support exception-specifications, as described in section 15.4 of the ANSI C++ draft. In addition, it does not support function-try-block described in section 15 of the ANSI C++ draft.

Quelle: MSDN Library Oktober 2001.

Was spricht dagegen, den ganzen Code der Funktion in einen try-catch-Block einzupacken?

  • Autor

Mach ich ja. Trotzdem wird mir immer noch nicht klar, wieso der SetWindowText zu einem Absturz unter NT & W98 führt.


void Editor::OnBnClickedmovealias() 

{

try

{

	CString name("");

	int start=0,end=0;

	m_Orgname.GetSel( start, end );

	if ( start==end || start || end ) 

	{

		m_Orgname.GetWindowText( name );

		if (start<end )	name=name.Mid( start, end-start );

	}

	m_SNRAlias.SetWindowText( name );

	m_Orgname.SetSel( m_Orgname.LineLength(), m_Orgname.LineLength());

}

catch (...) { MessageBox( "Fehler aufgetreten in Editor::OnBnClickedmovealias!" );

}

Interessant ist diese Meldung, wenn ich gewaltsam die Exception auslöse:

"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

Den ESP retten bringt aber auch nichts: Immer noch unsinnige Abstürze.

Ist nur die Frage, welche Calling-Convention von welcher Funktion. Ist doch eine AFX-Message. Also habe ich da persönlich keinen Einfluß drauf.

Schon seltsam, was da vor sich geht. Wenigstens läufts unter XP und 2000 korrekt.

  • Autor

CEdit m_SNRAlias;

eingebunden über

DDX_Control(pDX, IDC_SNRAlias, m_SNRAlias);

SetWindowText sieht so aus:

void CWnd::SetWindowText(LPCTSTR lpszString)

{

ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));

if (m_pCtrlSite == NULL)

::SetWindowText(m_hWnd, lpszString);

else

m_pCtrlSite->SetWindowText(lpszString);

}

Also eigentlich nichts Weltbewegendes.

Naja, ich bemühge im Zweifelsfall noch die Microsoft-Developer-Hotline, hab ja noch 2 Fragen frei =8-)

Wäre nur etwas doof, die für sowas (scheinbar) simples aufzubrauchen.

hmmm. m_pCtrlSite ist 0!

Sollte aber auch nix Schlimmes sein, ist ja nur für OLE-Variablen.

  • Autor

In SetWindowText, allerdings die Stelle konnte ich noch nicht ausloten, weil ich mein .NET auf Win98 nicht installieren kann. Muß mir das alte Studio nochmal holen zum ordentlichen Debuggen.

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.