std STL with MFC

This may seem a very odd Question, but one I must ask. Do many programmers
use Std C++ STL data structures like Vector<>, List<>, Queue<>, etc when
programming MFC (or even win32 API) projects? To me It just seems weird. I
like to keep MS code with MS stuff (eg use CString instead of std::String
when using MFC), and standard C++ stuff (like STL and std::String) with UNIX
and other non - MS developments. Do I make sense?

So do many MFC projects contain, (use) STL? What is your opinion?

Thanks.


0
2/17/2004 11:13:47 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
589 Views

Similar Articles

[PageSpeed] 8

"Simon Flannery" <support@bigpond.com> wrote in message
news:OeLYkcU9DHA.3404@TK2MSFTNGP09.phx.gbl...
> This may seem a very odd Question, but one I must ask. Do many programmers
> use Std C++ STL data structures like Vector<>, List<>, Queue<>, etc when
> programming MFC (or even win32 API) projects? To me It just seems weird. I
> like to keep MS code with MS stuff (eg use CString instead of std::String
> when using MFC), and standard C++ stuff (like STL and std::String) with
UNIX
> and other non - MS developments. Do I make sense?
>
> So do many MFC projects contain, (use) STL? What is your opinion?
>
> Thanks.


Hi

Since I know about stl, I don't use anything else. The only thing I don't
use from stl in MFC projects, is std::string. This is because a lot of MFC
API uses CString.

The thing is that once you know stl, you don't need any other collection
classes. So then you don't need to relearn about those classes/algorithms in
a new environment.
---
Cheers,
Tom Tempelaere



0
2/17/2004 11:33:42 AM
While developing applications, the bottom line which I follow is,
If there are any chances of porting the application to Non-windows platform,
use stl, so that you need to spend only little time in porting. Otherwise
use MFC containers, bcoz they go very well with MS platform.

Cheers
Jagadeesh



"TT (Tom Tempelaere)" <_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote in
message news:q_mYb.4455$B6.304168@phobos.telenet-ops.be...
> "Simon Flannery" <support@bigpond.com> wrote in message
> news:OeLYkcU9DHA.3404@TK2MSFTNGP09.phx.gbl...
> > This may seem a very odd Question, but one I must ask. Do many
programmers
> > use Std C++ STL data structures like Vector<>, List<>, Queue<>, etc when
> > programming MFC (or even win32 API) projects? To me It just seems weird.
I
> > like to keep MS code with MS stuff (eg use CString instead of
std::String
> > when using MFC), and standard C++ stuff (like STL and std::String) with
> UNIX
> > and other non - MS developments. Do I make sense?
> >
> > So do many MFC projects contain, (use) STL? What is your opinion?
> >
> > Thanks.
>
>
> Hi
>
> Since I know about stl, I don't use anything else. The only thing I don't
> use from stl in MFC projects, is std::string. This is because a lot of MFC
> API uses CString.
>
> The thing is that once you know stl, you don't need any other collection
> classes. So then you don't need to relearn about those classes/algorithms
in
> a new environment.
> ---
> Cheers,
> Tom Tempelaere
>
>
>


0
jagadeeshvn (256)
2/17/2004 11:48:27 AM
It is a matter of taste. STL is cleaner and more general than the MFC classes (which were
largely written before STL was really made 'S'). There have been reports that the VC6
implementation of STL has significant bugs if you use the shared MFC DLL, and since I
don't use anything else, I have avoided it. I have also heard that all known bugs in VC6
have been fixed in VC7, and I have no  reason to doubt this.

Someday Real Soon Now I will take the time to learn STL. But since VC7 is nearly unusable,
being the worst-engineered user interface Microsoft has produced in the history of C IDEs,
I and nearly all my clients are sticking with VC6 until that decision is completely
untenable. Perhaps when Microsoft produces the next iteration, they will correct the
horrible set of defects in the GUI that were introduced in the "improvement" (VS7 has lots
of nice features, many signifcant and important improvements in MFC, supports managed
code, and of course supports C#, but it is nearly unusable because the designer thought
about doing a "clean design" and forgot about the concept of "usable design"). Even my one
client who uses VS7 despises it but needs a feature it has that VS6 does not have.

I don't know what happens at the borders where STL meets MFC, e.g., CString works fine
with both Unicode and ANSI applications interchangeably, and there is an implicit LPCTSTR
cast that simplifies a lot of programming interface issues. STL seems to not be very good
at supporting Unicode/ANSI apps in this sense, the last time I looked at it several years
ago it was hopelessly mired in the 8-bit-character world. Since I build all my code
Unicode-aware, I would find STL classes that use strings completely useless if this is
still true.
					joe

On Tue, 17 Feb 2004 22:13:47 +1100, "Simon Flannery" <support@bigpond.com> wrote:

>This may seem a very odd Question, but one I must ask. Do many programmers
>use Std C++ STL data structures like Vector<>, List<>, Queue<>, etc when
>programming MFC (or even win32 API) projects? To me It just seems weird. I
>like to keep MS code with MS stuff (eg use CString instead of std::String
>when using MFC), and standard C++ stuff (like STL and std::String) with UNIX
>and other non - MS developments. Do I make sense?
>
>So do many MFC projects contain, (use) STL? What is your opinion?
>
>Thanks.
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/17/2004 6:00:03 PM
STL works fine with MFC. I would recommend using STL whenever you can over MFC. MFC
collection classes were part of MFC before STL became C++ standard.

We use STL for another reason as well, it gives you the ability to specify allocators. For
subsystems with own memory management, it works well. MFC, as shipped, is CRT based while
STL does not have to be.

-- 
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"Simon Flannery" <support@bigpond.com> wrote in message
news:OeLYkcU9DHA.3404@TK2MSFTNGP09.phx.gbl...
| This may seem a very odd Question, but one I must ask. Do many programmers
| use Std C++ STL data structures like Vector<>, List<>, Queue<>, etc when
| programming MFC (or even win32 API) projects? To me It just seems weird. I
| like to keep MS code with MS stuff (eg use CString instead of std::String
| when using MFC), and standard C++ stuff (like STL and std::String) with UNIX
| and other non - MS developments. Do I make sense?
|
| So do many MFC projects contain, (use) STL? What is your opinion?
|
| Thanks.
|
|

0
ajaykalra (6842)
2/17/2004 7:04:17 PM
In fact one of the most serious problems of the MFC classes is that when you are running
in environments where space must be closely managed, you cannot specify the allocator. It
is compiled-in to the library. The ability to specify allocators is a definite plus on the
side of STL.
					joe

On Tue, 17 Feb 2004 11:04:17 -0800, "Ajay Kalra" <ajaykalra@yahoo.com> wrote:

>STL works fine with MFC. I would recommend using STL whenever you can over MFC. MFC
>collection classes were part of MFC before STL became C++ standard.
>
>We use STL for another reason as well, it gives you the ability to specify allocators. For
>subsystems with own memory management, it works well. MFC, as shipped, is CRT based while
>STL does not have to be.

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/18/2004 1:44:06 AM
Reply:

Similar Artilces:

Return ERRORLEVEL from MFC App.
Hi All, I am in the unfortunate position of having to write an MFC app while knowing nothing about MFC. It's a simple thing, display a dialog box with an embedded webbrowser control and return an indicationto a batch script which of two buttons was clicked. It all works fine except that I can't access the return value. I have overridden ExitInstance to return the appropriate value and the exit code shows up correctly in the Visual Studio output window, however the ERRORLEVEL returned is always 0. Can anyone help, or suggest a better way of doing this??? Thanks, mal Sorry, ...

How to create MFC child window with parent given as HWND ?
Can I create a window with some template parent and after it just call : ::SetParent( m_cWnd.m_hWnd, hWnd ); on MFC widow. Will it work ? Thanks in adwance, Adam Avoid the use of SetParent. What is it you are trying to do? There is no such thing as "creating a window with some template". There is creating dialogs from templates, and creating windows. In either of these cases, you specify the parent, so there is no need to SetParent. Generally, if you are using SetParent, you are either doing something completely wrong, or there is a better way to do it. joe On Fri, 18...

Win98 support in MFC.
Good day. I have a problem when running my app which uses CFileDialog on Windows 98. It fails at the point of the .DoModal() method in that the dialog never opens it just appears to hang the app. I have had a suggestion to verify the operating system support in stdafx.h and to check my operating system symbols. Looking into it a bit more it appears as I have to enable support for Win98 to use the old OPENFILENAME structure and I thought all I would have to do is specify WINVER=0x0400 in my preprocessor definitions. I tried this but the same problem is occurring at the .DoModal() call. Wha...

Interfacing C and MFC C++
I need some advice on transferring information between C and C++ code. I have made in VC++6 an MDI application that has one document and many views which draw a few graphs and display numerical information. The actual data should come from exising C code that cannot be migrated into C++ since it is also used in, let's say, embedded devices. My application visualizes the outcome of the computer simulation of these embedded devices. I have several functions in the document object that the C code should ultimately call by one way or another. Their parameters are just CStrings, BOOLs and dou...

Dialog Boxes in MFC Dlls
Hello, I was wondering if it is possible to add a complete CDialog box class and resource to a MFC dll, that will later be included in an application? I have tried it already and have not been able to get a successful compile. The error given was: error C2065: 'IDD_DIALOG1' : undeclared identifier I took a look at the code and everything 'looks' alright. Any ideas? Thanks in advanced. Sincerely, James Simpson Straightway Technologies http://www.straightwaytech.com Yes, that can be done. Make an extension DLL and add your dll to resource chain using CDynLinkLibrary clas...

Skin and MFC , How to?
Hello, i'm working on an application written with MFC. It is a dialog app and now my boss wnat a nice skin. Where should look for information on how to accomplis this? Thanks in advance "Bredal Jensen" <Bredal.Jensen@mimosa.com> wrote in message news:#w7sQjEgEHA.632@TK2MSFTNGP12.phx.gbl... > > Hello, > i'm working on an application written with MFC. It is a dialog app > and now my boss wnat a nice skin. Where should look for information > on how to accomplis this? > > Thanks in advance > > this site is loading slowly right now so I haven...

how to include "commctrl.h" in a MFC project?
i want to use BTNS_WHOLEDROPDOWN which is defined in commctrl.h , and i add #include "commctrl.h" in my MainFrm.cpp , but the compiler still say BTNS_WHOLEDROPDOWN is undeclared . alex, You need to define _WIN32_IE with value 0x0500 and then include commctrl.h #define _WIN32_IE 0x0500 For more info take a look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla tform/commctls/toolbar/styles.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla tform/shell/programmersguide/versions.asp -- Regards, Kobi Ben Tzvi "...

MFC vs. WinForms
Anyone have any suggestion regarding using WinForms in .NET framework rather than MFC? Should one switch to WinForms for its ease of use and added functionality? What about the inconvenience of MSIL and CLR? ...

Stepping through MFC source code
I used to be able to step into and through the MFC source code in the debugger but now I can't. I have an access violation inside MFC42UD but the debugger will only show me the disassembly. Any idea what I may need to do? I've recently moved back to MSVC++6 from .NET (re-installed VC++6). Could this be part of the problem? I'm thinking it's probably not looking in the right place for the source files but the directory paths look ok to me. For Source files, the paths are: C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC C:\Program Files\Microsoft Visual Studio\VC98\MFC\I...

MS Access + mfc
Hi! I�ve a problem. I create a *mdb file using SQLConfigDataSource. This is ok. But then I want to create a table, always an syntax error occures (ExecuteSQL). CDatabase db; CString statement; SQLConfigDataSource (NULL, ODBC_ADD_DSN, "Microsoft Access Driver (*.mdb)", CREATE_DB=musicdata.mdb") ; db.OpenEx("Driver=Microsoft Access Driver (*.mdb); Dbq=musicdata.mdb;", CDatabase::noOdbcDialog | CDatabase::useCursorLib); db.ExecuteSQL("CREATE TABLE data ( Index INTEGER NOT NULL, Artist VARCHAR(50) NOT NULL);"); db.Close(); If I try: db.ExecuteSQL("...

Still stuck on animation over MFC Bitmaps
Hey again, okay this problem of flickering when I am trying to animate a small circle overtop of a bitmap (in a frame) is still kicking around. I've tried a lot of different solutions but always get the same net effect, it either will not redraw the entire frame (so I'm stuck with a trail of circles on the screen not just the one new circle I wish to draw) or else the screen flickers and takes around 1/2 second to draw (so the mouse is paused while it is trying to redraw). Okay, I think my problem is that I am always redrawing the bitmap AND the circle each time I want to move the cir...

How can I get the list of OCX controls being used in MFC
In VB IDE we have menu for setting reference and control. It shows the list of Active X DLL and ocx that are being used in VB application. Presently I am debugging the MFC code that uses quite a number of OCX controls and active X DLL. Some of them seems to be missing. Like Reference menu provided in VB IDE, can I have any facility in VC++ IDE so that I can get the list of Active X control and Active X DLL being used in my MFC application. Thank u. Biplab revo wrote: > In VB IDE we have menu for setting reference and control. It shows the > list of Active X DLL and ocx that are being...

MFC SDI Doc/View Multi threading
hi guys... need a bit help here.. i am using a Doc/View SDI MFC app.. i have a fn in my DOC void CxxxDoc::OnReceive() inside this fn i need to put watever in received to an array.. but i need to do this in a thread.. so i create a fn code:------------------------------------------------------ -------------------------- void CxxxDoc::GetMsgAndPutInArray() { char* pBuff=new char[1024]; int nBuffSize=1024; int nRecvd; CString strRecvd, strCmd; nRecvd=m_sMyConnectSocket.Receive(pBuff,nBuffSize); if(nRecvd==SOCKET_ERROR) {//yes AfxMessageBox("Error in recieve");...

How to create an MFC application with XP look?
Hi! When I create an MFC app with the wizard in VS .Net 2005 I get an application that looks like it's from the eighties right? Lookin in stdafx.h it's obvious all headers know we're past Windows 3.11. #ifndef WINVER // Allow use of features specific to Windows XP or later. #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif ...

Possible to have MFC Ctreectrl meet Vista Aero theme by developing in Windows XP?
Hi All, I have an application including MFC tree-view control created by CTreeCtrl class, this applicaiton is developed in Windows XP, and now i need to run this application on Vista, so is it possible to have MFC Ctreectrl meet Vista Aero theme by developing it in Windows XP? that means the tree-view control should meet the following standards: The expanded tree items exceed what the container's client area is capable of displaying, a scroll bar appears for the XP style controls. However, for the Vista Aero theme a scroll bar will not appear. In Vista, when the user clicks on tree items ...

Exchange 2K3 Std: Primary email address change reverts to original
Hi Everybody, A customer of mine is running SBS 2003 Standard w/ Exchange 2003 SP2. Each user mailbox has two email addresses - firstnamelastname@domain.com and firstinitiallastname@domain.com. Latter is currently the default email address. Customer has decided that they want to use former as default email address. As I typically would, I open AD Users and Computers MMC, open the property sheet for any user object , go to Email addresses tab, select firstnamelastname@domain.com address and click on "Set as primary" button, then OK out to save changes. HOWEVER...the prim...

Overloading MFC Functions
I have a custom control for which I want to write a Create function. But when I try, I can't use it, I only am able to use the default Create function (from CWnd). When I try to use the other I get the "no overloaded function takes xx arguments". Any thoughts here? tia B Create is virtual so you should be able to override it (I do that all the time). Make sure the arguments are the same as the original: http://msdn2.microsoft.com/en-us/library/0yhc9kx4(VS.80).aspx Tom "saywhat" <no@fuk.no> wrote in message news:7D64g.77$b51.43@fe03.lga... > &...

integration of multiple MFC projects
Hi, pardon me if this qurestion has been asked before. I do not have much working experience with MFC and as such am not sure abt the ways things are done in the industry. In a project team with each person implementing a few CDialogs in their own programs which are to be integrated into a single executable. Now, what is the best way to integrate the disparate programs into a single program without sacrificing ability to do individual unit testing using own project while being to integrate easily with the rest when done? I knew MFC extension DLL can solve it to a certain extent but it requ...

problem with add old string to new string in edit box (MFC)
my code: if (new data ) { CString* pStr = (CString*)wParam; //data come with some com port (PostMessage) CString p2Str; //old string in edit box m_dataa.GetWindowText(p2Str); *pStr= p2Str+*pStr; // add old string to new string m_dataa.SetWindowText(*pStr); // send new string to edit box delete pStr; } in first step I have in edit box "12345" then come new data "6789" so it should be after adding two string "12345 6789" in edit box but is "12345 789" why I lost sign?...

Force Apply of Mailbox Settings (Exchange 5.5 Std Edition)
I have change mailbox's primary user account to a user and it takes a long time before it identifies from the workstation side. For example, I have userA is viewing MailboxA. Then after a time, I want userB to view MailboxA by changing the Primary User Account of his Mailbox. I have check userB if he can view it but there is an error, permission not allowed. I have restart the userB's computer but it didn't work also. I have experience this before but what I did is I only wait for the time that it takes effect. Can I force apply the settings immediately? Hoping for your response. ...

Does MFC supports IPv6 ?
Hi, I am converting one application from IPv4 to IPv6. The application is usign MFC socket class CSocket and CAsyncSocket. ::: My Query ::: 1. When I compile my application for IPv6 by defining IPV6STRICT. I am getting errors in Afxsock.h. I believe CSocket and CAsyncSocket (for MFC 4.2) doesn't support IPv6. Please reply if this is true. 2. How can I make sure that CSocket and CAsyncSocket supports IPv6. ? or 3. How can I include IPv6 support for CSocket and CAsyncSocket classes. ? ::: Some Backgroud ::: 1. I am using VS 6.0 with service pack 6. 2. I am using XPSP-2 SDK. Pleas...

BUG in vs2005 MFC?
ON_WM_NCHITTEST macro. #define ON_WM_NCHITTEST() \ { WM_NCHITTEST, 0, 0, 0, AfxSig_l_p, \ (AFX_PMSG)(AFX_PMSGW) \ (static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(CPoint) > (&ThisClass :: OnNcHitTest)) }, Should the LRESULT be replaced with UINT? Otherwise this invokes a compiler error. Ming. >ON_WM_NCHITTEST macro. >... >Should the LRESULT be replaced with UINT? >Otherwise this invokes a compiler error. There's definitely something wrong here - I'm not sure what the intention is but according to the docs the cast ought to have been UINT. Please report it ...

MFC Shell Extension & Threading
All, I'm working on an MFC Shell Extension project and need some guidance. For reference, I've used a few of Michael Dunn's examples on codeproject.com. http://www.codeproject.com/shell/shellextguide1.asp http://www.codeproject.com/miscctrl/iprogressdialog.asp Basically I'm providing right-click functionality on files\folders. To keep things initially simple, I did not implement threading but the side affect is that Windows hangs while the operation is performed, especially if a large number of files were selected. I've done threading in other languages but I'...

mfc class wizard pops up everytime!
hi, i just started with vc7 with an MFC dialog box project. I added some controls and attached variables... it worked out fine. I don't know what happened but now every control I doubleclick pops up the MFC Class Wizard. Right-clicking any control does not show the ADD VARIABLE option anymore. The ClassView does not show TestMFCDlg as a class anymore (the AboutDlg class is there and I can add variables to it as well!) Can somebody please tell me what went wrong? IDE version: 7.0.9466 Thank you. dtor ...

Check Printer Status with MFC
Hi All, May I know if there is an easy way for me to check the printer status before sending any data to the printer? I am programming in MFC, VC 6.0 and Win2K. For some reason, I must use API OpenPrinter() to access the printer. Cannot access the port directly. What I need is only to ensure that the printer is able to print. And yes, the printer driver does prompt a message when the printer is not ready. But I need to be able to detect this in my program. Thanks in advance. Regards Hi, http://www.codeguru.com/printing/std_printing.shtml With Regards, R.Selvam ...