如何在图片框上制作鼠标光标跟踪线而不会干扰图片框中的图像? [英] How to make mouse cursor tracking line on picturebox without disturbing the image in the picturebox?

查看:133
本文介绍了如何在图片框上制作鼠标光标跟踪线而不会干扰图片框中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次在visual studio工作,之前我用qt在ubuntu上制作了一个gui,但是现在在visual studio中创建了一个gui。我有一个图片框
,我正在从相机显示连续的进纸。

现在我希望每当我在影像框的任何地方移动我的cusor时,它会在图片框上绘制一条垂直和水平线鼠标光标作为交叉点而不影响图片框中的Feed图像
并再次为ROI绘制一个矩形,而不会影响图片框中的图像。

QT结果如下:

< span style ="color:#242729">




我尝试过图形处理方法但是它没有给我所需的结果

Pen^ pen1x = gcnew Pen(Color::Black);
		 Graphics^ g_cam1_cal;
		private: System::Void cam1_calib_imagebox_MouseMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
			if (!g_cam1_cal)
				g_cam1_cal = cam1_calib_imagebox->CreateGraphics();
			g_cam1_cal->Clear(Color::Empty);
			g_cam1_cal->DrawLine(pen1x, e->X, 0, e->X, cam1_calib_imagebox->Height);


结果:

移动光标 

when cursor was moved 

推荐答案

您好victor1765,

Hi victor1765,

清除图形对象后需要刷新pictureBox:

You need to refresh the pictureBox after clear the graphic object:

        Pen^ pen1x = gcnew Pen(Color::Black);
        Graphics^ g_cam1_cal;
		private: System::Void cam1_calib_imagebox_MouseMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e)
        {
            if (!g_cam1_cal)
                g_cam1_cal = cam1_calib_imagebox->CreateGraphics();
            g_cam1_cal->Clear(Color::Empty);

            cam1_calib_imagebox.Refresh();
            //cam1_calib_imagebox.Invalidate();//or

            g_cam1_cal->DrawLine(pen1x, e->X, 0, e->X, cam1_calib_imagebox->Height);
        }

问候,

Frankie


这篇关于如何在图片框上制作鼠标光标跟踪线而不会干扰图片框中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆