A question about #include

zhaozj2021-02-08  236

A question about #include Zhao Xiangning question: I tried to include a header file in the project's resource file. To this end, add the following line code in the.rc file: #include "myfile.h", although there is no problem, each time it opens the resource in Visual Studio, it removes this line of code. The reason why I want to include this header is because I want to use a third-party defined menu item ID number. Solution: The annoying IDE environment is sometimes always having fun with your code, do you say? Please don't be afraid, Mo Gao is one foot, a high high, and there is always a way to solve it for this problem. When opening the .rc file, the APP Studio (the old name of the Visual Studio Resource Editor) is handled by this file. When you store a file, it does not re-generate this file and saved. In particular, App Studio likes to have one and only one header file contains all resource symbols defined. Usually, this file is resource.h, but you can change the name of this file by right-click on MyApp and select "Resource INCLUDES". When App Studio is written to the resource file, it generates one and only one #include statement. Any additional #include that is knocked into the hand is to be deleted as before. Can the eight dialogs are handled by Dialog Margins? of course can. You may notice that App Studio embeds your own information into the resource file. For example, you may have created a border dialog (as shown in Figure 8). Do you know which app studio exists in the sideline size? There is no statement of the dialog box because it doesn't have a Margins option. In fact, App Studio has a special segment of this information: //

#ifdef apstudio_invoke

Guidelines DesignInfo Discardable

Begin

IDD_MYDIALOG, DIALOG

Begin

Leftmargin, 8

Rightmargin, 502

TopMargin, 8

Bottommargin, 273

End

End

#ENDIF // APSTUDIO_INVOKED

// APSTUDIO_INVOKED is defined when App Studio is processed .RC file, not when it is used to compile it in the usual resource compiler. The resource compiler will not understand the meaning of "guidelines"; only app studio will understand. Why is #include's question involve "guidelines"? Because the answer to this problem relies on APSTUDIO_INVOKED. All the work you have to do is just in the form of the file to be included #include: //

#ifndef apstudio_invoke // if not defined

#include "myotherheader.h"

#ENDIF

// App Studio is running because of APSTUDIO_INVOKED, so it ignores your #include. But when there is no apstudio_invoked, the RC compiler will compile your #include file. Also - is also the most important point --apply, you protect your #include statement when it stores your .rc file. It recognizes: "This #ifndef here is not mine, so I think it is best not to delete it ..." If your curiosity wants to know why App Studio always wants to add the code added like it - That is Another story! Let's talk about it next time.

转载请注明原文地址:https://www.9cbs.com/read-1621.html

New Post(0)