RE: DirectDrawCreate/SetCooperativeMode problems

new topic     » topic index » view thread      » older message » newer message

[reposting from the web, since it hasn't show up in over 7 hours]

> -----Original Message-----
> From: animeshk at yahoo.com [mailto:animeshk at yahoo.com]

> I just tried this again, this time not using the
> wrapper generated from TBrowse (importing dx7vb.dll). 
> It still isn't working, and it is returning the same
> error code at the SetCooperativeMode call.  The error
> code translates, in the TBrowse-generated wrapper, to
> the completely incorrect error code saying that
> aggregation isn't allowed!  Can anyone tell me what
> the heck is going on here?  I'm sure I'm just doing
> something really really stupid and obvious sad

Yeah, but it's the really stupid and obvious errors that I make that are 
the hardest to fix. :)  First, I'm not sure where you got the IID for 
DirectDraw4_iid, but it's the wrong length fro an iid, and formatted 
strangely.  In fact, you don't need to declare an additional interface.  
You can use the default interface for the functions here.  If you wanted 
to use invoke, you'd need to add IDispatch.  BTW, all VB goes through 
IDispatch (also known as Automation).  EuCOM couldn't find your 
interface, since it's incorrect.  Change:

res = call_interface( DDraw, DirectDraw4_disp,
	DirectDraw4_SetCooperativeLevel,
	{ getHandle(MainWin), 0 } )

to: 

res = call_interface( DDraw, 1,
	DirectDraw4_SetCooperativeLevel,
	{ getHandle(MainWin), 8 } )

If you don't change the 0 to an 8, you'll get an error saying that at 
least one argument is invalid.  In this case, the docs for 
SetCooperativeLevel say that you must set either the DDSCL_NORMAL or 
DDSCL_EXCLUSIVE flag (DDSCL_NORMAL = 8).

Whenever you're writing a EuCOM app, I recommend putting com_err_out(1) 
at the top.  This will direct any error messages from EuCOM to standard 
output (you could open a file and pass the file number, too).  Also 
handy is using com_error() whenever you get a non-zero HRESULT, since it 
will tell you if it recognizes the error.  It's real easy to try to 
debug the wrong part of the program, when in fact the error is something 
trivial in some call to a method.

With regard to TBROWSE.  It's mainly useful when using ActiveX objects, 
and you're going to use Automation.  Everything it does is really geared 
towards using the invoke() method of accessing object and interface 
members.  It may not always get the information you need to call 
interfaces directly (it depends upon the file, and how the author built 
it and what made it into the typelibrary).  However, it will still get 
you a lot of good information in the way of structure declarations and 
constant values, plus you can use it as an online guide.  For things 
like DirectX, I would recommend having a copy of the C header files 
handy, and, of course, the documentation.

Hope this helps,

Matt Lewis

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu