Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC COM ActiveX
I am writing an activeX control in Visual C++ 6.0
I would like to have an hWnd parameter in one of my methods, so that I can set the parent of a window from a seperate process, so it'll be a child window of the dialog the activeX (*.ocx) is embedded in.
I've tried making a method like this for example:
 
double CMyActiveXControlCtrl::Parent(HWND Parent);
{
SetParent(Parent, ... )
return 0.0;
}
 
But it won't work because I have to add the method via right click on tree view item -> add method.
When that is done in the Visual C++ IDE, it still won't work because there is no hWnd parameter to select in the drop down menu, There is long, short, float, bool, LPCTSTR, OLE_HANDLE, etc but none of them are what I need. What do I need for setting a struct HWND__ * method parameter? What am I doing wrong?
 
Thanks!
TKG
Posted 13-Aug-12 9:59am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to use OLE_HANDLE.
 
You have to typecast HWND to OLE_HANDLE (and vice versa). Check the following link for a sample:
 
http://us.generation-nt.com/answer/how-do-you-cast-an-hwnd-an-ole-handle-help-9254962.html[^]
  Permalink  
Comments
time-killer-games at 15-Aug-12 18:20pm
   
Thanks! This is awesome! I haven't tested it yet but I'm pretty certain it will work... You're awesome ;)
manoranjan at 16-Aug-12 0:07am
   
You are welcome:) Glad to be of help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 14 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100