We help IT Professionals succeed at work.

HWND?  CWnd?

police1
police1 asked
on
ok.. I am trying to change the info on my system tray icon, but don't know how to get the HWND from my project. Here is a bit of info.

I am not changing the info from a place I can get it from easy.  So that eliminates  m_hWnd.   When I try to use AfxGetApp()->GetMainWnd();   It says that, that is a CWnd... not an HWND.   Is there any function (like the AfxGetApp)  That will let me get the HWND of my applications main window?  The icon was created with -GetSafeHwnd();... which is not available from my other class.

Thanks.
Comment
Watch Question

ekc

Commented:
CWnd has a public member variable m_hWnd.
Commented:
AfxGetApp()->GetMainWnd()->m_hWnd

is what you need.
The class CWnd is MFC wrapper around generic window and the place where you can find almost all the information and APIs related to windows.
Hi,
Use GetSafeHwnd() that should be doing ur job.
-Shilpa
ekc

Commented:
shilpa_Jb...
Please, don't lock the questions and try to post only comments, especially if there are some answers which are as good candidates for the correct one as your own...

Author

Commented:
GetSafeHwnd() is not available in the other class, as stated in my question.

Author

Commented:
Thanks man... that worked great. :)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.