![]() |
|
#1
|
|||
|
|||
How to get a handle to a derived class?Hello forum,
I have an MFC dialog application with a USB class of my own. I would like to be able to receive device notifications in the USB class, but the RegisterDeviceNotification needs a handle for the recipient of the notifications. The only handle I can come up with is the handle for the main dialog class. So how do I get the handle for my USB class, so that it's the USB class' MESSAGE_MAP that receives the notification? The call to RegisterDeviceNotification looks like this at the moment: CPP / C++ / C Code:
The call is made from within the USB class, but the member function containing the call to RegisterDeviceNotification is called from the main dialog class' OnInitDialog(). I would somehow like to replace "this" with the handle for the USB class. The USB class object is created like this: CPP / C++ / C Code:
I'm not sure I have provided enough background information on how to get the handle, so please ask for more if nessasary. I hope you can help me. Thanks. Regards, Futterama Last edited by LuciWiz : 26-Jan-2007 at 12:40.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#2
|
|||
|
|||
Re: How to get a handle to a derived class?HI,
Is your class is derived from CDialog. // class USBclass : public CDialog If yes then u can easily see that CDialog is internally derived from CWnd, which is having a member variable m_hwnd that contains handle to dialog. For modeless dialog u have to initializes the value m_hwnd by calling Create function of Cwnd class. your class Cntr will look like something this USBclass() : CDialog(...) { Create(.....) // Just see parameters which has to be passed. } After calling create function , your class members will get initilaized and you can get the vlaue of m_hwnd. USBclass USBclassObj; You can use value like this USBclassObj.m_hwnd; For mOdal dialog instead of calling Create function you have to call another fn. See MSDN for help. Regards, Umesh Bansal. |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hard drive/CPU Diagnoses Issues | binarybug | Computer Hardware Forum | 1 | 22-Jan-2007 20:23 |
| Box Class, need help again :( | TransformedBG | C++ Forum | 7 | 13-Nov-2006 16:11 |
| a tester class and then some. | postage | Java Forum | 1 | 06-May-2006 16:48 |
| Help with syntax errors | PeteGallo | C Programming Language | 7 | 08-Aug-2005 21:30 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 07:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The