vc picture上用鼠标画直线???都找了好几天了

来源:百度知道 编辑:UC知道 时间:2024/05/25 17:11:36
我在dialog中放了一个picture播放视频,怎么能在picture上用鼠标画一条直线.
要求是:1、能保存这条直线
2、不管画多少条,只保存最后画的一条。也就是说只能有一条直线
3、要能看出画的轨迹

用Picture控件,改变大小就成了一个直线,很多人都推荐这样做
源码;void CDlgLineDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CClientDC pDC(this);
int red = 0;
int green = 0;
int blue = 0;
int width = 2;
int row = 20;

for (int x=0; x<8; ++x)
{
int color = RGB(red,green,blue);
CPen newPen(PS_SOLID, width, color);
CPen* oldPen = pDC.SelectObject(&newPen);
pDC.MoveTo(20, row);
pDC.LineTo(300, row)