Click here to Skip to main content
15,887,746 members
Everything / Desktop Programming / MFC

MFC

MFC

Great Reads

by Hans Dietrich
XQueue implements a shared-memory first-in first-out (FIFO) queue, based on memory-mapped files, that works on all versions of Windows.
by Paul Vickery
Code to add a message bar to virtually any existing Windows control.
by Hans Dietrich
This series of articles is a step-by-step guide to reading files stored in your program's resources. Along the way I will present some non-MFC classes to assist you in reading text, binary, zip, and even encrypted files that have been compiled into your program as resources.
by Paul M Watt
Guide to understanding how to create and use regions with the WIN32 SDK

Latest Articles

by Ștefan-Mihai MOGA
Task Manager shows you the programs, processes, and services that are currently running on your computer. You can use Task Manager to monitor your computer’s performance or to close a program that is not responding.
by Ștefan-Mihai MOGA
This article is about the IntelliFile application which is a free alternative Windows version to Total Commander and uses many components that have been published on CodeProject.
by Ștefan-Mihai MOGA
An alternative Windows version to XML Sitemap online generators
by PJ Arends
An MFC CWnd derived grid of user definable tiles

All Articles

Sort by Title

MFC 

5 Sep 2001 by Marat Bedretdinov
Shell interfaces in use. IShellFolder, IEnumIDList, etc.
24 Sep 2012 by Member 7909353
Hi,In Visual Studio 2008 -> Visual C++, I create a simple dialog. Afterwards I right click on the project in solution explorer and select "Add Class...", and then the MFC Add Class Wizard pops up. I want my dialog to be a "CMFCPropertySheet", but the Base Class field does not allow me to do...
24 Sep 2012 by Richard MacCutchan
See the note here[^] that states: This page is specific to Microsoft Visual Studio 2012/.NET Framework 4.5
25 Sep 2012 by Member 7909353
CMFCPropertySheet class is avialable in vs 2010,2012 not in vs 2008
4 Feb 2003 by Nicolas Bonamy
Two simple ways to add "Do not ask again" Message Boxes to your application.
16 Aug 2012 by DrBones69
What could be wrong with this? It was working fine and then...Improper Argument.Could it have something to do with deleting records from the array?for(int i = 0; i
16 Aug 2012 by nv3
Your best friend is as in most cases your debugger. But from just looking at the code I would suspect that nItem = m_ListCtrl.InsertItem(0, FirstName[i] + L" " + LastName[i]);might return -1 when not successful (for whatever reason) and the following ...
17 Aug 2012 by DrBones69
I was trying to read my arrays beyond the amount of data that the arrays had stored. This is what I did to fix this issue:s7 = (((_wtof(myData[nPos].m_sPrice7) / _wtof(myData[nPos].m_sQty7)) - _wtof(myData[nPos].m_sCost7)) * _wtof(myData[nPos].m_sQty7)); t7.Format(L"%.2f",...
22 Dec 2009 by Pramooth
Hi All,im new to MFC..just trying to draw circle and rectangle based on user option(if user selects circle then a circle will be drawn).For this, i would like to know whether these drawings can be done inside the formview or we can add only controls inside the formview?tks in...
22 Dec 2009 by Christian Graus
wrote:For this, i would like to know whether these drawings can be done inside the formview or we can add only controls inside the formview?Handle the paint event and you can draw anything you like.To add, why did you ask this three times ? I've deleted the other two.
7 Apr 2023 by Zouaoui Billel
Hello All; I am working on C++/MFC project where I need to use access control device SDK acualy I registred SKD DLL (using regsvr32.exe) to create a controller, after that I Open my MFC project and I added activex controller from the wizard, ...
16 Mar 2023 by Zouaoui Billel
Hello All; I am working on C++/MFC project where I need to consume an active x control, so I create a control like CZKEM1 m_zktecoCtrl; but when I try to invoke it Like bool bConnect = false; bConnect =...
16 Mar 2023 by CPallini
Someone here would (correctly) write: "This is not a good question [...]". As Richard pointed out, at least one argument is expected. You should post here, at least, the Read method prototype in order to get meaningful help. [update] Your...
16 Mar 2023 by Richard MacCutchan
As far as I can see your code should not compile, because of: static BYTE parms[] = VTS_BSTR VTS_I4; The elements of an array should be separated by commas, thus: static BYTE parms[] = { VTS_BSTR, VTS_I4 }; ...
16 Apr 2001 by Igor Sukhov
The ATL and MFC versions of the class that implements a dialog for selecting users(computers) within the Windows Network.
27 Mar 2007 by vishalkmehta
This article demonstrates how to leverage the power of images and inheritance to achieve a "skinned" look for your Windows applications.
19 Sep 2006 by tanvon malik
This article shows you ways to run Control Panel applets from VC++, even those that don't have a cpl extension file.
2 May 2016 by Gayle123
I Created a 64 bit exe and 32 bit com dll ... i did neccesary changes in registry as suggested by some site .. now CoCreateInstance is returning :HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT) : %1 is not a valid Win32 application. HRESULTCould you please let me know why the error...
2 May 2016 by George Jonsson
How did you register your COM dll?By default the 64-bit version of RegSvr32 is used and you need to use the 32-bit version.See https://support.microsoft.com/en-us/kb/249873[^]And here is some general information: Process Interoperability (Windows)[^]
2 May 2016 by CPallini
Unless I misunderstood the documentation, you cannot do that. See Process Interoperability (Windows)[^]:On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.
4 Jul 2012 by manishg440
when i am going for debug after successfully rebuild, i got this problem. Debugging information for 'demo.exe' cannot be found or does not math.Binary was not built with debug information.Please help me.
4 Jul 2012 by barneyman
- Ensure your configuration for that exe is Debug (Build/Configuration Manager)- Ensure your project properties compile debug info (Project Properties/C++/General/Debug Info. Format)- Ensure the linker is linking debug (Project Properties/Linker/Debugging/Generate Debug Info) and lastly...
8 Nov 2011 by codeprojectvijayanand
Hi,I am developing an MFC application which uses CListView control. It is basically a viewer which will read a binary file and display the info read as records. Now I have to implement a feature like goto record number. I dont have any pointers to that. Can you guys hint me on...
8 Nov 2011 by Pranit Kothari
myListCtrl.Set...
13 Nov 2011 by Selva K
WritePrivatePr...
7 May 2012 by chaiein
I am gettingerror C2664: 'midiInGetErrorTextW' : cannot convert parameter 2 from 'char [128]' to 'LPWSTR' How to solve this error?
7 May 2012 by enhzflep
I had similar error message when using GDI+ in a non-unicode app. My filenames were simple char*, yet the load function needed WCHAR*You just need to use MultiByteToWideChar. WCHAR wFilename[MAX_PATH]; string fileName; char *filename; filename =...
7 May 2012 by chaiein
Change the Project properties in character set to Use Multi-Byte Character Set solved my problem
21 Aug 2012 by Maximilien
Changing to state of tree item to BOLD does not change the size of the displayed string.(VS2008, MFC, feature-pack).I created a CTreeCtrl and filled it with some data; the items are "drawn" dynamically with the handle of NM_CUSTOMDRAW and in the CDDS_ITEMPREPAINT, I set the item state to...
21 Aug 2012 by Maximilien
Fix: I had to reset the string of the item after the bold state was set to the item.
31 Oct 2013 by Maximilien
Happy monday.I'm trying to use a GIF or a 8 bpp BMP image image as a source for an OpenGL texture.The code is working well for other types of image (24, 32bits image)I'm loading the file with CImage, but I'm having problems figuring the format and type parameters of the glTexImage2D...
6 Jun 2013 by Maximilien
The bad behaviour was caused by a not-yet fully understood modification in another CDockablePane that messed up the focus; it causes the button to loose the focus and I did not visually see that when I thought I clicked on the button, I was putting the focus back to it; and if I was lucky enough...
4 Mar 2011 by Mr. Tomay
I am wondering how to (Save / Load) a CBitmap object (Into / From) an ".MDB" file as OLE Object.Help me please :((
7 Mar 2011 by Piccadilly Yum Yum
Take a look there :http://bytes.com/topic/c-sharp/answers/869355-saving-image-ole-object[^]
30 Sep 2012 by vaibhavbvp
Hi everybodyi have a problem in converting a audio which is in .dss format.i want to convert it in wave format through code.can anybody help me in converting it without using third party software.
1 Oct 2012 by CPallini
That's difficult, in my opinion, since DSS is a proprietary format and apparently you cannot even find free documentation.It looks you have to a third part library (e.g. Olympus Audio SDK[^]).
17 May 2013 by User 9450691
All of the DVR SDKs I've look at for DSS (or DS2) to WAV conversion use the hardware, i.e. the SDK calls a function hardcoded onto the DVR to do the decryption. So even with a licence you would still need a DVR connected.
15 Nov 2003 by Prakash Kumar Singh
This article explains and demonstrates various ways to implement localization in your .NET application.
2 Nov 2010 by Daniel Ranger
Native C++ implementation of the .NET Asynchronous Design Pattern using Windows I/O Completion Ports
2 Mar 2017 by Prain86
Using VisualStudio WindowsForms Form. Creating Chart control in designer.I'm trying to add some customLabels on charts Axis along WITH the default labels.To do so I add customLabels with RowIndex property =1. Thus I see default labels AND my customLabels.Now the problem is that default...
19 Feb 2004 by Mathias Taylor
Export Microsoft Outlook data using XML DataSets and the Outlook COM Object Library.
9 Dec 2002 by Stoyan Damov
A Draft Implementation of an Idea for .NET Dynamic Software Load Balancing
17 Sep 2004 by Nick Parker
A free IE toolbar that pulls up namespace and class documentation on the new MSDN site.
13 Aug 2002 by Bill Ferreira
File encryption object using Managed Extensions for C++
2 May 2013 by npdev13
I am new in VC++ and MFC, I am creating one application in the MFC with VC. I found that when I build the project it create the .obj file for .cpp file in the debug folder.Now my question is when I am doing deployment of this project I require to include this .obj file? because I found that...
2 May 2013 by Ian A Davidson
No you don't need it for executing the application. It is an intermediary object file, used by the linker to make the executable. It is common practice to specify a directory for the intermediary files that is different from the output directory, in order to make clean-up and deployment...
28 Jul 2013 by P Uday kishore
Hi i need to get the file details of .url file(.ie internet explorer favorites file format).I can get the details like created date,accessed date and all but am not able to get the URL of that. Can anyone help me regarding this way???
28 Jul 2013 by Richard MacCutchan
you could start with Internet Explorer Favorites, deconstructed[^].
28 Jan 2011 by Mike Marquet
Hello to everyone,I have a little question about .URL file (a shortcut file that linked to a web page).How can I programmatically retrieve the URL from this file using MFC/C++ ?How can I programmatically write an URL to a file ?[edit]In explorer, I right click and create new...
27 Jan 2011 by Richard MacCutchan
What do you mean by "retrieve the URL from this file"? Which file are you referring to? If you have the information stored in a text file then you can use the standard library fstream or the MFC CFile to access it.
28 Jan 2011 by Richard MacCutchan
OK, you want to read and write shortcuts, try How to create and resolve a shortcut[^], a nice CodeProject article.
28 Jan 2011 by Richard MacCutchan
Create a text file with content similar to the following:[InternetShortcut]URL=http://www.codeproject.com/and save it with a ".url" extension.
19 Dec 2011 by snavece
I have inherited some older MFC code. That I am updating and maintaining. It has a form of comment in from of most methods and global declararions of //##ModelId=xxxxxxxxxxxx. I am wondering what the use of ModelId is/was?I suspect that they are left over from some IDE or wizard that used...
19 Dec 2011 by fjdiewornncalwe
It is commented out which means it won't be compiled which means it is useless unless it is there to describe the functionality of some code that is not commented out. The easy way to find out is to remove these instances and see if the code still compiles and runs properly.
29 Oct 2012 by Virendra_ec10
Hello C++ Gurus,I created a 64-bit COM DLL by compiling a 32-bit application in visual studio 2010(Mode-Release, Platform-x64) and registered it successfully using Regsvr32.exe tool.I am trying to create the instance of the dll but, I am getting "Class Not registered " error in the below...
29 Oct 2012 by enhzflep
I'm still(hopefully will remain?) pretty wet-behind-the-ears with respect to COM work. Though I do note that the behaviour you report is the same as that which I observe when starting a 32bit COM server under either windows xp or 7.That is to say CLSIDFromProgId does just that - it returns...
11 Jul 2013 by Dattatraya Mengudale
Please refer..http://www.gfi.com/blog/32bit-object-64bit-environment/It will really solve your problem...
12 Jul 2013 by PrafullaVedante
If you are trying to create a COM object from a 32 bit dll/exe , then your 64 bit com object cannot be instantiated . Because Windows maintain separate entries for 32 bit and 64 bit COM objects. Hence make sure that your COM object and your container application belongs to same architecture...
19 Jan 2015 by Vamsi Krishna
2)and i want that the string to be in a loop because no.of queries have to be executed and to store the data in that string? 3) while executing the each loop data should be updated in another string ? 4) finally the data stored in a string should be thrown out??? Here, iam just showing...
28 Jan 2013 by fraudlabs
solution to prevent chargebacks and to reduce fraud for online merchants
19 Jan 2003 by peterchen
Setting up doxygen, a free tool to document your code, in a few simple steps.
11 Aug 2014 by Mahdi Nejadsahebi
in the name of allahhave a good timei work with visual C++2012can you tell me how can i fix the below error?1>LINK : fatal error L1025: nested left parenthesesthanks
1 Oct 2013 by Mohamed Kalmoua
2-3 tree implementation in c++
24 Jan 2005 by darkoman
An article on creating 2D animated charts using Windows GDI.
7 Jan 2011 by Prasenjit Samanta
I have an image of type IplImage *imgI captured all image value from img to an integer matrix a[][].Now i want to plot each matrix index value to an groupbox area.How do i do that?thanks in advance
20 Jul 2012 by Sunil P V
This article is a simple geometry library for drawing lines, circles, arcs, text, etc.
19 Oct 2007 by Chesnokov Yuriy
This article demonstrates the use of 2D Fast wavelet transform for image processing
5 Aug 2003 by Nikolai Teofilov
An ActiveX control for 2D data visualisation
14 Apr 2014 by auralius manurung
An article on designing your own robot simulator
7 Jan 2003 by valgouss
A simple 2D Pie Control
6 Apr 2005 by asef
An article for drawing a String formula at a static.
22 Aug 2011 by steveh2112
hi, my 32 bit MFC app, developed on windows 7 32 bit with VS2010 has some stability problems running on 64 bit windows machine. i don't have access to a 64 bit machine at the moment but i have a very helpful customer who has isolated some of the issues.he says the problem my be in the...
22 Aug 2011 by Richard MacCutchan
The default location for 32 bit programs is Program Files (x86); other than that a 32 bit application should run without any other changes on 64 bit.
30 Jan 2012 by chaiein
Hi I need to develop 3D shooter game. I have knowledge on visual studio c++ mfc,dark gdk,little javascript . please give me resource of sample shooter game code using any of these tools to learn. Or Please suggest me if any good game development engines that can be learnt soon and where many...
31 Jan 2012 by JackDingler
You might try Garage Games. The developers there used to work for Sierra Arts. They have a fairly mature development engine for a reasonable price.
6 Feb 2012 by chaiein
We can also develop games using Dark GDk whether its 3d or 2d and even the samples are provided which we can develop further.for more information check this site.www.thegamecreators.com
17 Feb 2002 by John Aspras
Ever seen 3D Studio 2.5 Slidable DialogBar? Want to know how they did it?
17 Feb 2009 by MikeTheDwarf
Helper class to display 3D data
6 Jun 2005 by asef
An article to draw a 3D math function on a static control.
10 Sep 2013 by Pablo Aliskevicius
Memory reallocation generated by string concatenations can create performance bottlenecks. .NET has System.Text.StringBuilder, JavaScript has Array.join, and we have string::reserve.
10 May 2017 by Petrov Vladimir
Former NeHe OpenGL Lessons adapted to MSVS-15 pro MFC in INICODE and the samples of the Joystick implementation
25 Jan 2012 by ilostmyid2
hii've a CScrollBar object in my class. i create it by using its Create function. it appears and works well. but it's an old style (Windows 2000 theme) scrollbar. how can i replace it with a new style (Windows XP blue theme) scrollbar?now i'm going to ask the same in another words and this...
25 Jan 2012 by Espen Harlinn
Have a look at Using Windows XP Styles in your MFC/WIN32 Applications[^]That should solve your problem :)Best regardsEspen Harlinn
26 Jan 2012 by ErnestoNet
At the end of stdafx.h, add the following code:#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")Hope it helps.
2 May 2012 by ilostmyid2
hithere's a member function for adding items to a property grid property when the property is treated as a combo box called AddOption. there's also another member function for setting data to the property. but, like an ordinary combo box which has the ability to set data for every item...
19 Dec 2012 by ilostmyid2
hilook at the following property sheet:[^]the property page is created from a resource template with size 2x2! it seems that a property page can't have size less than a special value. in another words there's a minimum size in width and height which the dimensions of a property page...
19 Dec 2012 by Richard MacCutchan
You need to find a property or function in the class that you can change or override; check the documentation[^] to see if it's possible. If such a feature is not available then you probably need to look into the possibility of subclassing[^] the control.
1 May 2015 by ilostmyid2
hii create a CDockablePane as well as a CView in the main frame of my application. i need the pane not to get focused. this causes the active view to lose focus and doesn't receive keyboard events anymore. the pane consists of tool boxes. they're dragged into the view. but the pane and its...
6 Jun 2014 by ilostmyid2
hiIn an MDI program written in C++, I've this problem. When a new document is creating, it's view is shown repeatedly with different sized until it gets its final size. I put TRACE in OnSize of the corresponding child frame and got the following...
6 Jun 2014 by Sergey Alexandrovich Kryukov
Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it...
12 Jul 2014 by ilostmyid2
hii've a dockable pane in my program with three child windows, a tab ctrl and two toolbox-like windows. since my program's window may be resized by user, the dockable pane should have vertical and horizontal scrollbars which have to get visible when required, so that the tools may be exposed...
12 Jul 2014 by Richard MacCutchan
You need to study the message and notification handling process for these controls. When a scrollbar is clicked or moved, it sends a notification message to its parent window, so that window needs to handle the message and repaint itself according to the direction and amount of scrolling. As to...
24 Jul 2014 by ilostmyid2
in the following project:https://dl.dropboxusercontent.com/u/4829119/930502%20-%20t3.zip[^]i wonder why scrollbars of my view appear, but are disabled. how can i make my view's scrollbars act properly like other views?click on scrollbars are received by my view instead!related...
26 Jul 2014 by ilostmyid2
i found the reason: i had to change class name of my view from Static to Message when creating it.
23 Oct 2014 by Sergey Alexandrovich Kryukov
As your report mention that you "changed the code somehow", I know exactly how to help. You need to fix the code somehow. :-)—SA
28 Nov 2014 by ilostmyid2
hii want to use CArchive for storing data structures into buffers and loading them from it. no file is involved.is it possible?i think i should derive a class from CArchive and override > operators.
28 Nov 2014 by KarstenK
You better NOT use CArchive, but write data in a file. If you use the standard file API of C likefopen you get portable code.If you write a struct you use write and you are done.plz dont use CArchive ;-)
28 Nov 2014 by Richard MacCutchan
If you are only keeping data in memory then why do you need something as complicated as a CArchive? Use one of the STL container classes[^].
28 Nov 2014 by CPallini
I guess you may use a CMemFile[^] pointer in the CArchive constructor.
11 Sep 2013 by kaushik4study
Hi guys.I am not here wrirting complete code but just giving you some details.And if somebody knows the thing you can send me link or hiint. More important i have done google it could not find solution for it.My case: I am using my own software (company's product) for accesing some video...