Click here to Skip to main content
Sign Up to vote bad
good
See more: VC6MFC
Hi, When I want to use Win32 API functions in some cases it's need to use the HWND of App as an input parameter.
In MFC I used AfxGetApp()->m_pMainWnd but I got this message from VC6 compiler:
error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *'.
 
By the way I have the same problem with HINSTANCE parameters.
 
Thanks.
Posted 12 Feb '10 - 1:18
Edited 12 Feb '10 - 2:05
CPallini246K


2 solutions

You should deference the CWnd pointer: using *AfxGetMainWnd() is enough, since CWnd implements the HWND cast operator.
For instance:
::SetWindowText(*AfxGetMainWnd(), _T("Hi Folks"));
  Permalink  
AfxGetApp()->m_pMainWnd is a CWnd* and the CWnd class has a HWND member called m_hWnd.
 
So you could use it as AfxGetApp()->m_pMainWnd->m_hWnd.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 394
1 Mahesh Bailwal 353
2 Maciej Los 285
3 CPallini 245
4 Rohan Leuva 175
0 Sergey Alexandrovich Kryukov 9,287
1 OriginalGriff 7,204
2 CPallini 3,923
3 Rohan Leuva 3,211
4 Maciej Los 2,713


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 12 Feb 2010
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid