私はこれをどのように動作させるかを考え出しました。つまり、プログラムでこれを実装する方法を知りたい人は、このコードからアイデアを得ることができます。
コード:
void CRangemasterGeneratorDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
GetCursorPos(&point);
int mx = point.x;
int my = point.y;
float cursR, cursH;
cursR = (mx - 312)/7.2;// records the current cursor's radius(x) position
cursH = (641 - my)/5.3;// records the current cursor's height(y) position
CString Hgt,Rds;
Hgt.Format("%.3f",cursH);// Rounding off Height values to 3 decimal places
Rds.Format("%.3f",cursR);// Rounding off Radius values to 3 decimal places
curR = (float)atof(Rds);
curH = (float)atof(Hgt);
// I had limits on my grid from 0 - 100 on both x and y-axis
if(curR < 0 || curR >100 || curH < 0 || curH > 100)
return;
SetCapture();
SetCursor(::LoadCursor(NULL, IDC_CROSS));
//snap the point, compare the point with your array and save position on 'y'
for(int i=0; i < 100; i++)
{
if(curH < m_Points[i+1].m_height_point && curH >m_Points[i-1].m_height_point)
{
curH = m_Points[i].m_height_point;
curR = m_Points[i].m_radius_point;
y = i;
}
}
CDialog::OnRButtonDown(nFlags, point);
UpdateData(false);
Invalidate();
}
void CRangemasterGeneratorDlg::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ReleaseCapture();
GetCursorPos(&point);
int mx1 = point.x;
int my1 = point.y;
float curR1,curH1;
curR1 = (mx1 - 312)/7.2;// records the current cursor's radius(x) position
curH1 = (641 - my1)/5.3;// records the current cursor's height(y) position
m_Points[y].m_radius_point = curR1;
m_Points[y].m_height_point = curH1;
Invalidate();
CDialog::OnRButtonUp(nFlags, point);
UpdateData(false);
}
...
私はこのコードを実行しているし、それは見事にうまく動作します。このコードの変数は、自分のプログラムで使用した変数に関連しています。あなたが理解できない場合は、私に相談してください。
ありがとうBrandon。本当に助かった。あなたが言ったことを実装した後、それは働いた。 乾杯。 – Neophile
@ Nerds.Dont.Swear大歓迎です、私はそれが助けてくれてうれしいです:-) – BrandonSun