• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Basic MFC problems - Newbie.

Hi! Everybody.
My problems are as follows:

1). "Shared or Statically Linked MFC?"

While making a MFC application using the App Wizard, in the 5th step (Visual C++ 5.0), it asks ::
=====
How would you like to you the MFC library?
1). As a shared DLL?
2). As a statically linked library?
=====

What are these options and how can they affect the development of my project? Also when can I use them (i.e. are there any restrictions on when can I use one method over the other and vice-versa).

2). While studying the code, I came across the following lines::
======
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
======
While studying the Documentation, I learned that in Visual C++ _MSC_VER = 1100. That's fine. But what I could not understand is the explanation for the line #pragma once -> Specifies that the file, in which the pragma resides, will be included (opened) only once by the complier in a build.
What does this mean? And why are these lines included in the header files for the application? What if I change the source code for the header files?

3). What do these lines in the resource script mean?
=====
#if !defined (AFX_RESOURCE_DLL) || defined (AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif // _WIN32
[other program lines]
#endif
=====

4). Let's imagine that I create a Dialog based application using the MFC AppWizard named MFCSample.
It creates the following files:
MFCSample.cpp, MFCSample.h
MFCSampleDlg.cpp. MFCSampleDlg.h
stdafx.cpp. stdafx.h
Resource.h, MFCSample.rc
MFCSample.rc2, MFCSample.ico
ReadMe.txt

In MFCSampleDlg.h file we are referencing an identifier
enum {IDD = IDD_MFCSAMPLE_DIALOG} ;
defined in resource.h but we are not including this file in the MFCSampleDlg.h whereas the opposite is happening in MFCSample.h file

5). Upon seeing the documentation for WS_EX_APPWINDOW extended Window Style, it says that this style forces top-level window to be minimized. What does this mean?

===============================================
Thanks in advance.
0
NoviceAndGood
Asked:
NoviceAndGood
1 Solution
 
JPMartineauCommented:
1) Regarding the statically or dynamically linked MFC: if you choose static link, the MFC lib will be linked to your project (increasing its size). If you choose dynamic link library, the application will require the mfc DLLs
(MSVCRT.dll, etc.). I am a strong supporter of dynamic linking, since I often create many MFC apps (which would be much larger!), but both have their benifits.

2) Sorry, can't help you here. I've always kinda ignored this... I figure it's somekind of backward compatibility stuff...

3) This is used to specify which version of the resources you are using. When you create a resource (Dialog or String table), you have the choice of defining it to be English, French, etc.

Your application actually only uses one of those (You can re-compile to make a french or italian version)

4) The line
enum {IDD = IDD_MFCSAMPLE_DIALOG};
is enclosed in a block:
// Dialog Data
      //{{AFX_DATA(CDialogEditGame)
      enum { IDD = IDD_MFCSAMPLE_DIALOG };
      ...
      //}}AFX_DATA

I figure that the MFC mechanisms [AFX_DATA(CDialogEditGame)] include the resources somewhere.

5) This actually means that a window with this Window Style will be visible in the taskbar when it (the window) is visible. Therefore, it is usually the main application window that has that style

Hope I helped you understand a bit more...

JPM
0
 
JPMartineauCommented:
sorry, forgot to check "Answer"

1) Regarding the statically or dynamically linked MFC: if you choose static link, the MFC lib will be linked to your project (increasing its size). If you choose dynamic link library, the application will require the mfc DLLs
(MSVCRT.dll, etc.). I am a strong supporter of dynamic linking, since I often create many MFC apps (which would be much larger!), but both have their benifits.

2) Sorry, can't help you here. I've always kinda ignored this... I figure it's somekind of backward compatibility stuff...

3) This is used to specify which version of the resources you are using. When you create a resource (Dialog or String table), you have the choice of defining it to be English, French, etc.

Your application actually only uses one of those (You can re-compile to make a french or italian version)

4) The line
enum {IDD = IDD_MFCSAMPLE_DIALOG};
is enclosed in a block:
// Dialog Data
//{{AFX_DATA(CDialogEditGame)
enum { IDD = IDD_MFCSAMPLE_DIALOG };
....
//}}AFX_DATA

I figure that the MFC mechanisms [AFX_DATA(CDialogEditGame)] include the resources somewhere.

5) This actually means that a window with this Window Style will be visible in the taskbar when it (the window) is visible. Therefore, it is usually the main application window that has that style

Hope I helped you understand a bit more...

JPM
0
 
akalmaniCommented:
Hi !!
 I agree with the answers that are given and its just an extension to question 3 and 4

3) The language option is for the localisation. U can have the resources which has all the languages in one DLL and load only the particular language resource depending upon which language u have set for application's thread.

4)There are 2 separate compilers for Visual C++. One which compiles the code and other is the Resource compiler. The resource.h is included for both the Code compilation and the reource compilation.  Both the .obj(Code compiler output) and .res(Resource compiler output) are linked by the linker to build the final .exe. For more information u read the "Inside Visual C++ " by David Kruglinski
The enum ID is the Dialog ID.

Hope this helped u
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
NoviceAndGoodAuthor Commented:
Dear JPM,
             Thanks for the answer. Could you also tell me the difference between selecting the Debug mode, Relaese mode, and All Configurations mode as stated in the project settings dialog. Also how can these affect the development of my project.

Thanks.
0
 
JPMartineauCommented:
There are 2 modes when you compile an app: Debug and Release. You can add as much as you like, though.

Basically, these different configurations define how the application will be built:

Debug:
This is the mode in which you develop your application. The optimisations are turned off, the debug info helps you to debug, some functions are added (ASSERT(), TRACE(), etc...)

Release:
This is the mode which you use to ship your product: code is optimized, no debug info is included, basically, it is smaller & faster, but you can't really debug it.

When you select debug mode, you see/set the settings that are specific to the debug mode. When you select the release mode, you edit the settings that are specific to the release mode. If you select configurations, you can edit settings that are common to all (debug & release) configurations.

Nothing prevents you to add other configurations...  It could be useful to have a mode that is based on the release mode but with the debug info turned on... But for most cases, the 2 defaults are enough...
0
 
mikeblasCommented:
JPMartineau> the application will require the mfc DLLs (MSVCRT.dll, etc.).

MSVCRT.DLL is not an MFC DLL.

..B ekiM
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now