How do I use Create Device in an ActiveX/MFC game? I need HWND but can't get it
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
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
Sorry if function name or object type is wrong; it's been a little while :)
Matt Hughson
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()
To get a HWND from a CWnd, use CWnd::GetSafeHwnd()
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.
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
Popular Topics
Advertisement