Sign in to follow this  
wease

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
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()

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this