CWnd * pWnd=GetDlgItem (IDC_STATIC_T); PWnd - & gt; Invalidate (). PWnd - & gt; UpdateWindow (); The CDC * pDC=pWnd - & gt; GetDC (); PDC - & gt; A Rectangle (0, 0580660);//rectangular frame CPen * pPenRed=new CPen ();//create a brush object The CGdiObject * pOldPen=pDC - & gt; SelectObject (pPenRed);//select the current red brush, and save the previous brush PDC - & gt; MoveTo (40, 20);//draw the axis PDC - & gt; The LineTo (40, 620);//up axis PDC - & gt; LineTo (540620);//horizontal axis CodePudding user response:
Get the current mouse position, and determine whether on the axis line, display in words, not just don't show!
CodePudding user response:
Don't forget to delete the brush pointer...
CodePudding user response:
Hi, I am a mouse in the coordinate system can output the coordinates, but I move the coordinate system a location, the coordinate is changed, I how to convert the coordinates relative to the coordinates of the control
CodePudding user response:
"But I put the moving coordinate system a position, coordinates changed"
Remember coordinates in the relative position of the client area
CodePudding user response:
Void CXqDlg: : onm ouseMove (UINT nFlags, CPoint point)
{
}
I want to ask next the onm ouseMove inside point coordinates, which is relative to, how do I take this coordinate transformation to me to come in the coordinate system
CodePudding user response:
reference Andy516520 reply: 3/f hello, I am a mouse in the coordinate system can output the coordinates, but I move the coordinate system a position, coordinates is changed, I how to convert the coordinates relative to the coordinates of the control Computing the relative position of two coordinate system before and after the ~ CodePudding user response:
Point Specifies the x - and y - coordinate of the cursor. These coordinates are always relative to the upper - left corner of the window. CodePudding user response:
These coordinates are always relative to the upper - left corner of the window. CodePudding user response:
Coordinate Space and the Transformation Functions provides The following functions provides are 2 with coordinate Spaces and transformations. ClientToScreen CombineTransform DPtoLP GetCurrentPositionEx GetGraphicsMode GetMapMode GetViewportExtEx GetViewportOrgEx GetWindowExtEx GetWindowOrgEx GetWorldTransform LPtoDP MapWindowPoints ModifyWorldTransform OffsetViewportOrgEx OffsetWindowOrgEx ScaleViewportExtEx ScaleWindowExtEx ScreenToClient SetGraphicsMode SetMapMode SetViewportExtEx SetViewportOrgEx SetWindowExtEx SetWindowOrgEx SetWorldTransform CodePudding user response:
Void CXqTestDlg: : onm ouseMove (UINT nFlags, CPoint point) { CRect RCT. GetDlgItem (IDC_STATIC_T) - & gt; GetWindowRect (RCT);//GetWindowRect function is to obtain control coordinates relative to the left upper corner of the screen RCT. TopLeft () + x=110; RCT. TopLeft (). + y=30; RCT. BottomRight (). X=RCT. TopLeft () x + 500; RCT. BottomRight (). Y=RCT. TopLeft (.) y + 600; CPoint pt; The GetCursorPos (& amp; Pt);//GetCursorPos to obtain the cursor position, in screen coordinates, If (PtInRect (& amp; RCT, pt))//PtInRect function is whether the Point within the Rect (Point) in the area of the rectangle { HCURSOR hCur=LoadCursor (NULL, IDC_CROSS); : : SetCursor (hCur); Float zx, zy; Zx=(300.0/497.0) * point in x - 588.83; Zy=600.0/598.0 (-) * point. Y + 608.026; M_x. The Format (" % 2 f ", zx); M_y. The Format (" % 2 f ", zy); The UpdateData (FALSE); } The else { HCURSOR hCur=LoadCursor (NULL, IDC_ARROW); : : SetCursor (hCur); } CDialog: onm ouseMove (nFlags, point); } This is my onm ouseMove statements, on my computer can put the coordinates of the output is correct, but the same program in the computer wouldn't work, coordinate output right wrong CodePudding user response:
RCT. TopLeft () + x=110; RCT. TopLeft (). + y=30; RCT. BottomRight (). X=RCT. TopLeft () x + 500; RCT. BottomRight (). Y=RCT. TopLeft (.) y + 600; Zx=(300.0/497.0) * point in x - 588.83; Zy=600.0/598.0 (-) * point. Y + 608.026; So many number immediately, associated with the computer! CodePudding user response:
As for your Static IDC_STATIC_T derived CodePudding user response:
@ schlafenhamster hello, contact before long, you said "as IDC_STATIC_T derived for your Static" "how can not understand, refers to a direction CodePudding user response:
Add a new class 1 The class CMyStatic: public CStatic 2. IDC_STATIC_T associated CMyStatic instead CodePudding user response:
Position should be to capture the message, and then obtain coordinate system origin of coordinates, to determine how many pixels per unit length!!!! How specific implementation didn't want to know!!!!!