PDA

View Full Version : HWND Help


sxc
8th May 2002, 01:21
I am trying to write an external app. that will communicate with Winamp. I started by inserting this line "HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);" to find the winamp window (like the API page says). However, when I try to compile the program I am getting an error from VC++ that says

"error C2440: 'initializing' : cannot convert from 'class CWnd *' to 'struct HWND__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"

Can someone tell me what I am doing wrong?

Thanks!

Brian

Tuatara
11th May 2002, 11:00
Brian,

Firstly you're using MFC, and you're most likely using this code inside a CView or some other derivative of a CWnd.

For your code to work properly in MFC, you'll need to code things like this:

CWnd *pWndWinamp = FindWindow("Winamp v1.x", NULL);

since MFC returns a static CWnd* for this function in a CWnd, or if you don't want MFC in the way use the following ...

HWND hwndWinamp = ::FindWindow("Winamp v1.x", NULL);

The double colon '::' specifies that you don't want the MFC derived functionality in the CWnd class, but want the API declaration instead.

Hope this helps. :D