Jump to content
  • Advertisement
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

This topic is 4894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!