通过子进程处理子窗口:好的或不好的做法 [英] Handling child window through child proc: good or bad practice

查看:75
本文介绍了通过子进程处理子窗口:好的或不好的做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我是新来的论坛,是C ++的新手,也是Windows原始编程的新手,通过Win32.我想知道处理子窗口消息的最佳方法是什么:注册单个子窗口的效率有多低? proc,以便我可以将整个处理程序封装在一个包中?还是做一些变通的操作,然后将开关添加到已注册的父窗口proc并调用每个子消息处理程序,是否更好?

Hi all.
I''m new to the forum, new to C++ and new to windows raw programming, through win 32. I would like to know what is the best way to handle child window messages: is it any how less efficient to register individual child window proc so that i can encapsulate the whole handler in a package? Or is it better to do a little work around and add a switch to the registered parent window proc and call each child message handler?

推荐答案

我觉得有一个单独的每个窗口的过程函数最好,以防您可能想做一些特定的事情.如果您有一些逻辑要求父级窗口和子级窗口一起工作,则可以将消息发送到父级窗口.如果您只处理诸如WM_CREATE和WM_PAINT之类的常见消息,则可以有一个通用的Window过程.

这只是我的意见,我认为其他人可能对此有更多信息.希望这对您有所帮助.
I feel that having a separate procedure function for each window is best in case you might want to do something specific. Sending a message to the parent window can be done if you have some logic which requires the Parent and the child window to work together. You can have a common Window procedure if you just handle the usual messages like WM_CREATE and WM_PAINT.

This is just my opinion and I feel that others might have more information on this. Hope this helped.


这取决于两者之间有多少共同的行为,但就我个人而言,我认为最好是孩子拥有自己的WinProc,因为这意味着您可以与其他父类一起再次使用子窗口类,这也使它更具可读性.

如果要求父级执行某些操作,则实现发送其父级的消息,因为这样您也可以在父级中获得更具可读性和可重用性的代码.
It depends on how much common behaviour there is between the two but personally, I think it''s best if the child has it''s own WinProc as this means that you can re-use the child window class again with a different parent class, it also makes it much more readable.

Implement messages that it sends it''s parent if it requires the parent to do stuff because this way you have far more readable and reusable code in the parent as well.


这篇关于通过子进程处理子窗口:好的或不好的做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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