15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


OLE question

Joao Vargem -- jpv.loyaltech@taguspark.pt
Tuesday, March 25, 1997

Environment:	Windows 95, Visual C++ 4.1

	This one is completly out of my league. Can anyone explain-me whats
happening?
	In an attempt to improve the performance of my application, I decided
to create a User Interface Thread, wich created a dialog to be processed
by that thread. Freing the application while the dialog calculations e
screen updates where made. It all seemed to go smothly until I ran the
program (what a surprise hum?). I create the dialog using
CreateIndirect. In the program main thread, I've had no problems, inside
the Interface thread I get the following errors ( the applications
doesn't crash):

	CoCreateInstance of OLE control {48932A4F-981F-101B-A7FB-4A79242FD97B}
failed.
	>>> Result code: 0x800401f0
	>>> Is the control is properly registered?
	Warning: CreateDlgControls failed during dialog init.
	Warning: Dialog creation failed!

	I'm using a OCX in the dialog, as I said previously in the main process
I've never had any problems. This errors are generated from within the
function ::CreateDialogIndirect.
	I really don't know much about OLE and all the help I could find
doesn't explain anything close enough for me to understand whats
happening. If anyone has an ideia I can't wait to read it. TIA

-- 
				Joao Vargem	(jpv.loyaltech@taguspark.pt)
				LoyalTech Portugal SA
				Oeiras, Portugal



Mike Blaszczak -- mikeblas@nwlink.com
Wednesday, March 26, 1997

[Mini-digest: 8 responses]

At 10:34 3/25/97 -0800, Joao Vargem wrote:
>Environment:	Windows 95, Visual C++ 4.1

>	In an attempt to improve the performance of my application, I decided
>to create a User Interface Thread, wich created a dialog to be processed
>by that thread. 

> [...]

>	>>> Result code: 0x800401f0

>	I really don't know much about OLE and all the help I could find
>doesn't explain anything close enough for me to understand whats
>happening. If anyone has an ideia I can't wait to read it. TIA

The error code 0x800401F0 means "CoInitialize has not been called."  That is,
you've started a new thread and not called CoInitialze() on that thread.
OLE has never heard of your thread before, and is not prepared to work
with it.  If you call CoInitialize() in your subordinate thread as it
starts up, I think you'll enjoy much better results.


.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
       One is too many and a million is not enough.
-----From: "Folbrecht, Paul B" 









You have to initialize COM in every thread that uses it.  Call
AfxOleInit().


______________________________ Reply Separator ____________________________
_____
Subject: OLE question
Author:  jpv.loyaltech@taguspark.pt at JOHNSON_CONTROLS
Date:    3/25/97 10:34 AM







Environment:   Windows 95, Visual C++ 4.1

 This one is completly out of my league. Can anyone explain-me whats
 happening? In an attempt to improve the performance of my application, I
 decided
to create a User Interface Thread, wich created a dialog to be processed
by that thread. Freing the application while the dialog calculations e
screen
updates where made. It all seemed to go smothly until I ran the
program (what a surprise hum?). I create the dialog using
CreateIndirect. In the program main thread, I've had no problems, inside
the Interface thread I get the following errors ( the applications
doesn't crash):

 CoCreateInstance of OLE control {48932A4F-981F-101B-A7FB-4A79242FD97B}
 failed.
 >>> Result code: 0x800401f0
 >>> Is the control is properly registered?
 Warning: CreateDlgControls failed during dialog init.
 Warning: Dialog creation failed!

 I'm using a OCX in the dialog, as I said previously in the main process
I've never had any problems. This errors are generated from within the
function ::CreateDialogIndirect.
 I really don't know much about OLE and all the help I could find
doesn't explain anything close enough for me to understand whats
happening. If anyone has an ideia I can't wait to read it. TIA

--
    Joao Vargem	(jpv.loyaltech@taguspark.pt)
    LoyalTech Portugal SA
    Oeiras, Portugal


-----From: mzinner@berlin.snafu.de

you have to call AfxEnableControlContainer() in your
new thread to enable MFC to use the control in your dialog.

For your main thread, this was done in InitInstance() because
you checked 'Enable Ocx Control support' in appwizard, but
you have to do it again for this other thread.

HTH,
-manfred
-----From: Stephane Larocque 

Did you call OleInitialize(NULL) before CoCreateInstance(...) ?

steph.

-----From: "Doug Brubacher" 

     I've seen it mentioned here several times that OLE needs to be 
     initialized by each thread in your application that requires it (OLE). 
     Try adding AfxEnableControlContainer() or OleInitialize() in your 
     interface thread.
     
     Regards,
     
     Doug Brubacher
     Doug_Brubacher@compuware.com

-----From: Mario Contestabile

>CreateIndirect. In the program main thread, I've had no problems, inside
>the Interface thread I get the following errors ( the applications
>doesn't crash):
>
> CoCreateInstance of OLE control {48932A4F-981F-101B-A7FB-4A79242FD97B}
>failed.
> >>> Result code: 0x800401f0
> >>> Is the control is properly registered?
> Warning: CreateDlgControls failed during dialog init.
> Warning: Dialog creation failed!

AfxOleInit() should be called for every thread.

Mario Contestabile
mcontest@universal.com

-----From: hou@tfn.com (Bing Hou)


The error code 0x800401f0 is defined by OLE as CO_E_NOTINITIALIZED, that 
indicates that your UI thread does not initialize ole, it could certainly 
help.

Bing Hou
hou@tfn.com
------------------------------------------------------------------------
  "Always take a job that is too big for you."




______________________________ Reply Separator _________________________________
Subject: OLE question
Author:  Joao Vargem  at Internet
Date:    3/25/97 10:34 AM


Environment:    Windows 95, Visual C++ 4.1

        This one is completly out of my league. Can anyone explain-me whats
happening?
        In an attempt to improve the performance of my application, I decided
to create a User Interface Thread, wich created a dialog to be processed
by that thread. Freing the application while the dialog calculations e
screen updates where made. It all seemed to go smothly until I ran the
program (what a surprise hum?). I create the dialog using
CreateIndirect. In the program main thread, I've had no problems, inside
the Interface thread I get the following errors ( the applications
doesn't crash):

        CoCreateInstance of OLE control {48932A4F-981F-101B-A7FB-4A79242FD97B}
failed.
        >>> Result code: 0x800401f0
        >>> Is the control is properly registered?
        Warning: CreateDlgControls failed during dialog init.
        Warning: Dialog creation failed!

        I'm using a OCX in the dialog, as I said previously in the main process
I've never had any problems. This errors are generated from within the
function ::CreateDialogIndirect.
        I really don't know much about OLE and all the help I could find
doesn't explain anything close enough for me to understand whats
happening. If anyone has an ideia I can't wait to read it. TIA

-- 
                                Joao Vargem     (jpv.loyaltech@taguspark.pt)
                                LoyalTech Portugal SA
                                Oeiras, Portugal
-----From: David Razzetti 

On Tue, 25 Mar 1997 10:34:51 -0800, you wrote:

Did you remember to initialise the OLE DLLs (CoInitiaize) at the start
of your worker thread ?

>Environment:	Windows 95, Visual C++ 4.1
>
>	This one is completly out of my league. Can anyone explain-me whats
>happening?
>	In an attempt to improve the performance of my application, I decided
>to create a User Interface Thread, wich created a dialog to be processed
>by that thread. Freing the application while the dialog calculations e
>screen updates where made. It all seemed to go smothly until I ran the
>program (what a surprise hum?). I create the dialog using
>CreateIndirect. In the program main thread, I've had no problems, inside
>the Interface thread I get the following errors ( the applications
>doesn't crash):
>
>	CoCreateInstance of OLE control {48932A4F-981F-101B-A7FB-4A79242FD97B}
>failed.
>	>>> Result code: 0x800401f0
>	>>> Is the control is properly registered?
>	Warning: CreateDlgControls failed during dialog init.
>	Warning: Dialog creation failed!
>
>	I'm using a OCX in the dialog, as I said previously in the main process
>I've never had any problems. This errors are generated from within the
>function ::CreateDialogIndirect.
>	I really don't know much about OLE and all the help I could find
>doesn't explain anything close enough for me to understand whats
>happening. If anyone has an ideia I can't wait to read it. TIA
>
>--=20
>				Joao Vargem	(jpv.loyaltech@taguspark.pt)
>				LoyalTech Portugal SA
>				Oeiras, Portugal




Joao Vargem -- jpv.loyaltech@taguspark.pt
Monday, March 31, 1997

Mario Contestabile wrote:
> 
> AfxOleInit() should be called for every thread.
> 
	I can't. It makes sense but the function ASSERTS the second time it's
called:

BOOL AFXAPI AfxOleInit()
{
	_AFX_OLE_STATE* pOleState = _afxOleState;
	ASSERT(!pOleState->m_bNeedTerm);    // calling it twice? <- the
functions ASSERTS here,
								can it be an implementation flaw?
	(...)
	// termination required when OleInitialize does not fail
	pOleState->m_bNeedTerm = TRUE;
	(...)
}

	However, calling OleInit, the error I mensioned disapears and starts
happening another:

        InitNew or Load on OLE control
{48932A4F-981F-101B-A7FB-4A79242FD97B} failed.
        >>> Result code: 0x8000ffff 
        Warning: CreateDlgControls failed during dialog init.
        Warning: Dialog creation failed!

	I managed to find that 0x8000ffff == E_UNEXPECTED. But unexpected
doesn't help-me much.
	Thanks for all the answers.

-- 
				Joao Vargem	(jpv.loyaltech@taguspark.pt)
				LoyalTech Portugal SA
				Oeiras, Portugal



Kenneth A. Argo -- argo@rias.COM
Tuesday, April 01, 1997

You can call this:

	// Initialize OLE libraries, needs to be executed in each thread using OLE
	if (FAILED(::OleInitialize(NULL)))
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FAILED;
	}


Ken

-----Original Message-----
From:	Joao Vargem [SMTP:jpv.loyaltech@taguspark.pt]
Sent:	Monday, March 31, 1997 8:51 PM
To:	MFC Mailing List
Subject:	Re: OLE question

Mario Contestabile wrote:
> 
> AfxOleInit() should be called for every thread.
> 
	I can't. It makes sense but the function ASSERTS the second time it's
called:

BOOL AFXAPI AfxOleInit()
{
	_AFX_OLE_STATE* pOleState = _afxOleState;
	ASSERT(!pOleState->m_bNeedTerm);    // calling it twice? <- the
functions ASSERTS here,
								can it be an implementation flaw?
	(...)
	// termination required when OleInitialize does not fail
	pOleState->m_bNeedTerm = TRUE;
	(...)
}

	However, calling OleInit, the error I mensioned disapears and starts
happening another:

        InitNew or Load on OLE control
{48932A4F-981F-101B-A7FB-4A79242FD97B} failed.
        >>> Result code: 0x8000ffff 
        Warning: CreateDlgControls failed during dialog init.
        Warning: Dialog creation failed!

	I managed to find that 0x8000ffff == E_UNEXPECTED. But unexpected
doesn't help-me much.
	Thanks for all the answers.

-- 
				Joao Vargem	(jpv.loyaltech@taguspark.pt)
				LoyalTech Portugal SA
				Oeiras, Portugal





Become an MFC-L member | Вернуться в корень Архива |