OnLButtonDown
-
Hello. I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg. The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down. Can anyone help me in this? I want to get the coordinates of the picture.
-
Hello. I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg. The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down. Can anyone help me in this? I want to get the coordinates of the picture.
Where do you use of
GetCursorPos
on your program for get position?
WhiteSky
-
Where do you use of
GetCursorPos
on your program for get position?
WhiteSky
When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture. And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this?
-
When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture. And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this?
ReturnRain wrote:
When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture
GetCursorPos() will return the x,y points with respect to screen coordinates. Change those to clinet coordinates. say, m_wndMyStatic is your derived static class variable,then
POINT pt = {0};
GetCursorPos( &pt );
m_wndMyStatic.ScreenToClient( &pt );ReturnRain wrote:
And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this
Handle WM_LBUTTONDOWN and WM_LBUTTONUP and do the above. You can get the rect.. Hope this will help
Do your Duty and Don't expect the Result
-
Hello. I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg. The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down. Can anyone help me in this? I want to get the coordinates of the picture.
Your picture control is a seperate child window to the dialog, so mouse click message is generated and sent to static window, then the static window send WM_NOTIFY message to the parent dialog window, when ur mouse clicks on static control rather than clicking on dialog window. I recommand u to handle this by overwrite CStatic::OnLButtonDown or handle it by CYourDialog::OnNotify. hope this could help u out.
life is like a box of chocolate,you never know what you r going to get.
-
ReturnRain wrote:
When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture
GetCursorPos() will return the x,y points with respect to screen coordinates. Change those to clinet coordinates. say, m_wndMyStatic is your derived static class variable,then
POINT pt = {0};
GetCursorPos( &pt );
m_wndMyStatic.ScreenToClient( &pt );ReturnRain wrote:
And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this
Handle WM_LBUTTONDOWN and WM_LBUTTONUP and do the above. You can get the rect.. Hope this will help
Do your Duty and Don't expect the Result
Thanks! I can get the first part right. But Im confused with the WM_LBUTTONDOWN and WM_LBUTTONUP. Since i want the picture coordinates when the button is down, should i put the codes in OnLButtonDown or OnPicture (picture control)? And just to make sure, OnLButtonDown and OnLButtonUp is in the dlg?
-
Thanks! I can get the first part right. But Im confused with the WM_LBUTTONDOWN and WM_LBUTTONUP. Since i want the picture coordinates when the button is down, should i put the codes in OnLButtonDown or OnPicture (picture control)? And just to make sure, OnLButtonDown and OnLButtonUp is in the dlg?
You must get position on the picture class (if you derived a CStatic class)
WhiteSky