Catching MFC exception

Fabian Cenedese Cenedese at
Wed Sep 4 07:27:59 CDT 2002


I found one of the wrong behaviours though I don't know where to solve it. 
For creating an ocx one can give a window title. I gave a "" to the 
CreateControl function. But this poses a problem to MFC, it's only prepared 
for valid strings or NULL pointers. That's why it generates the exception:

void AFXAPI AfxThrowOleException(SCODE sc){
#ifdef _DEBUG
	TRACE1("Warning: constructing COleException, scode = %s.\n",
	COleException* pException = new COleException;
	pException->m_sc = sc;

In Windows this is caught by another function in MFC and doesn't do any harm:

BOOL AFX_CDECL COleControlSite::SafeSetProperty(DISPID dwDispID, VARTYPE 
vtProp, ...) {
	va_list argList;    // really only one arg, but...
	va_start(argList, vtProp);
	BOOL bSuccess;
	TRY {
		SetPropertyV(dwDispID, vtProp, argList);
		bSuccess = TRUE;
	} CATCH_ALL(e) {
		bSuccess = FALSE;
	return bSuccess;

Now it seems that the exception handling inside (or wherever) the MFC.dll 
doesn't work if running in Wine or the MFC exceptions are different and the 
exception comes right through. I can overcome this problem by giving a 
valid window title but that solves it only for me. I have no idea how and 
if this can be solved but maybe this description gives a hint to a 
programmer with more insight.



More information about the wine-devel mailing list