问题描述
我想使用MFC CDialog创建MS Paint程序.我在创建画布时遇到问题.我不想直接在CDialog上绘制.我想在CDialog上放一些东西作为绘画画布.我的意思是,我想在白色画布上画线.我尝试了以下方法.
1.我使用mousemove事件并在CDialog上使用笔.我可以在CDialog上绘画.但是我不想直接在CDialog上绘制.
2.我在CDialog上创建了GroupBox用作画布.通过使用CRect,我用白色填充了GroupBox.当时那个矩形是用白色上色的.这就是我所需要的.然后,我使用mousemove事件和笔在GroupBox上绘制.但是,我不能在白色矩形上画线.我看不到任何画的线.
3.我基于CStatic类创建了GroupBox类.使用OnEraseBkgnd(CDC * pDC)事件,用白色填充GroupBox.然后,我在其中添加OnMouseMove,OnLButtonDown事件来处理鼠标事件.然后,我将该类添加到CDialog中.但是,问题是鼠标事件不适用于GroupBox.我说的对吗?
总而言之,我的要求是创建一个绘画画布并在其上绘制.但是我不知道该怎么做.有人可以给我指导吗?谢谢高级.
I would like to create MS Paint program by using MFC CDialog. I have problem in creating paint canvas. I don''t want to draw directly on CDialog. I would like to put something on CDialog as a paint canvas. I mean, I would like to draw lines on white canvas. I tried the following methods.
1. I used mousemove events and pen on CDialog. I can draw and paint on CDialog. But I don''t want to draw directly on CDialog.
2. I created GroupBox on CDialog to use as a canvas. By using CRect, I filled the GroupBox by white color. At that time, that rectangle was colored by white. It is what I need. Then, I use mousemove events and pen to draw on GroupBox. But, I can''t draw lines on white rectangle. I can''t see any lines that I draw.
3. I created GroupBox Class based on CStatic Class. Use OnEraseBkgnd(CDC* pDC) event, to fill GroupBox with white color. Then I add OnMouseMove, OnLButtonDown events there to handle mouse events. Then I added that class to CDialog. But, the problem is mouse events don''t work for GroupBox. Am I right?
Summarizing, my requirement is to create a paint canvas and draw on it. But I don''t know how to do it. Could anyone give me guidelines on it? Thanks in advanced.
推荐答案
这篇关于我可以在MFC GroupBox中使用鼠标事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!