CframeWnd在运行时动态自定义CFrameWnd [英] CframeWnd to custom CFrameWnd dynamically at Runtime

查看:76
本文介绍了CframeWnd在运行时动态自定义CFrameWnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





虽然它很奇怪,但我需要在RUN中动态地将我的MFC SDI的帧窗口类从CframeWnd更改为CMyframeWnd(一个自定义的CframeWnd) -TIME。



你能帮我吗?



谢谢,

Mochenoo

Hi,

Although it is so strange, but I need to change my MFC SDI's frame window class from CframeWnd to CMyframeWnd (a customized CframeWnd) dynamically at RUN-TIME.

Would you help me?

Thanks,
Mochenoo

推荐答案

是的,它看起来很奇怪。降级往往是代码设计不好的标志。



无论如何,这些问题可以通过动态演员来解决,当你不是确定某个对象的确切运行时类型是什么:

http:// en.wikipedia.org/wiki/Dynamic_cast [ ^ ],

http://msdn.microsoft.com/en-us/ library / cby9kycs.aspx [ ^ ]。



如果由于某种原因,你知道那个运行时类型是什么,那就意味着你使用了错误的编译时类型。无论如何,请参阅: http://www.cplusplus.com/doc/tutorial/typecasting [ ^ ]。



-SA
Yes, it looks strange. Down-casting is often the sign of bad code design.

Anyway, such problems can be solved using dynamic cast, when you are not sure what is the exact runtime type of some object:
http://en.wikipedia.org/wiki/Dynamic_cast[^],
http://msdn.microsoft.com/en-us/library/cby9kycs.aspx[^].

If, by some reason, you know what is that runtime type, it means that you are using wrong compile-time type. Anyway, see also: http://www.cplusplus.com/doc/tutorial/typecasting[^].

—SA


这篇关于CframeWnd在运行时动态自定义CFrameWnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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