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

MFC 

20 Aug 2009 by "Fish" (David B. Trout)
A command-line tool to run multiple programs in parallel (i.e. concurrently, as a group).
16 Apr 2001 by #realJSOP
Technique for utilizing a CResizablePage in a CFormView-derived class
6 Jun 2001 by #realJSOP
Extension of Paolo Messina's CResizableDialog concept
14 Mar 2002 by #realJSOP
Parse strings with specified delimiter and specified quote character
7 May 2001 by #realJSOP
Track a mouse click, even in a scrolled view
12 Dec 2001 by #realJSOP
A small function to either accept or create a UUID* and return a CString
8 Dec 2002 by #realJSOP
Some dialogbox code to give the Blonde a clue
22 Dec 2003 by #realJSOP
Add a scrollbar to a property page when the SIP is displayed.
13 May 2005 by #realJSOP
Create blinking cells for Chris Maunder's grid control.
9 Aug 2005 by #realJSOP
Enumerate all controls in a dialog box or form view.
28 Jul 2006 by #realJSOP
Copy a bitmap over a portion of another bitmap
3 Aug 2006 by #realJSOP
A passable workaround for the COleDateTime formatting behavior in MFC8.
27 Jan 2007 by #realJSOP
Implement XML application profiles that are similar (but not too similar) to using INI files
26 Jan 2007 by #realJSOP
Add menu items to, and learn how to handle the system menu
21 Jan 2010 by #realJSOP
When I was doing MFC, I just used the designer and drag/dropped a menu control onto the dialog box...
29 Jan 2010 by #realJSOP
The app should automatically enumerate the printers in the common Print dialog, and will automatically select the default printer. What do you want to monitor?In any event, when new hardware is added to your system, a system-wide event is sent, and you can intercept this event in your...
30 Jan 2010 by #realJSOP
The proper way to do it is to enumerate the child controls of the dialog box, find the highest tab order, and set the new button's tab order to the highest tab order you found + 1.However, your problem is that of visibility. Hide the button you don't want to be active, and Show the button...
5 Feb 2010 by #realJSOP
I wrote this article[^] nine years ago. It's got the code you need. Asking my any questions about it would be fruitless because I haven't looked at that code since at least 2002, and I'm not doing C++/MFC anymore.
19 Feb 2010 by #realJSOP
If you want to find out what will happen, your best bet is to run the code under the debugger.Beyond that, why are you destroying the timer and then recreating it again? That seems rather pointless to me. What you should be doing (barring the use of multi-threading) is turn the timer OFF...
8 Apr 2010 by #realJSOP
Your button has to be able to detect when the mouse is within it's rectangle. I think I remember it being call mouse capture or something like that. It's been more than three years since I did any C++/MFC.Once the button detects that the mouse has entered its rectangle, you can have the...
25 Apr 2010 by #realJSOP
After you maximize the app, focus the main window.
29 Apr 2010 by #realJSOP
My experience is that users don't like it when controls (or menu items) appear and disappear while they're using the program. At the very most, they are just barely comfortable with items being disabled, but when things start disappearing/reappearing, they freak out. I'd rethink my interface if...
11 May 2010 by #realJSOP
OnSize is called several times during dialog startup. Just check to see if m_txtImageCtrl is null before doing anything with it.
13 May 2010 by #realJSOP
Because Intellisense is VC6 sometimes doesn't work. That's the best I can tell you.
31 May 2010 by #realJSOP
You could do it in the handler where you handle the list item click event. Just call parent->Focus() or something like that.
1 Jun 2010 by #realJSOP
You have to derive a new class from CListCtrl, and override the OnPaint() event, drawing the item the way you want to. Keep in mind that you have to handle ALL painting situations when you do this.
10 Jun 2010 by #realJSOP
Google this phrase, and sift through over 1.6 million hits (including at least one hit that references a thread here on CodeProject):"c++ icons in menu"I would derive a new class for CMenuItem, and handle the OnPaint method, but it's been three years since I've done any MFC, and they...
19 Jun 2010 by #realJSOP
Start a new MFC application in Visual Studio, and copy your code into it in the appropriate place(s).
19 Jun 2010 by #realJSOP
Here's what you do (this is a three-year old memory, so you may have to tweak it).0) Put a GroupBox control on your form.1) Put the radio buttons inside the groupbox.2) Set the tab order, starting with the radio buttons, and finishing with the groupnbox.3) Set the first radio...
20 Jun 2010 by #realJSOP
Actually, the way it should go is that you should create a wcf service, and then port your code to .net while at the same time adding it to the service.Since you're going from C++/MFC, the process is going to probably be completely manual, meaning there's no automatic conversion utility...
9 Jul 2010 by #realJSOP
Maybe add event handlers and set a breakpoint in them. Is there a OnWindowCascade event? Are you calling the method on the correct object?You're going to have to get creative to find out why this isn't working. I googled it and drilled down past 200 returned result items and didn't see...
11 Jul 2010 by #realJSOP
Maybe you shouldn't worry about it. Copy protection won't work because if your application is deemed to be important enough, someone somewhere will figure out a way to deactivate anything you might put in the code. However, if you really think your application is worthy of stealing, you...
13 Jul 2010 by #realJSOP
What difference does it make *-why* CObject is the ultimate base class. It simply is, and there's nothing you can do about it.
27 Jul 2010 by #realJSOP
It baffles me as to why people don't search google first. This is the first of 382,000 results returned with "MFC and unicode":http://msdn.microsoft.com/en-us/library/wsdfs47e(VS.80).aspx[^]
3 Aug 2010 by #realJSOP
You need to read up on collections:http://msdn.microsoft.com/en-us/library/942860sh(VS.80).aspx[^]
5 Aug 2010 by #realJSOP
You don't want to use BroadcastSystemMessage, because you get ALL system messages. You want to regsiter a message in both apps, and respond only to that message.I would look at this article regarding inter-process communications:Interprocess communication tutorial[^]
15 Aug 2010 by #realJSOP
Well, it's calling the ansi version of the function, and you're using a buffer of type TCHAR. Try changing it to a char type ans see if that works...
25 Aug 2010 by #realJSOP
You have to create a handler that either does or does not do something based on some condition that you set.There's also absolutely no reason to put an angry smiley in your question.
30 Aug 2010 by #realJSOP
Ad an event handler for the Resize event, and in that handler, do the checks necessary to keep the size to your desired minimum/maximum.
3 Sep 2010 by #realJSOP
I've used registered messages in the past. Simply post the registered message to the system. To allow messages to be shared, I put them into a LIB file and simply linked it to the applicable applications.You can also setup TCP/IP comms using sockets, named pipes, and shared memory via DLLs,...
3 Sep 2010 by #realJSOP
Instead of changing the size of the combobox, try scaling the image size to fit the available space.
7 Sep 2010 by #realJSOP
Your associations aren't set correctly in Windows 7. Add your file types to the Associations and it should work.
7 Sep 2010 by #realJSOP
Google "mfc createprocess". You'll get over 1.6 million hits.
7 Oct 2010 by #realJSOP
Why do you have this in your code NINE TIMES?#include Also, does myheaderfiles.h also have this line:#include "stdafx.h"
17 Oct 2010 by #realJSOP
Have you tried manually invalidating the listbox?
28 Oct 2010 by #realJSOP
You can't use the commandline to do that. You could make your program provide a "command window" of it's own that would allow you to have it "do stuff" when you type something in.You could also write another commandline app that you could pass parameters to that would then instruct your...
18 Nov 2010 by #realJSOP
You should probably try setting the font in the OnPaint event for the button.
22 Nov 2010 by #realJSOP
Put a timer in the dialog and have it close itself on the timer tick
22 Nov 2010 by #realJSOP
Put a timer in the dialog and have it close itself on the timer tick
29 Nov 2010 by #realJSOP
That's a non-standard use of the left mouse button, and should be avoided. If it were me, I'd provide a button that the user could click, or a context menu for the edit ccontrol that allows themm to paste the text.
30 Nov 2010 by #realJSOP
Look at the scribble sample project provided by microsoft.
3 Dec 2010 by #realJSOP
I googled "mfc tooltips", and found this:Custom ToolTips for MFC Projects[^]It might get your started.
7 Dec 2010 by #realJSOP
The button appearance in MFC is controlled by the current theme running on the underlying OS (or at least it used to be that way a few years ago).If it's still that way, if you want to change a button's appearance, you have derive a new class and override the OnPaint event.
26 Dec 2010 by #realJSOP
There are a couple of ways you can do this:0) You're going to have to change your app to send an object instead of just text. The new object would probably contain the targeted users name(s) and the text to be sent to them. Then when the server gets the message, it only sends the text to the...
27 Dec 2010 by #realJSOP
There are a lot of ways you can approach this.0) Put the counter in a data file.1) Put the counter in the registry.2) Put the counter into a DLL file.
30 Dec 2010 by #realJSOP
You either have to do it manually, or you have to find software that can reliably translate it. If your strings aren't in a resource DLL, it's going to be a lot more tedious.
31 Dec 2010 by #realJSOP
If you just cave in and use google, you might find an answer faster. I searched for "cricheditview zoom", and found this file:http://www.learnstar.com/AliR/RichEditZoom.zip[^]
3 Jan 2011 by #realJSOP
You can subscribe to Windows system events. Google is your friend.
5 Jan 2011 by #realJSOP
It's not a coding thing.Just drag the app into your startup folder, and it will start when the user logs in.
7 Jan 2011 by #realJSOP
Try googling the phrase "mfc custom control tutorial". You'll get 101 THOUSAND results.
11 Jan 2011 by #realJSOP
You have to parse the RTF document and add the marks yourself. Here's the RTF v1.5 spec (there may be something newer, but I don't know). Google is your friend.http://www.biblioscape.com/rtf15_spec.htm[^]
18 Jan 2011 by #realJSOP
The best I can do is provide a link to the MSDN documentation because your question isn't providing enough information to provide any semblence of a more accurate answer. Instead of posting code, go to this link and READ THE INFORMATION THOROUGHLY. It just indicate might what you're doing...
18 Jan 2011 by #realJSOP
http://msdn.microsoft.com/en-us/library/758fye78(v=vs.90).aspx[^]
18 Jan 2011 by #realJSOP
This is the third time you've posted the same question. Try using google - that's what we would have to do to find a possible answer for you. If your first instance of this question hasn't been resolved, EDIT IT to say it's still not resolved, and it will be put back at the top of the question...
21 Jan 2011 by #realJSOP
Shouldn't it be CSocket server; server.Create(PRE_AGREED_PORT);server.Listen();CSocket client;server.Accept(client);Have you tried using the debugger that comes with Visual Studio? Most of the time, stepping through the code will reveal your actual problem to you.
19 Jan 2011 by #realJSOP
Maybe you should use a CTabView as your main view, and put sub-views into tab pages.
27 Jan 2011 by #realJSOP
Go to the CodeProject home page, find the Search Articles label, and specify "CStatic" as your search criteria. You'll get 170 different article references that might help you.
31 Jan 2011 by #realJSOP
You're going to have to run both apps under the debugger to see what's happening. I don't see any way you can avoid doing that.
8 Feb 2011 by #realJSOP
We don't do homework for people. It's not that we feel like we're superior or anything, it's that you won't learn anything if we do the work for you. Make an effort to do the work yourself, and if you have a specific problem, come back and ask a question about that problem.
12 Feb 2011 by #realJSOP
I believe you need to use WMI to get that info. Google is your friend.
3 Mar 2011 by #realJSOP
Have you - oh, I don't know - tried the debugger?
17 Mar 2011 by #realJSOP
You're specifying a 120 and 140-point font height. No matter what mapping mode you use, the fonts are going to be huge.
17 Mar 2011 by #realJSOP
Whay can't you just do this:public void CallFunction(){ if (pClassA) { pClassA->function(); } else { if (pClassB) { pClassB->function(); } }}This way, you always call the CallFunction method, and it...
17 Mar 2011 by #realJSOP
You have to paint those kinds of controls yourself. The usual way to do this is to create a new class derived from CButton (or CCheckbox), and override the OnPaint command. Don't forget that you have to also paint for ALL states the control can have. There's probably already code out there...
19 Mar 2011 by #realJSOP
I don't think you can mix platforms. Try changing both the app and the dll to either 32-bit or 64-bit and see if it clears up.
21 Mar 2011 by #realJSOP
Do it a pixel at a time. Be aware that it's always RGB, but depenbding on the color depth of the image, there could be an Alpha bit, so it would be ARGB. You can use the CBitmap.GetPixel() method, or GetDIBits() windows api method. When you google thaose methods, you should be able to eeasily...
24 Mar 2011 by #realJSOP
It's been more than four years since I wrote any MFC stuff, but it goes something like this:CString path;if (dlg.DoModal() == IDOK){ path = dlg.GetPathName();}
6 Apr 2011 by #realJSOP
CString str = "The string";_bstr_t bstrTest( str );//or_bstr_t bstrTest = _bstr_t( str );
7 Apr 2011 by #realJSOP
Your operating system support should be restricted to XP, Vista, Windows 7, Server 2003-2008. Everything older than those is irrelevant and so obsolete that they make Warren Buffet look like a spring chicken.Further, unless you have a tangible requirement to create 64-bit software, don't...
14 Apr 2011 by #realJSOP
Create a Setup project in your solution, and it will (by default) include dependency checks for the appropriate versions of MFC and the C Runtime Library. This will force the user to download it if it's not already installed. It would do you good to learn how to use the tools you have on hand.
14 Apr 2011 by #realJSOP
In the designer, make all of the controls in the form disabled. In the code, after the data is loaded, enumerate all of the controls on the form, and enable them. Here's an article I wrote that shows how to enumerate controls in a form:Enumerate Controls In a Dialog Box or FormView[^]
15 Apr 2011 by #realJSOP
Well, "print screen" does exactly that. Since the window is minimized, there's no presence on the screen, and you get a black image. You probably have to normalize (or maximize) the application in question, "print" the screen, and then return it to its minimized state.
15 Apr 2011 by #realJSOP
Put a try/catch block around the code and run it under the debugger. There's little we can do here without being able to see your code, and besides, you really should have run it under the debugger BEFORE asking us to identify your issue.
5 May 2011 by #realJSOP
It manages the event handlers for the specified MFC object. Google is your friend:google results for search phrase "mfc begin_message_map"[^]
6 May 2011 by #realJSOP
So, what's your question? Put the classes into a MFC DLL and get on with the task at hand.
12 May 2011 by #realJSOP
There are several regex solutions for validating email addresses. All you need is a little google foo.
22 May 2011 by #realJSOP
Google reveals all:Search phrase results for "mfc richedit copy paste image"[^]
7 Jun 2011 by #realJSOP
Don't you want to use CRadioButton instead of CButton?
9 Jun 2011 by #realJSOP
VS2005 deprecated a lot of the old C runtime functions and replaced them with "secure" versions. If you're not using any of them, you're gold. If you are using them, fixing the warnings should be a piece of cake. The VS2005 compiler also catches some errors that the earlier ones didn't. Those...
13 Jun 2011 by #realJSOP
The sheet itself doesn't have/need a title. The *pages* do.
4 Jul 2011 by #realJSOP
Each process should be responsible for opening ad closing its own files. When the process opens the files, they should open them with non-exclusive read AND write. Sharing open file handles is not recommended.
7 Jul 2011 by #realJSOP
You can either turn off the UAC, or run the app as admin. I think in order to run the app as admin, you can't use ShellExecute. Instead, create a process and set the appropriate properties to run it as admin.
12 Jul 2011 by #realJSOP
It's been a while since I did C++, but I seem to remember that you also have to provide a default constructor:CBibliotekaDlg::CBibliotekaDlg():CDialog(){}
25 Jul 2011 by #realJSOP
This link might be useful[^]
17 Aug 2011 by #realJSOP
You can't dynamically create enums. What you SHOULD do is create a HashSet (do you have a HashSet colleciton in unmanaged C++? I haven't kept up with it since moving to .Net) in of account types that are loaded from the database, and use that instead of an enum.
2 Sep 2011 by #realJSOP
what type is BtnState? If it's not a bool, and it's not set to null (or zero), it will evaluate to true.EDIT ======================0) Are you sure m_pg isn't null?1) Try it this way:CPage* m_pg = ((CPage*)((CGSPropertySheet*)GetParent())->GetParent());if (m_pg){ ...
4 Sep 2011 by #realJSOP
On MSDN - ParseCommandLine[^]A very simple google search...
9 Sep 2011 by #realJSOP
Google reveals all.A skinned dialog in Python and MFC[^]
25 Dec 2011 by #realJSOP
That's a circular reference, and you can't do that. Refactor your code.
7 Mar 2012 by #realJSOP
I'm not sure you can unless you're using exchange server, and even then, the mail is not recallable once it's been read.