Archived

This topic is now archived and is closed to further replies.

help me on getting the current window pos please

This topic is 5013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have two questions. 1.how do you get the current window pos for like buttons,etc... what function do i use? 2.when i click the mouse on the window the child window like buttons ,etc(creating at runtime).. dont go where your mouse was click at. it goes other places on the window. how do i fix that? thanks for trying to help me.

Share this post


Link to post
Share on other sites
1)

RECT rTemp;
GetClientRect(hwnd, &rTemp);
//that one returns 0,0,width,height
GetWindowRect(hwnd, &rTemp);
//that one returns absolute coordinates, relative to the screen

2)
Im not quite getting you

[edited by - porthios on March 27, 2004 10:40:27 PM]

Share this post


Link to post
Share on other sites
on GetWindowRect() i just want to know how to get the x,y.
for the height it is bottom-top and the width it is right-left
but how do i get the x and y.

for the second question.
what i mean is when you click the left mouse button on the screen
it will create buttons and other stuff but when i click the left mouse button it will create the button on the screen but not where the mouse was clicked at.i used the GetCursorPos function and then i did the createwindow function but for the x and y i put in mouse.x and mouse.y . it does not go where your mouse was at. please help me... i want it to go where your mouse was at.

Share this post


Link to post
Share on other sites
You use GetWindowRect to get the coordinates of the corners of the window. So if you are interested in the top left corner, the x is the left value, and the y is the top value.

Share this post


Link to post
Share on other sites
For the second question, GetCursorPos returns the position relative to the top left corner of the screen. Simply convert the screen coordinate to client coordinate. There is even a Win32 function for doing just that, ScreenToClient(....).

Share this post


Link to post
Share on other sites
thanks i got it working now.....thanks.thanks.thanks

by the way.
so the rect.left is x
and rect.top is y

is it.....is there any equations to do to get the x and y

just asking.

Share this post


Link to post
Share on other sites