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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting position / coordinate of button on dialog

Status
Not open for further replies.

Skute

Programmer
Jul 21, 2003
272
GB
Hi,

how can i get the position of a button on my dialog? im basically trying to find out when the mouse is over a particular button.

i tried this, but it didnt work:

CPoint ptCursor;
CRect rtButton;
CButton* cmdRecord = (CButton *)GetDlgItem(IDC_RECORD);

GetCursorPos(&ptCursor);
cmdRecord->GetClientRect(&rtButton);

if (rtButton.PtInRect(ptCursor))
{
// Etc...
}

Thanks
 
You probably are experiencing a challenge because the coordinate systems used by the rectangle and the point are different. There is a built in functions ClientToScreen and ScreenToClient to handle the conversion for you.

Hope this helps.
 
yeah ive tried the clienttoscreen, but the actual rect comes back empty? should that code actually work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top