HOW TO :GetParentOwner() in a DLL 
Author Message
 HOW TO :GetParentOwner() in a DLL

Hello All,

I want to get parent owner under mouse curosr,
i tried the below code it works,
but same is not applicable  to the DLL that i create
in VC++. It gives the error....:

error C2440: 'initializing' : cannot convert from
'struct HWND__ *' to 'class CWnd *'

The DLL is a Win32 DynamicLinkLibrary,

Is there any possiblity for GetParentOwner();
from HWND because i get HWND from WindowFromPoint(pt);

Or any other anternative.

=================================================
POINT pt;
GetCursorPos(&pt);
CWnd *pWinCur = WindowFromPoint(pt);
CWnd *pWinCurMain = pWinCur->GetParentOwner();
=================================================

alex.



Mon, 12 Sep 2005 05:42:51 GMT  
 HOW TO :GetParentOwner() in a DLL

Quote:

> Newsgroups: microsoft.public.vc.mfc
> Subject: HOW TO :GetParentOwner() in a DLL

> Hello All,

> I want to get parent owner under mouse curosr,
> i tried the below code it works,
> but same is not applicable  to the DLL that i create
> in VC++. It gives the error....:

> error C2440: 'initializing' : cannot convert from
> 'struct HWND__ *' to 'class CWnd *'

> The DLL is a Win32 DynamicLinkLibrary,

> Is there any possiblity for GetParentOwner();
> from HWND because i get HWND from WindowFromPoint(pt);

> Or any other anternative.

> =================================================
> POINT pt;
> GetCursorPos(&pt);
> CWnd *pWinCur = WindowFromPoint(pt);
> CWnd *pWinCurMain = pWinCur->GetParentOwner();
> =================================================

> alex.

Hi Alex,

The above code works fine in your APP since that code is in a member
function of a class that derives from CWnd. WindowFromPoint is resolving to
the member function that returns CWnd*.

In the DLL the code is in a function that is not a member of a class that
derives from CWnd and WindowFromPoint is resolving to the windows API that
returns HWND.

Change the code in the DLL as follows.

POINT pt;
GetCursorPos(&pt);

CWnd *pWinCur = CWnd::WindowFromPoint(pt));    // ************************
//

CWnd *pWinCurMain = pWinCur->GetParentOwner();

--
Sridhar Madhugiri, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Sat, 17 Sep 2005 20:56:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Mfc42d.dll Mfco42d.dll and Msvcrtd.dll

2. Create ocx in Dll(regular Dll using shared MFC Dll)

3. Please explain msvcrt.dll msvcrt20.dll msvcrt40.dll

4. msvcrt.dll mfc42.dll mfco42.dll

5. loading an MFC DLL that was originally an extension dll from a non MFC dLL

6. Create ocx in Dll(Regular Dll using Shared MFC Dll)

7. Create ocx in Dll(Regular Dll using Shared MFC Dll)

8. VC6 DLL calls VB6 DLL calls back to VC6 DLL: Occasional GPF or ‘Bad DLL calling convention'

9. Microsoft.Data.Odbc.dll causes System.dll problem

10. calling from non-net C++ DLL to .net DLL and back

11. HOWTO? Calling VB DLL from C++ DLL

12. Using public class constants from a C#-dll in mangaged C++-dll

 

 
Powered by phpBB® Forum Software