|
FORUM MESSAGE
|
|
You are reading a General forum message.
Possible Solution for TDx_Draw::Create Problem
Author: Jeff Young
Date Posted: 2004-03-09 08:38:11
My computer (running Windows 2000 and BCB6) seems to be one of the ones afflicted with the TDx_Draw::Create problem that is discussed in FAQ and elsewhere in this forum. I tried messing around with the component source a bit and I believe I may have found a workaround.
I tried compiling Example 1and immediately hit the bug when the line Dx_Draw1->Create(NULL); is executed. After trying with some other example programs and thrashing around a bit, I tried modifying the component source in TDx_Draw.cpp with some alternate methods of creating and initializing the DirectDraw interface. The apporach that works is as follows:
In TDx_Draw.CPP in the function TDx_Draw::Create replace:
fErrorValue = DirectDrawCreateEx( pGuid, (LPVOID*) &fLPDIRECTDRAW7;, IID_IDirectDraw7, NULL);
with
CoInitialize(NULL);
if (FAILED(CoCreateInstance(CLSID_DirectDraw,
NULL,
CLSCTX_ALL,
IID_IDirectDraw7,
(void **)&fLPDIRECTDRAW7;)))
{
ShowMessage("Failed to create DD7 Instance ");
return false;
}
else
{
if (FAILED(IDirectDraw7_Initialize(fLPDIRECTDRAW7,NULL)))
{
ShowMessage("Failed to initialize DD7 instance");
return false;
}
}
CoUninitialize();
I still want to clean up the error handling and get rid of the ShowMessages, but when I made this change and rebuilt TDx_Draw3D_Library I could now compile and run the example programs successfully . Woohoo!
Hope this is useful for others having this problem.
Jeff
REPLY TO THIS MESSAGE?
Top
You can post a reply to this General message using the form below:
|
|