Questions tagged [mfc]
This tag should be used for questions concerning Microsoft Foundation Class Library (MFC), a C++ framework for Windows desktop GUI application programming. You should specify a tag for the version of C++ or Visual Studio being used. Due to the size of MFC, additional tags such as [com], [wininet], [winapi] or other subject matter tags are helpful.
13,114
questions
137
votes
6
answers
224k
views
LPCSTR, LPCTSTR and LPTSTR
What the difference between LPCSTR, LPCTSTR and LPTSTR?
Why do we need to do this to convert a string into a LV / _ITEM structure variable pszText:
LV_DISPINFO dispinfo;
dispinfo.item.pszText = ...
120
votes
3
answers
38k
views
What's the fundamental difference between MFC and ATL?
Assuming I am only using them for "normal" GUI programs (no COM, no ActiveX, nothing fancy), what is the fundamental difference I will see between ATL and MFC, to help me figure out which one to use?
...
93
votes
16
answers
264k
views
How do you convert CString and std::string std::wstring to each other?
CString is quite handy, while std::string is more compatible with STL container. I am using hash_map. However, hash_map does not support CStrings as keys, so I want to convert the CString into a std::...
78
votes
6
answers
50k
views
How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project?
I'm just starting my first C++ project. I'm using Visual Studio 2008. It's a single-form Windows application that accesses a couple of databases and initiates a WebSphere MQ transaction. I basically ...
62
votes
9
answers
191k
views
Convert CString to const char*
How do I convert from CString to const char* in my Unicode MFC application?
62
votes
1
answer
129k
views
How do I call a static method of another class
I have a class, lets say CAppPath which has a static method:
public:
static CString GetAppPath();
and in CAppPath.cpp it's defined as:
CString CAppPath::GetAppPath()
{
return "C:\..\MypAth"...
59
votes
9
answers
91k
views
error Please #define _AFXDLL or do not use /MD[d] occurs even after making changes in Project Properties
I am working on Win32 project in Visual Studio 2011. It is generating MFC error when I includes afx.h or afxwin.h.
To resolve this, I have made the following changes in the Project Properties tab :
1) ...
53
votes
12
answers
166k
views
Convert MFC CString to integer
How to convert a CString object to integer in MFC.
50
votes
11
answers
51k
views
C++ MFC vs .NET?
My colleagues are using Visual Studio 2002 and uses the C++ MFC. I am developing in C #.
It has not been any problems before, but now questioning our customers if we really should develop in ...
50
votes
2
answers
42k
views
Which Font is the default for MFC Dialog Controls?
The picture below (enlarged, so you better see the differences) shows Font differences between dynamically created Edit controls (the upper two examples) and Edit Controls created from the Dialog ...
47
votes
4
answers
12k
views
What's with the "Afx" in StdAfx.h?
I'm just curious what Afx stands for. And what about Fx in FxCop?
45
votes
3
answers
48k
views
What is the difference between BOOL and bool?
In VC++ we have the data type “BOOL” which can assume the value TRUE or FALSE, and we have the data type “bool”, which can assume the value true or false.
What is the difference between them and when ...
37
votes
4
answers
43k
views
Error LNK2019 when using GetFileVersionInfoSize()
I just included this bit in my already working code, but I am getting an LNK2019 error. I'll paste the error after pasting the code.
The Class CAboutDlg has:
public:
CStatic m_VersionInfoCtrl;
...
37
votes
4
answers
42k
views
How to detect a CListCtrl selection change?
I want to execute some code when the user selects a row in a CListCtrl (report view, I don't care about the other viewing modes).
How do I catch this event? is there some message I can map or a ...
36
votes
5
answers
27k
views
App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions
Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry ...
33
votes
4
answers
128k
views
How can I convert an Int to a CString?
I can convert a Double to a CString using _ecvt
result_str=_ecvt(int,15,&decimal,&sign);
So, is there a method like the one above that converts an int to CString?
33
votes
8
answers
17k
views
How do I force windows NOT to redraw anything in my dialog when the user is resizing my dialog?
When the user grabs a corner of a resizable window, and then moves it, windows first moves the contents of the window around, then issues a WM_SIZE to the window being resized.
Thus, in a dialog ...
32
votes
6
answers
123k
views
How to format date and time string in C++
Let's say I have time_t and tm structure. I can't use Boost but MFC. How can I make it a string like following?
Mon Apr 23 17:48:14 2012
Is using sprintf the only way?
32
votes
3
answers
33k
views
Is there a Designer for MFC in Visual Studio like for windows forms in .NET?
I'm a .NET programmer. I've never developed anything in MFC. Currently I had to write a C++ application (console) for some image processing task. I finished writing it. But the point is I need to ...
31
votes
13
answers
9k
views
Why STL containers are preferred over MFC containers?
Previously, I used to use MFC collection classes such CArray and CMap. After a while I switched to STL containers and have been using them for a while. Although I find STL much better, I am unable to ...
31
votes
8
answers
21k
views
Is MFC still used for new development (with any material volume)?
I've never been a big fan of MFC, but that's not really the point. I read that Microsoft is due to release a new version of MFC in 2010 and it really struck me as odd - I thought MFC was dead (no ill ...
31
votes
2
answers
73k
views
Redefining or changing macro value
I am currently working on an already developed project written in MFC C++ and am facing a problem with an already present macro having the definition:
#define HEIGHT_TESTS 13
I am trying to change ...
31
votes
5
answers
10k
views
What are some techniques for migrating a large MFC application to WPF/.NET?
I am currently working on a very large legacy MFC MDI application. It has a large number of UI elements - dockable toolbars, custom tree controls, context menus, etc. It is an image processing ...
30
votes
15
answers
6k
views
Ever done a total rewrite of a large C++ application in C#? [closed]
I know Joel says to never do it, and I agree with this in most cases. I do think there are cases where it is justified.
We have a large C++ application (around 250,000 total lines of code) that uses ...
30
votes
15
answers
36k
views
VS2008: "Resource file opened in another editor"
But it's a lie!
Good day to all!
I have the following problem: when I try to open the resource file PriceCalculationUI.rc Visual Studio 2008 tells me that the file is opened in another editor (in ...
30
votes
4
answers
52k
views
MFC development in vs2017
When I installed vs2017, I did select Windows development with C++ option. After installation, however, I don't see the MFC has been added. Sure enough, I get errors when I compile my application,
...
29
votes
3
answers
67k
views
What is `CString`?
Why do I see some code using CStrings declared differently.
Some use this format
char a_c_string [];
While others use
CString another_c_string;
Is there a difference? All the references I have ...
29
votes
7
answers
60k
views
How to create a resizable CDialog in MFC?
I have to create a dialog based application, instead of old CFormView type of design. But CDialog produces fixed-size dialogs. How can I create dialog based applications with resizable dialogs?
29
votes
8
answers
4k
views
Disallowing creation of the temporary objects
While debugging crash in a multithreaded application I finally located the problem in this statement:
CSingleLock(&m_criticalSection, TRUE);
Notice that it is creating an unnamed object of ...
29
votes
2
answers
14k
views
Using a Qt-based DLL in a non-Qt application
Am I doing it right?
A client of mine has a group where I'm developing Qt-based client-server stuff with a lot of fun widget stuff and sockets.
Another group within the company wants to use a ...
28
votes
6
answers
34k
views
How to prevent MFC dialog closing on Enter and Escape keys?
I know one method of preventing an MFC dialog from closing when the Enter or Esc keys are pressed, but I'd like to know more details of the process and all the common alternative methods for doing so.
...
28
votes
4
answers
72k
views
Split functionality for MFC Cstring Class
How to Split a CString object by delimeter in vc++?
For example I have a string value
"one+two+three+four"
into a CString varable.
27
votes
5
answers
46k
views
#error WINDOWS.H already included. MFC apps must not #include <windows.h>
I am getting #error WINDOWS.H already included. MFC apps must not #include windows.h
But i dont know how do i find out because of which file this is happening
Thanks
27
votes
3
answers
5k
views
Creating a professional-looking (and behaving!) form designer
When I began programming (some 10+ years ago), three things amazed me:
Compilers/interpreters (back then I knew them as "programs that make my programs work", often followed by the qualifier "...
27
votes
1
answer
2k
views
Menubar + Commandbar on WM 5.0 and WM 6.5.3
I'm developing a Windows Mobile application, and I faced a problem with CCommandBar, which combines toolbar and menubar. Well, I mean the following:
m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME);
...
26
votes
5
answers
59k
views
Why #pragma optimize("", off)
I'm reviewing a C++ MFC project. At the beginning of some of the files there is this line:
#pragma optimize("", off)
I get that this turns optimization off for all following functions. But what ...
26
votes
5
answers
31k
views
"binary was not built with debug information " warning meaning in mfc application?
I am getting the following Warning when i run my Windows Application(MFC) in Windows 7.
'XXX.exe': Loaded 'C:\2010\Debug\bin\plugins\control\libhotkeys_plugin.dll', Binary was not built with debug ...
26
votes
9
answers
4k
views
Where is a good place to start programming GUIs for windows? [closed]
I have experience writing console and network client/server applications in C and C++, but I know next to nothing about using the win32 visual API, MFC, Qt, wxWidgets, etc. Where is a good place to ...
25
votes
6
answers
13k
views
Difference between a C++ exception and Structured Exception
Can someone explain the difference between a C++ exception and a structured exception in MFC?
25
votes
4
answers
43k
views
How to get the command line arguments in MFC applications?
I wish to have a small dialog based application which is passed command line parameters, so, using VC++6 I ran the application wizard and chose an MFC dialog application.
This is not automatically ...
25
votes
4
answers
25k
views
MFC: std::string vs CString?
Using C++ with MFC. Coming from a C# background I typically just use string for all, well, strings. I use them for class members, method parameters, and method return values.
Now in C++ I've got ...
25
votes
2
answers
38k
views
How to set compile flag /bigobj in visual studio?
I have a cpp file that contains a huge array.
I get a fatal error (exceeded object file format limit) and the suggestion to compile with the flag /bigobj
Where do I set this flag in visual studio?
25
votes
6
answers
158k
views
error MSB3073: How do I fix this?
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\Release\EnergyLib.dll" ...
24
votes
10
answers
38k
views
Windows 7: how to bring a window to the front no matter what other window has focus?
I'm implementing a task-bar replacement, dock-like application-switcher style program. It's doing some unique stuff with OpenGL, and with keyboard shortcuts, so the way it's set up, the window doesn't ...
24
votes
4
answers
37k
views
how to terminate a process created by CreateProcess()?
I have created a process using CreateProcess(). This is the code:
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
result = CreateProcess("C:\\AP\\DatabaseBase\\dbntsrv.exe", NULL, NULL, NULL, ...
23
votes
2
answers
66k
views
How to get size and location of a control placed on a dialog in MFC?
I've got the pointer to the control with function
CWnd* CWnd::GetDlgItem(int ITEM_ID)
so i've got CWnd* pointer which points to the control,
but simply can't find any method within CWnd class that ...
23
votes
1
answer
29k
views
How to Set the Initial Focus of the control in the particular window?
I created an application in which I use window procedure to keep track of all the controls in the window.
My question is, how do I initially set the focus to the first created control in the window?
23
votes
2
answers
28k
views
DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR, ULONG_PTR When, How and Why?
I found that Windows has some new Windows Data Types
DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR, ULONG_PTR
can you tell me when, how and why to use them?
23
votes
7
answers
14k
views
Unit testing MFC UI applications?
How do you unit test a large MFC UI application?
We have a few large MFC applications that have been in development for many years, we use some standard automated QA tools to run basic scripts to ...
22
votes
4
answers
46k
views
MFC does not support WINVER less than 0x0501
I have a C++ project that references many other projects/libraries. This is for an application that was created many years ago. About every once a year it is updated and a new version is done. I've ...