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.

Filter by
Sorted by
Tagged with
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 = ...
nothingMaster's user avatar
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? ...
user541686's user avatar
  • 208k
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::...
user25749's user avatar
  • 4,855
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 ...
John M Gant's user avatar
  • 19.2k
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?
Attilah's user avatar
  • 17.8k
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"...
Simsons's user avatar
  • 12.5k
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) ...
SayaliK's user avatar
  • 593
53 votes
12 answers
166k views

Convert MFC CString to integer

How to convert a CString object to integer in MFC.
user avatar
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 ...
magol's user avatar
  • 6,175
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 ...
Christian Ammer's user avatar
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?
Qwertie's user avatar
  • 16.8k
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 ...
Umesha MS's user avatar
  • 2,881
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; ...
Neophile's user avatar
  • 5,780
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 ...
LLucasAlday's user avatar
  • 2,461
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 ...
crashmstr's user avatar
  • 28.3k
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?
Eslam Hamdy's user avatar
  • 7,276
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 ...
Mordachai's user avatar
  • 9,532
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?
Tae-Sung Shin's user avatar
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 ...
claws's user avatar
  • 53.3k
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 ...
Naveen's user avatar
  • 75.7k
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 ...
NTDLS's user avatar
  • 4,813
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 ...
Neophile's user avatar
  • 5,780
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 ...
17 of 26's user avatar
  • 27.2k
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 ...
TWA's user avatar
  • 12.8k
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 ...
GrinderZ's user avatar
  • 674
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, ...
Louis's user avatar
  • 660
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 ...
user1768079's user avatar
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?
user avatar
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 ...
Naveen's user avatar
  • 75.7k
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 ...
darron's user avatar
  • 4,354
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. ...
Laxman Sahni's user avatar
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.
Dharma's user avatar
  • 837
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
Uday's user avatar
  • 829
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 "...
isekaijin's user avatar
  • 19.5k
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); ...
Roman Dobrovenskii's user avatar
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 ...
Stokke's user avatar
  • 1,921
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 ...
vasanth kumar's user avatar
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 ...
Ed.'s user avatar
  • 1,404
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?
RK-'s user avatar
  • 12.2k
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 ...
karthik's user avatar
  • 17.6k
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 ...
User's user avatar
  • 64.3k
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?
ragnarius's user avatar
  • 5,768
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" ...
CodeDoctorJL's user avatar
  • 1,246
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 ...
Joey Eremondi's user avatar
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, ...
digvijay's user avatar
  • 361
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 ...
dragan.stepanovic's user avatar
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?
karthik's user avatar
  • 17.6k
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?
ju.'s user avatar
  • 493
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 ...
titanae's user avatar
  • 2,279
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 ...
user3242337's user avatar

1
2 3 4 5
263