zia
zia

Reputation: 117

FindWindow is not working?

I just want to know why this code is not working?

    HWND hWnds = FindWindow(NULL,(LPCTSTR)"Calculator");

It always returns NULL for the hWnds....

Any idea how to fix this? Thank you :)

Upvotes: 0

Views: 6404

Answers (2)

Ajay
Ajay

Reputation: 18411

Make a folder named 'Calculator' and enter into it using Windows Explorer.

Now run your program - wrong window handle would be returned!

Using Spy++ on Windows 7, I found out class-name of Calculator window to be: CalcFrame.

Try using this:

HWND hWnds = FindWindow(_T("CalcFrame"), NULL);

Upvotes: 0

Daniel A. White
Daniel A. White

Reputation: 190925

Dont cast the string.

HWND hWnds = FindWindow(NULL,_T("Calculator"));

Upvotes: 4

Related Questions