程序想要获取Picture控件在对话框中的位置,并从对话框起点画直线到控件正中点。程序如下:
CRect DrawLine;
GetDlgItem(IDC_DrawLine)->GetWindowRect(&DrawLine);
CClientDC dc(this);
CPen pen(PS_SOLID,1,RGB(255,0,0));
dc.SelectObject(&pen);
CPoint point;
point.x=(DrawLine.left+DrawLine.right)/2;
point.y=(DrawLine.top+DrawLine.bottom)/2;
dc.MoveTo(0,0);
dc.LineTo(point);
不知为何,画出的直线位置显示不对。
请大虾们指点迷津……
CRect DrawLine;
GetDlgItem(IDC_DrawLine)->GetWindowRect(&DrawLine);
CClientDC dc(this);
CPen pen(PS_SOLID,1,RGB(255,0,0));
dc.SelectObject(&pen);
CPoint point;
point.x=(DrawLine.left+DrawLine.right)/2;
point.y=(DrawLine.top+DrawLine.bottom)/2;
dc.MoveTo(0,0);
dc.LineTo(point);
不知为何,画出的直线位置显示不对。
请大虾们指点迷津……
解决方案 »
- VC++.NET问题
- syslistview控件怎么改变每个Item字体颜色
- 怎么调用计算出来的CString型的资源ID
- Winpcap 发包函数pcap_sendpacket 有时成功,有时失败
- 在windows xp下使用softice 4.3.1 lite出现的问题
- 关于guid,急!!!
- netmeeting高手帮忙!!!一个关于netmeeting的问题!如果问题解决再送100分!!!!!!
- VC为什么会出现这样的情况,编译通过,LINK会出错?
- 关于windbg 导入dump的问题
- 我是这样解决AnimateWindow()
- VC++程序求助各位高手
- 今天刚刚开始学GDI+ 遇到了问题。
CRect DrawLine,WindowRect;
GetDlgItem(IDC_DrawLine)->GetWindowRect(&DrawLine);
this->GetWindowRect(&WindowRect);
CClientDC dc(this);
CPen pen(PS_SOLID,1,RGB(255,0,0));
dc.SelectObject(&pen);
dc.MoveTo((-WindowRect.left + DrawLine.left),(-WindowRect.top + DrawLine.top -29));
dc.LineTo((-WindowRect.left +DrawLine.CenterPoint().x),(-WindowRect.top +DrawLine.CenterPoint().y-29));29是偏移调整,我自己是这么做的,也不是很明白为什么,不同机子还不太一样的