How do I use Create Device in an ActiveX/MFC game? I need HWND but can't get it

Started by
2 comments, last by wease 18 years, 10 months ago
Hi, I'm trying to write a game that will run from an activeX control. Unfortunately, I need the window's HWND to use the CreateDevice function. I've been trying to figure out how to get this but everything I've tried doesn't work. Anyone know how to do this? thanks
Advertisement
I believe your CHWND has a function called GetHwnd( ) which does exactly what you need.

Sorry if function name or object type is wrong; it's been a little while :)

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
The GetTopLevel*() methods of your COleControl based class should do the trick for finding a top level window (AFAIK one of those should get the top most control container window if necessary).

To get a HWND from a CWnd, use CWnd::GetSafeHwnd()

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks...you guys both responded so promptly. I don't know why I didn't post this on here earlier :)

Anyway, I tried the GetHwnd() function and it worked perfectly. I also tried the GetTopLevelOwner() function (I couldn't find anything about GetTopLevel...there was GetTopLevelFrame and GetTopLevelOwner, etc and it worked perfectly as well.

So thank you both for your help.

This topic is closed to new replies.

Advertisement