简体   繁体   English

大型机中的MFC GUI以及nedd GUI的其他DLL

[英]MFC GUI in main frame and other DLLs that nedd also GUI

I have a MFC application which has its GUI implemented as part of the executable code (view-doc architecture etc.) My application uses some DLLs I worte. 我有一个MFC应用程序,它的GUI作为可执行代码的一部分实现(view-doc体系结构等)。我的应用程序使用了一些我喜欢的DLL。

Now I have to write another DLL which I know it has to have a GUI as well. 现在我必须编写另一个DLL,我知道它也必须有一个GUI。

My question/uncertainty is should I implement the GUI as part of the main application (main GUI) and connect between them OR should I implement a GUI as part of the new DLL and just make an entry point in main GUI ? 我的问题/不确定性是我应该将GUI作为主应用程序(主GUI)的一部分来实现,并在它们之间进行连接,还是应该将GUI作为新DLL的一部分来实现,而只是在主GUI中建立入口? In both cases it clear to me that I must have an interface class. 在这两种情况下,我都清楚我必须有一个接口类。

In case I implement a GUI as part of the DLL, it is clear to me that the GUI should hold a pointer to the interface class but how should the interface class talk with the GUI (eg notifies the GUI a long operation is completed or give the GUI intermediate reports about the operation ? 1) using pointer from Interface to GUI? 如果我将GUI作为DLL的一部分实现,则对我来说很明显,GUI应该持有指向接口类的指针,但是接口类应如何与GUI对话(例如,通知GUI长时间的操作已完成或给出了GUI中间报告操作?1)使用从接口到GUI的指针? 2) using message loop with callbacks? 2)使用带回调的消息循环? 3) other options??? 3)其他选择???

Many Thanks 非常感谢

Generally, MFC + GUI stuff in DLL = much needless trouble. 通常,DLL中的MFC + GUI东西=不必要的麻烦。 At least as I recall from ten+ years back. 至少我回忆起十年前的事情。 It has to do with MFC Microsoft-style "support" for something or other that someone at Microsoft imagined could be a problem, so MFC distinguishes between different kinds of DLLs and DLL states and whatnot, in particular with regard to resources. 它与MFC微软风格的“支持”有关,微软想象的某些东西可能是一个问题,所以MFC区分不同类型的DLL和DLL状态等等,特别是在资源方面。

So I'd say, for MFC, keep the GUI stuff in the main program, if at all practical. 所以我会说,对于MFC,如果可行的话,将GUI内容保留在主程序中。

It also has to do with allocation of responsibilities. 它还与责任分配有关。 By separating responsibilities you get a more clean design that is easier to maintain. 通过分离责任,您可以获得更简洁的设计,更易于维护。 Put knowledge of things where it's needed for the responsibilities. 把事情的知识放在责任所需的地方。

Cheers & hth., 干杯&hth。,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM