如何画儿童帆布? [英] How to draw in child canvas?

查看:122
本文介绍了如何画儿童帆布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个包含以下对象的SDI应用程序
层次结构.
CVeiw< ;-(从CWnd派生的类)

•CWnd类应响应所有大小通知并调整大小
因此.它应该最大限度地利用自己的整个客户
区域.
•该类应能够支持以下接口.
•ShowRectangle()-应该在
内的任何地方绘制矩形 客户区.
•ShowCircle()-第一个参数是
的结构 定义圆的尺寸和颜色.
•全部擦除–清除画布.
•当用户
时,应调用该类中的上述方法 选择Draw->画圆->矩形,绘制->从
删除 菜单.(菜单应动态生成)

我已将CWnd派生的类和一个窗口作为CVeiw的子类实现,并在Mainfrm.cpp文件中添加了它们的动态菜单和汉勒.

现在我的问题是,当在Mainfrm.cpp中处理事件时如何在子窗口的画布上绘制?使用MFC,但我认为一般流程是将值添加到描述形状及其位置的CDocument对象中,然后调用UpdateAllViews().然后,在视图的OnPaint()方法中,在视图上显示相关的形状.


Create an SDI application that incorporates the following object
hierarchy.
CVeiw<-(Class derived from CWnd)

• The CWnd class should response to all size notifications and resize
accordingly. It should maximize itself to utilise the entire client
area.
• The class should be able to support the following interfaces.
• ShowRectangle() - A rectangle should be drawn anywhere within
the client area.
• ShowCircle() - The first parameter being a structure that
defines the dimension and colour of the circle.
• Erase All – Clears the canvas.
• The above methods within the class should be invoked when the user
chooses Draw -> Circle, Draw -> Rectangle, Draw -> Erase from the
menu.(Menu should be generated dynamically)

I have implemented the class Derived from CWnd and a window as child of CVeiw and added dynamic menu and hanlers of them inside Mainfrm.cpp file.

Now my problem is, How to draw on the canvas of child window when events are handled inside the Mainfrm.cpp??

解决方案

It''s some time since I used MFC but I think the general flow is that you add values to your CDocument object which describe the shapes and their location, and then call UpdateAllViews(). Then in your view''s OnPaint() method you display the relevant shapes on your View.


这篇关于如何画儿童帆布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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