Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ScreenToClient function

Status
Not open for further replies.

horst123

Programmer
Mar 21, 2005
18
DE
Hi,

can anybody explain to me, how to use the ScreenToClient function I've done this:

Code:
IntPtr hwnd;
hwnd = panel1 -> get_Handle();
ScreenToClient(hwnd, mousePos);

where panel is a Panel and the mousePos is a Point. The Error I get is: can't convert IntPtr to HWND

thx for help
 
Hmm,

after lots of try I did like that:

ScreenToClient((HWND)&hwnd, (LPPOINT)&mousePos);
 
Okay, now there's no error, but the piece of code I wrote does nothing. The coordinates are still wrong...

Any idea?
 
I guess you're calling a member function, not the Windows API.

This should do the trick:
Code:
::ScreenToClient(hwnd, mousePos);

/Per

www.perfnurt.se
 
Hi,

I've done it. After your comment I got the idea:

Code:
mousePos = panel1 -> PointToClient(mousePos);

Okay, thx anyway!
 
Probably get_Handle() member returns not HWND handle (1st arg of ::ScreenToClient type). As usually get_Handle() in this context returns bitmap, icon etc handles...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top