Click to See Complete Forum and Search --> : Getting window class from HWND


Jaime Wyant
May 25th, 1999, 01:07 PM
If I have an HWND, is there a way to tell if this window is an edit control?

Also, is there a way to get a CWnd* from an HWND?

Thanks,
Jaime

hammad
May 25th, 1999, 01:25 PM
Attach it to a CWnd using the static CWnd function FromHandle.

CWnd* pWnd = CWnd::FromHandle(hWnd);

Then use runtime information.

if (pWnd->IsKindOf(RUNTIME_CLASS(CEdit)))
{
Do whatever...
}

You have a pointer to a CWnd* object now. It's not permanent though. For it to be permanent you should call the static function CWnd::FromHandlePermanent.