Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Everything / desktop / MFC

MFC

MFC

Great Reads

by Marat Bedretdinov
Shell interfaces in use. IShellFolder, IEnumIDList, etc.
by Nicolas Bonamy
Two simple ways to add "Do not ask again" Message Boxes to your application.
by Igor Sukhov
The ATL and MFC versions of the class that implements a dialog for selecting users(computers) within the Windows Network.
by vishalkmehta
This article demonstrates how to leverage the power of images and inheritance to achieve a "skinned" look for your Windows applications.

Latest Articles

by Marat Bedretdinov
Shell interfaces in use. IShellFolder, IEnumIDList, etc.
by Nicolas Bonamy
Two simple ways to add "Do not ask again" Message Boxes to your application.
by Igor Sukhov
The ATL and MFC versions of the class that implements a dialog for selecting users(computers) within the Windows Network.
by vishalkmehta
This article demonstrates how to leverage the power of images and inheritance to achieve a "skinned" look for your Windows applications.

All Articles

Sort by Score

MFC 

by anscode
This post describes a slider control for C++ which make your application more attractive.
by HateCoding
A tiny custom list control
by Southmountain
glaux.h header file & glaux.lib can be replaced by freeglut.h & freeglut.lib
by Alexey Shtykov
Activate a particular document window in MDI application via MFC/C++
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
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
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...
by zdanman
Fully Customizable ProgressBar Control with Percentage shown that changes color as progress covers it
by CalicoSkies
C++: Converting an MFC CString to a std::string
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...
by oleg63
CString m_Name;CT2CA pszName(m_Name);std::string m_NameStd(pszName);Works for me everywhere... :)
by steveb
In UNICODE:CString str = L"Test";std::wstring ws(str);std::string s;s.assign(ws.begin(), ws.end());
by Kaqkk79
How about this (assuming your project is set to Unicode)?CString strMyString=L"Test string";std::string strMyStdAnsiStr = CStringA(strMyString);
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.
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...
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
by Christian Koberg
How to use CAsyncSocket in a console application? Is it possible at all?
by Eddie Nambulus
CheckBox as an item in CComboBox
by _Flaviu
A class designed to connect to a database through ODBC and perform basic operations such as inserts, updates, and deletes
by JPhelps
To dynamically set the password viewing style for the edit control
by Roger65
CFileDialog in a Console Application
by Binu MD
Change GUI control position with dialog re-size
by Binu MD
Change the default ICON of MFC applications
by hofingerandi
Workaround for a bug in the CMFCEditBrowseCtrl that causes heavy flickering (starting with Windows 7)
by rbrunton
Using Windows hooks to capture mouse action.
by ferdo
How to compile MFC sources with VS 2019 (for ARM64 too)
by SaahilPriya
Connect Systems using WMI Services, Remote as well as Local
by Mukit, Ataul
this tip tells about a tool that converts a win32 rc file to XML
by Mukit, Ataul
This tip shows you how to convert the dimension values in the .rc file of a dialog into pixels
by _Flaviu
A simple way to convert an office document to PDF
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.
by SaahilPriya
The sample demonstrates how to count the number of OLE Automation Objects running at a particular time.
by Mukit, Ataul
This tip is about creating a cursor from an icon
by Mukit, Ataul
Create a bitmap from an array of pixels
by SuperFun21
A general function using MFC that runs a command using CreateProcess(), waits for it to terminate, and returns its ExitCode.
by TyrWang
Use CResizeWnd as an add-on to any dialog
by _Flaviu
A memory CTreeCtrl like object, but resident in memory only
by Mukit, Ataul
This is not so much of a trick, just a little tip about how CTRL+I is interpretated in a window
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.
by .dan.g.
Displaying the 'new' Vista/Windows 7 File Dialog in 'old' MFC Apps
by M Sheik Uduman Ali
Don’t use elephant for your garden work
by Jibesh
Simple Drag and Drop functionality in a dialog.
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.
by Kyudos
Extracting A Particular Icon From an .ICO Resource
by Ștefan-Mihai MOGA
A quick solution to transform binary data to plain text
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
by Not Active
Plagiarized from http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx[^]
by Ștefan-Mihai MOGA
How to find a substring in a text, forward and backward, with Case Sensitive and Match Whole Word options.
by Roger65
Find file or use wildcard i.e. dlg*.h, or *.*
by Rick York
Something to help compile samples from the VS2010 feature pack
by Ajay Vijayvargiya
Need to Format/sprintf a string before displaying a messagebox? Here is solution!
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...
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
by Apprieu (Apprieu)
How to generate a serial key with Crypto API MFC
by MaxMax14
Keep the items highlighted when focus is on another control
by Thomas B Dignan
Getting the text of Win32 Error codes for 99% of cases.
by majid torfi
HexCounter, Calculate the number HEX duplicate
by Aydin Homay
This tip/trick discusses about hosting a Windows Form user control in an MFC dialog box and View windows.
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 →
by _Flaviu
A method of how to get rid of "close" menu from multiple CDockablePane panels
by Mukit, Ataul
Link to How to implement a resizable property sheet class that contains a menu bar in Visual C++ 6.0
by Mukit, Ataul
Addresses the issue of opening a view in maximized mode the proper way in MFC.
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.
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
by sunhui
Integrate .NET Component to your Native MFC Application at runtime
by Ștefan-Mihai MOGA
A look at the URLDownloadToFile function and architecture of IntelliLink
by _Flaviu
A way to know when a floating CDialogBar is closed
by Member 11246861
Some ways in which laptops and microcontrollers communicate
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.
by Mukit, Ataul
This tip shows the technique of loading a 256 color bitmap into an image list
by Ștefan-Mihai MOGA
How to get the MAPI server nane
by bishopnator29a
Simple method how to make application's window maximized on different monitors in multi-monitor setup.
by rev78
Simply bypass the 255 columns in MFC CRecordset
by Aydin Homay
Minor changes on CGridCtrl 2.27 for compatibility with old version of this control
by Shao Voon Wong
MFC KillFocus Derived CEdit to solve the Q&A question which has been reposted
by Christian Kleinheinz
Retrieving the correct pointer anytime and anywhere in MFC MDI applications
by aljodav
An easy way to encrypt files that are automatically decrypted in the same user account
by aljodav
A simple, short and easy way to display a JSON object in a browser (motivated by a forum question)
by aljodav
Easily reading CodeProject RSS feed for new articles from a MFC Application
by Ștefan-Mihai MOGA
How to implement the missing CMFCListView class
by MaxMax14
For single or multiple selection CListBox
by bkelly13
Multiple Projects in One Solution
by ReturnVoid
Working example: OpenGL CDialog Multiple Context
by Jochen Arndt
Information about COleDataSource not contained in the Microsoft documentation or hardly to be found
by fernando amatulli
Polynomial interpolation algorithm from 1 to 9 degree that allow forcing constant term to 0
by Antonio Miras
Programatically set a static IP, subnet mask and gateway to an ethernet network adapter on your local machine
by Reto70
Protect 'DLL hijacking' in MFC app with MAPI and Microsoft Office
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
by Mahdi Nejadsahebi
How to query a database file from an MFC application.
by Member 11246861
Wifi communication between RaspberryPi2 and Laptop ASUS: fonts English, Russian.
by Mukit, Ataul
Given a device context, replace a color (clrColorReplace) in a rectangular region of the device context with another color (clrColorFill)
by PawelBujak
How to avoid blocking long operations in GUI applications, that lead to hung state.
by Matt Fichtenbaum
A rich edit control's "find text" operation failed, but the same code worked in another program.
by Mukit, Ataul
This tip shows how to save a 24 bitmap to a file given filename, pixel data, bitmap width and bitmap height
by Ștefan-Mihai MOGA
How to save a message to an MSG Compound file.
by Tu (Le Hong)
A scroll window that surpasses the 16-bit limit and can be hosted by a dialog.
by Richard MacCutchan
Obscure a window or the screen and show a dialog.
by Roger65
Selected Font name, Point Size and Weight are displayed
by Member 11246861
Under laptop's control, microcontroller sends sensor data to laptop that displays numbers and graphic.
by Bob Van Tuyl
How to set landscape mode in MFC app
by Michael Haephrati
How to set write direction and alignment
by Eugen Podsypalnikov
http://rapidsh...
by Hasan Gurler
Simple DXF reader and viewer supporting the most common AutoCAD entities
by ravenspoint
This is an alternative for "Simple DXF Reader/Viewer with Spline Support"
by Gautam Agrawal (Programming Expert)
Enable user to make a dialog transparent without making its child control transparent
by David Wincelberg
A simple way to display "item" or "items" instead of "item(s)"
by kennethman
Hide data inside the zip structure of any zip-based file.
by mahendra.kumar.786
Clipboard operations like cut, copy, paste on a normal CEdit control can be disabled usng subclassing.
by lxdfigo
A Photoshop-Like Color Palette Dialog in MFC
by Eugen Podsypalnikov
http://rapidsh...
by Roger65
How to type text into a static control, change the font used and then save it into a bitmap
by JPhelps
Using CFolderPickerDialog
by Sweta Mittal
Validate whether value in string is a valid decimal number or not.
by Mukit, Ataul
Shows how to view the current library link order in a VC project
by Javad Taheri (drjackool)
How to use read only option in Vista common file dialog
by Emiliarge
How to statically link a Win32 Project with Visual C++ libraries (m***.dll)
by _Flaviu
A small guide to use VTK in MFC
by _Flaviu
Improved Excel class
by Akos Mattiassich
Find a window on the desktop, spy its properties and manipulate it.