简体   繁体   English

我如何 go 关于这个程序?

[英]How do I go about this program?

I have a program that has a lot of.cpp, .h and.dfm files.我有一个包含很多.cpp、.h 和.dfm 文件的程序。 I have just recently started learning about Visual C++ with MFC.我最近刚刚开始学习 Visual C++ 和 MFC。 The program doesn't have any.ncb or solution object files, because of which I am unable to understand as to how to start understanding the program.该程序没有任何.ncb 或solution object 文件,因此我无法理解如何开始理解该程序。 There are lots and lots of files and its quite confusing to understand the flow.有很多很多的文件,理解流程非常混乱。 There are two folders as well.还有两个文件夹。 One with.ac files and the other with text files.一个带有 .ac 文件,另一个带有文本文件。 Could anyone suggest me an easier way to start off?谁能建议我一个更简单的开始方法? Eventually, after looking at this program's code, I have to create my own program which is kind of similar to this but with added functionality.最终,在查看了该程序的代码之后,我必须创建自己的程序,该程序与此类似,但具有附加功能。

Kindly help please.请帮忙。

Cheers.干杯。

While I dont use C++ Builder, but .dfm suggest it is for other IDE than Visual C++.虽然我不使用 C++ Builder,但.dfm建议它适用于其他 IDE 而不是 Visual C++。 My hints would be:我的提示是:

  • Possibly it is the same source code for multiple IDEs.可能它是多个 IDE 的相同源代码。 Quite possible that all source files are not applicable for all IDEs.很可能所有源文件都不适用于所有 IDE。 They are selectively added for different IDEs.它们是针对不同的 IDE 有选择地添加的。 Some core files might be added for all projects (ie for in .SLN , .DSW , .VCPROJ , .DFM可能会为所有项目添加一些核心文件(即在.SLN.DSW.VCPROJ.DFM
  • If it is really MFC project, search for: CWnd , CWinApp , InitInstance , CString , OnInitDialog , BEGIN_MESSAGE_MAP , ON_WM_ , afx_msg etc.如果真的是 MFC 项目,搜索: CWnd , CWinApp , InitInstance , CString , OnInitDialog , BEGIN_MESSAGE_MAP , ON_WM_ , afx_msg等。
  • In MFC project, there is no main or WinMain - program starts at InitInstance .在 MFC 项目中,没有mainWinMain - 程序从InitInstance开始。

It is hard to gain knowledge of big VC++ project, and understanding MFC code would be quite troublesome for beginner! VC++大项目的知识比较难学,看懂MFC代码对初学者来说比较麻烦!

Some tips:一些技巧:

Use the Find in Files button to find the characters main .使用 Find in Files 按钮查找字符main If you find a main(), an _tmain(), or a WinMain this will tell you a lot about what you have.如果你找到一个 main()、一个 _tmain() 或一个 WinMain,这将告诉你很多关于你所拥有的东西。 If there's an exe, run it - that will show you what to look for also.如果有一个 exe,运行它——它也会告诉你要寻找什么。

Visual Studio 2010 has an option to create a solution from source files, so that may also help you. Visual Studio 2010 具有从源文件创建解决方案的选项,因此这也可能对您有所帮助。

If you think it's an MFC app, look for the View class, the Document class and so on.如果您认为它是 MFC 应用程序,请查找查看 class、文档 class 等。

In Visual Studio 2010 Navigate To (Ctrl,) is super helpful - using mixed case words in your search term will do a very clever search.在 Visual Studio 2010 中,导航到 (Ctrl,) 非常有用 - 在您的搜索词中使用大小写混合的单词会进行非常巧妙的搜索。 So if you run it and see a button labelled Open Policy, then you search with Navigate To for OpenPolicy, it will find PolicyOpen and OpenNewPolicy and plenty more that Find in Files would not.因此,如果您运行它并看到一个标有 Open Policy 的按钮,然后您使用 Navigate To 搜索 OpenPolicy,它将找到 PolicyOpen 和 OpenNewPolicy 以及更多 Find in Files 找不到的内容。

Good luck!祝你好运!

People are answering what IDE the project uses, I don't think figuring that out helps you understand what's going on in the project.人们正在回答项目使用的 IDE,我认为弄清楚这一点并不能帮助您了解项目中发生了什么。

For reading the project, the path I might follow would be go through the calls in WinMain as a debugger, you need to go step by step to see what actually happens.为了阅读项目,我可能会遵循 go 作为调试器通过 WinMain 中的调用,您需要逐步 go 以查看实际发生的情况。 Not Ad, but I find Source Insight is helpful on reading bunches of source files.不是广告,但我发现Source Insight有助于阅读大量源文件。 Or if you're familiar with cygwin, the basic "find & grep" is also handy but powerful tools to help you go through source files.或者,如果您熟悉 cygwin,基本的“find & grep”也是方便但功能强大的工具,可通过源文件帮助您 go。

To learn MFC, my own learning experience is create simple project and write code yourself.学习MFC,我自己的学习经验是自己创建简单的项目,自己写代码。 Don't rely too much on the IDE, although it has some fancy automation staff, such as double clicking on the control in UI design view and it automatically generates message handlers for you, but IMHO it does not help you to understand how MFC registers/handles this message.不要过分依赖 IDE,虽然它有一些花哨的自动化人员,例如在 UI 设计视图中双击控件,它会自动为您生成消息处理程序,但恕我直言,它并不能帮助您了解 MFC 是如何注册的/处理此消息。 Write your own message handler and register it manually, will give you a better idea on why and how it works.编写您自己的消息处理程序并手动注册它,会让您更好地了解它的工作原理和方式。

Hope this helps.希望这可以帮助。

Create new Project in Visual Studio and then add that files to project.. then press CTRL+F5 and Bulid Project.在 Visual Studio 中创建新项目,然后将该文件添加到项目中。然后按 CTRL+F5 和 Bulid 项目。

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

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