Click here to Skip to main content
15,889,889 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 

30 May 2012 by anscode
This post describes a slider control for C++ which make your application more attractive.
4 Mar 2021 by Southmountain
glaux.h header file & glaux.lib can be replaced by freeglut.h & freeglut.lib
8 Dec 2022 by Alexey Shtykov
Activate a particular document window in MDI application via MFC/C++
4 Aug 2013 by Ashish Ranjan Mishra
How to add sub menus dynamically, adding event for them and also retrieving the menu name on click event of individual sub menu
3 Jul 2014 by Rob Kraft
A method is idempotent when the same input(s) always return the same output.  This method is idempotent: This method is not idempotent: When adding methods to classes, many developers spend little time deciding if the method should be idempotent.  Making use of the properties in the class causes the
15 May 2010 by Software_Developer
You can use one single button for more than one behaviour.Here is how.If you have the coordinates of a point in device coordinates and want to find the corresponding position in logcal view - use CDC::DPtoLP to convert the device coordinates to logcal coordinates.Call on...
5 Jan 2015 by zdanman
Fully Customizable ProgressBar Control with Percentage shown that changes color as progress covers it
29 Mar 2011 by CalicoSkies
C++: Converting an MFC CString to a std::string
2 Apr 2011 by jean Davy
As you use CString, you have access to the CW2A ATL macro, assuming that you work with _UNICODE defined, here it is:CString theCStr;...std::string STDStr( CW2A( theCStr.GetString() ) );which will convert to "system encoding on the user's machine" (thanks Nemanja[^] comment !), if you...
7 Apr 2011 by oleg63
CString m_Name;CT2CA pszName(m_Name);std::string m_NameStd(pszName);Works for me everywhere... :)
30 Oct 2011 by steveb
In UNICODE:CString str = L"Test";std::wstring ws(str);std::string s;s.assign(ws.begin(), ws.end());
1 Nov 2011 by Kaqkk79
How about this (assuming your project is set to Unicode)?CString strMyString=L"Test string";std::string strMyStdAnsiStr = CStringA(strMyString);
13 Nov 2011 by geoyar
I am using CString str(_T("Test"));typedef std::basic_string string_t;string_t resStr(str);It works because the CSting has a cast to LPTCSTR.
1 Dec 2011 by stonexin
LPSTR WideChar2MBCS( const CString& strCS ){ const UINT wLen = strCS.GetLength() + 1; UINT aLen = WideCharToMultiByte(CP_ACP,0,strCS,wLen,NULL,0,NULL,NULL); LPSTR lpa = new char[aLen]; WideCharToMultiByte(CP_ACP,0,strCS,wLen,lpa,aLen,NULL,NULL); return...
30 Nov 2016 by David Wincelberg
Displays a date/time difference as calendar days or 24-hour days and can show hours or minutes for the first 24 hours
24 May 2016 by Christian Koberg
How to use CAsyncSocket in a console application? Is it possible at all?
4 Dec 2020 by Eddie Nambulus
CheckBox as an item in CComboBox
4 May 2012 by _Flaviu
A class designed to connect to a database through ODBC and perform basic operations such as inserts, updates, and deletes
13 Feb 2016 by JPhelps
To dynamically set the password viewing style for the edit control
23 Jan 2012 by Roger65
CFileDialog in a Console Application
28 Jun 2012 by Binu MD
Change GUI control position with dialog re-size
19 Jun 2012 by Binu MD
Change the default ICON of MFC applications
15 Apr 2018 by hofingerandi
Workaround for a bug in the CMFCEditBrowseCtrl that causes heavy flickering (starting with Windows 7)
5 Mar 2014 by rbrunton
Using Windows hooks to capture mouse action.
28 Dec 2010 by danielexx
Algorithm C++/MFC
18 Dec 2020 by ferdo
How to compile MFC sources with VS 2019 (for ARM64 too)
22 Apr 2014 by SaahilPriya
Connect Systems using WMI Services, Remote as well as Local
20 Jul 2011 by Mukit, Ataul
this tip tells about a tool that converts a win32 rc file to XML
15 Sep 2011 by Mukit, Ataul
This tip shows you how to convert the dimension values in the .rc file of a dialog into pixels
9 Sep 2021 by _Flaviu
A simple way to convert an office document to PDF
10 Dec 2011 by Pranit Kothari
If you have chosen Win32 console based application while using New Project Wizard, and later you realize you need to add MFC support, here is a trick.
21 Mar 2015 by SaahilPriya
The sample demonstrates how to count the number of OLE Automation Objects running at a particular time.
5 Jan 2011 by Mukit, Ataul
This tip is about creating a cursor from an icon
25 Jan 2011 by Mukit, Ataul
Create a bitmap from an array of pixels
2 Mar 2012 by SuperFun21
A general function using MFC that runs a command using CreateProcess(), waits for it to terminate, and returns its ExitCode.
22 Dec 2014 by TyrWang
Use CResizeWnd as an add-on to any dialog
8 Oct 2017 by _Flaviu
A memory CTreeCtrl like object, but resident in memory only
15 Sep 2011 by Mukit, Ataul
This is not so much of a trick, just a little tip about how CTRL+I is interpretated in a window
14 Apr 2011 by CHMLPAVANI
Sometimes we tend to enable the context sensitive help while creating a project, how to disable that later and get rid or error/information pops on clicking F1 while the application is running.
24 Apr 2010 by Kartik Sura
Introduction...
13 Nov 2011 by .dan.g.
Displaying the 'new' Vista/Windows 7 File Dialog in 'old' MFC Apps
20 Jun 2014 by M Sheik Uduman Ali
Don’t use elephant for your garden work
6 Dec 2012 by Jibesh
Simple Drag and Drop functionality in a dialog.
21 Aug 2017 by Biruk Abebe
How to completely take control of drawing a custom application window including the captionbar, menubar, toolbar, borders and statusbar in MFC Single document interface (SDI) applications using the MfcSkinSDI class.
26 Jan 2011 by Kyudos
Extracting A Particular Icon From an .ICO Resource
29 Aug 2014 by Ștefan-Mihai MOGA
A quick solution to transform binary data to plain text
5 Mar 2012 by Mukit, Ataul
This tip shows a very fast algorithm (with some constraints enforced for it to work) to EnsureVisible a row in CGridCtrl by Chris Maunder
13 Aug 2010 by Not Active
Plagiarized from http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx[^]
15 Aug 2011 by Ștefan-Mihai MOGA
How to find a substring in a text, forward and backward, with Case Sensitive and Match Whole Word options.
29 Jan 2013 by Roger65
Find file or use wildcard i.e. dlg*.h, or *.*
26 Oct 2017 by Rick York
Something to help compile samples from the VS2010 feature pack
20 Oct 2010 by Ajay Vijayvargiya
Need to Format/sprintf a string before displaying a messagebox? Here is solution!
21 Oct 2010 by Aescleal
printf is so 1980s. If you don't want to dig out your shoulder pads and big hair why not go for a more modern C++ approach?Instead of a function try a stream buffer:class message_box_stream_buf : public std::basic_streambuf{ public: message_box_stream_buf( const...
22 Aug 2015 by Juan AG
Create a dll wich uses MFC statically linked and allow you to call normal methods, static methods and global variables, quick an easy
13 May 2020 by Apprieu (Apprieu)
How to generate a serial key with Crypto API MFC
2 Feb 2016 by MaxMax14
Keep the items highlighted when focus is on another control
31 Jul 2013 by Thomas B Dignan
Getting the text of Win32 Error codes for 99% of cases.
17 Oct 2014 by majid torfi
HexCounter, Calculate the number HEX duplicate
7 May 2013 by Aydin Homay
This tip/trick discusses about hosting a Windows Form user control in an MFC dialog box and View windows.
30 Apr 2014 by Nitesh Kejriwal
Friends, I am planning to write a series of articles on creating menus in different ways and this is the 1st one in the series. This post will explain how to create a simple 2 level menu using HTML and CSS only. We know there are a lot of ways to create a HTML menu …Read more →
13 Apr 2018 by _Flaviu
A method of how to get rid of "close" menu from multiple CDockablePane panels
25 Jun 2011 by Mukit, Ataul
Link to How to implement a resizable property sheet class that contains a menu bar in Visual C++ 6.0
13 Jun 2011 by Mukit, Ataul
Addresses the issue of opening a view in maximized mode the proper way in MFC.
24 Nov 2013 by SoMad
The example for CStringT::Tokenize() on the MSDN page (and just about everywhere else on the Internet) skips empty tokens. Here is how to use it in order to get empty strings instead of simply skipping those fields.
11 Apr 2011 by Albert Holguin
The vc compiler and intellisense don't look for pre-compiled header in a similar manner, this is a summary of the issue along with workarounds
9 Mar 2015 by sunhui
Integrate .NET Component to your Native MFC Application at runtime
20 Feb 2024 by Ștefan-Mihai MOGA
A look at the URLDownloadToFile function and architecture of IntelliLink
23 Mar 2016 by _Flaviu
A way to know when a floating CDialogBar is closed
19 Apr 2015 by Member 11246861
Some ways in which laptops and microcontrollers communicate
26 Jan 2012 by hairy_hats
When linking a mixture of mixed-mode and unmanaged DLLs to an unmanaged C++ executable, the link order can affect how the program runs.
2 Feb 2011 by Mukit, Ataul
This tip shows the technique of loading a 256 color bitmap into an image list
8 Dec 2011 by Ștefan-Mihai MOGA
How to get the MAPI server nane
16 Dec 2014 by bishopnator29a
Simple method how to make application's window maximized on different monitors in multi-monitor setup.
21 May 2021 by rev78
Simply bypass the 255 columns in MFC CRecordset
27 Mar 2013 by Aydin Homay
Minor changes on CGridCtrl 2.27 for compatibility with old version of this control
24 Jul 2010 by Christian Kleinheinz
Retrieving the correct pointer anytime and anywhere in MFC MDI applications
27 Feb 2015 by aljodav
An easy way to encrypt files that are automatically decrypted in the same user account
28 Feb 2015 by aljodav
A simple, short and easy way to display a JSON object in a browser (motivated by a forum question)
26 Feb 2015 by aljodav
Easily reading CodeProject RSS feed for new articles from a MFC Application
29 Jan 2024 by Ștefan-Mihai MOGA
How to implement the missing CMFCListView class
13 Oct 2013 by MaxMax14
For single or multiple selection CListBox
22 Apr 2013 by bkelly13
Multiple Projects in One Solution
6 Apr 2013 by ReturnVoid
Working example: OpenGL CDialog Multiple Context
21 Feb 2012 by Jochen Arndt
Information about COleDataSource not contained in the Microsoft documentation or hardly to be found
10 Jun 2020 by fernando amatulli
Polynomial interpolation algorithm from 1 to 9 degree that allow forcing constant term to 0
2 Mar 2016 by Antonio Miras
Programatically set a static IP, subnet mask and gateway to an ethernet network adapter on your local machine
19 Sep 2010 by Reto70
Protect 'DLL hijacking' in MFC app with MAPI and Microsoft Office
6 Jul 2011 by Mukit, Ataul
Shows how to enable invoking of the OnUpdateCmdUI(...) in a dialog or property sheet when a menu bar item is pulled down to show popup menu
4 Dec 2013 by Mahdi Nejadsahebi
How to query a database file from an MFC application.
11 Oct 2015 by Member 11246861
Wifi communication between RaspberryPi2 and Laptop ASUS: fonts English, Russian.
6 Feb 2012 by Mukit, Ataul
Given a device context, replace a color (clrColorReplace) in a rectangular region of the device context with another color (clrColorFill)
29 Jul 2016 by PawelBujak
How to avoid blocking long operations in GUI applications, that lead to hung state.
20 Aug 2018 by Matt Fichtenbaum
A rich edit control's "find text" operation failed, but the same code worked in another program.
24 Mar 2012 by Mukit, Ataul
This tip shows how to save a 24 bitmap to a file given filename, pixel data, bitmap width and bitmap height
20 Aug 2023 by Ștefan-Mihai MOGA
How to save a message to an MSG Compound file.
23 Mar 2008 by Tu (Le Hong)
A scroll window that surpasses the 16-bit limit and can be hosted by a dialog.
20 Nov 2013 by Richard MacCutchan
Obscure a window or the screen and show a dialog.