1. RE: DirectDrawCreate/SetCooperativeMode problems
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Apr 14, 2003
- 473 views
[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 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
2. RE: DirectDrawCreate/SetCooperativeMode problems
- Posted by animeshk at yahoo.com Apr 14, 2003
- 479 views
--- Matt Lewis <matthewwalkerlewis at yahoo.com> wrote: > 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. Aaaah that oen . . . I got DirectDraw4_iid by going to ddraw.h in the Dx9 SDK. I saw a DEFINE_GUID for IID_IDirectDraw4, and I figured that was the IID. I cut-and-paste, converting the list of integers into a string, and I formatted the string like other GUID's I was seeing in Euphoria. Unfortunately, I goofed: I left a ", 0x05". Even when I fixed it, however, it didn't work. > In fact, you don't need to declare an > additional interface. > You can use the default interface for the functions > here. It worked! I removed the add_iid call completely and called "SetCooperativeLevel" with no problem. > 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. Thanks! --Animesh
3. RE: DirectDrawCreate/SetCooperativeMode problems
- Posted by animeshk at yahoo.com Apr 14, 2003
- 445 views
Because I can't leave well-enough alone, I tried something . . . well, kinda stupid. I read that the "recommended" way to create a DirectDraw7 object is to use "DirectDrawCreateEx". This expects an IID as a param. I was looking over a Delphi translation of the DX7 headers, and it appears that it expects the actual 16-byte GUID passed as a parameter to the fcn call -- not a _pointer_ to the GUID, but the GUID itself. Am I severely misreading this? If not . . . anyone know if this is even possible in Euphoria? Thanks! --Animesh
4. RE: DirectDrawCreate/SetCooperativeMode problems
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Apr 15, 2003
- 563 views
> From: animeshk at yahoo.com [mailto:animeshk at yahoo.com] > Because I can't leave well-enough alone, I tried > something . . . well, kinda stupid. I read that the > "recommended" way to create a DirectDraw7 object is to > use "DirectDrawCreateEx". This expects an IID as a > param. I was looking over a Delphi translation of the > DX7 headers, and it appears that it expects the actual > 16-byte GUID passed as a parameter to the fcn call -- > not a _pointer_ to the GUID, but the GUID itself. Am > I severely misreading this? If not . . . anyone know > if this is even possible in Euphoria? Thanks! > --Animesh Here's what MS says about DirectDrawCreateEx: HRESULT WINAPI DirectDrawCreateEx( GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter ); It's important to be careful when looking at how other languages implement things, especially OO ones like Delphi. What you could have seen was really a call to a TGUID constructor, or something, which actually converts the string representation into the 16-byte representation, and stores it in memory, returning a pointer to the location. In Euphoria, however, we tend to work at a slightly lower level when it comes to COM, so unfortunately, we have to understand what's *really* going on, as opposed to what Delphi or some C++ lib do. You'll need to use string_to_guid() and poke the result into memory. Matt Lewis