嗨,我开始用gdiplus学习绘制形状,但是如何从画布中删除形状? [英] Hi, I start to learn draw shape with gdiplus, but how do I delete shape from canvas ?

查看:146
本文介绍了嗨,我开始用gdiplus学习绘制形状,但是如何从画布中删除形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人:

i是新的,我刚开始学习绘画形状与vs2012 c ++和Gdiplus大约5周,我创建了一个简单的项目来测试,但是当我绘制多边形完成时,我不能删除我从画布中选择的任何多边形,删除矩形或椭圆不是那么容易,只删除CArray中的参数,但画布仍然可以找到多边形,就像我的项目结果显示...



i将我的项目放在这里:

https://drive.google.com/file/d/1LrQY0tQ7RqqXDiRjonASU5QXMRh3X2t0/view?usp=sharing



它可以工作,我需要有人来帮助我或教我关键点。



Q1:我如何识别背景存储区域,或者当我使用双缓冲区绘制形状时显示存储区域,我使用bitblt,显示绘制结果不是很好吗?



Q2:我如何使用面向对象编程的想法,重写我的测试代码,让它变得更容易阅读或更容易添加任何新项目,例如:阅读一些书籍或一些信息!



Q3:我对代码编程感兴趣,我需要知道哪些基本书籍或知识,如果我希望成为一个好的编码员。



或者如果您有任何想法,那就没关系~~~



如何使用我的项目:

1.打开项目,然后开始运行。

2.选择绘制模式或删除模式。

3.当用户选择绘制矩形时:使用鼠标左键并保持向下,开始绘制,并且可以调整大小。

4.选择绘制多边形时:使用鼠标左键移动鼠标,开始绘制,用户选择你想要的下一个点,它会自动将最后一个点连接到新点,如果要关闭,请使用鼠标右键并单击一次。

5。当用户选择删除时:使用鼠标选择你绘制的任何形状,然后单击形状topleft或bottomright,messagebox将显示,如果选择ok,则形状将通过笔notxorpen模式重绘。



我尝试过:



i尝试从书籍和网络上找到这么多的标题或答案,但那些不是很清楚,我想,我尝试编写代码来测试并找到它如何得到答案或当我采用不同的方式来测试gdiplus时会发生什么,我不太了解编程的代码如何:双缓冲区来绘制形状,使用面向对象的编程来创建一个新的完整项目,或者如何变得更容易阅读或测试其他人的思想。我知道这不是一个很短的时间来正确的方式,我只是想获得更多的基础知识来学习。

Dear All:
i am new, i just start to learn draw shape with vs2012 c++ and Gdiplus about 5 weeks, i create a simple project to test, but when i draw polygon finish, i cannot delete any polygon which i selected from canvas, it not so easy like to delete a rectangle or a ellipse, only delete the parameter in CArray, but the canvas still can find the "polygon", like my project result show...

i put my project here :
https://drive.google.com/file/d/1LrQY0tQ7RqqXDiRjonASU5QXMRh3X2t0/view?usp=sharing

it can be work, i need someone to help me or teach me the "key point".

Q1 : how do i to identify the background memory area, or show memory area when i use double buffer to draw shape, i use bitblt , it not very good to show the draw result?

Q2 : how do i to use "Object Oriented Programming" idea, to rewrite my test code and let it become more easy to read or easy to add any new item, for example : read some books or some information !

Q3 : i am interest in code programming, what basic books or knowledge i need to know, if i wish to become a good "coder".

or if you have any idea, it is ok~~~

how to use my project :
1. open the project, and start to run.
2. select draw mode or delete mode.
3. when user select draw rectangle : use mouse left button and keep it down, start to draw, and it can resize.
4. when select draw polygon : use mouse left button and move mouse, start to draw, and user select next point you want, it will auto connect the last point to the new point, if you want to close, please use mouse right button and click once.
5. when user select delete : use mouse select any shape you draw, and click the shape topleft or bottomright, messagebox will show, if you select "ok", the shape will redraw by pen notxorpen mode.

What I have tried:

i try to find so much title or answer from book and web side, but those are not very clear i thought, i try to write code to test and find how it get answer or what happen when i go different way to test the gdiplus, i do not very understand how the code to programming, like : double buffer to draw shape, use the "Object Oriented Programming" to create a new full project, or how to become more easy to read or test other people's thought. i know it not a short time to get the right way, i just want to get more basic knowledge to study.

推荐答案

你应该做你所有的绘画/绘画处理WM_PAINT消息的函数中的屏幕。每次调用此函数时,它都应重绘所有形状。删除形状后,只需将其从要绘制的项目列表中删除,然后调用 InvalidateRect 强制重新绘制客户端窗口。
You should do all your painting/drawing to the screen in the function that handles the WM_PAINT message. Each time this function is called it should redraw all the shapes. When a shape is deleted you just remove it from the list of items to draw, and then call InvalidateRect to force a repaint of the client window.


这篇关于嗨,我开始用gdiplus学习绘制形状,但是如何从画布中删除形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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