Using STL and MFC at the same time.

Started by
16 comments, last by mikef 21 years, 8 months ago
WTL will make MFC obsolete in the near future (I hope)
daerid@gmail.com
Advertisement
Wow, this is the most helpfull forum i ever posted in. Just like Cahaan said, i was planning on using MFC for the GUI.
quote:Original post by daerid
If you would kindly make a .dsw or .sln of a project that just uses "a little bit" of MFC, zip it up, and send it to bross_46@hotmail.com, I'd really appreciate it.

I've been trying to use just a little bit of MFC without using the whole god damn thing for years now.


I'm not sure what you're asking for. I have projects where I use bits of MFC all the time. What do you mean by "the whole damn thing"? That would imply that you are somehow forced to use things like CDBVariant in every application...

An example:

MFC:
CWnd Wnd;
CDC *pDC = Wnd.GetDC();

nonMFC:
HWND hWnd;
HDC hDC = GetDC(hWnd);

Mixed:
CWnd Wnd;
HDC hDC = GetDC(Wnd.GetSafeHwnd());

There are better examples, but that's the general idea.

[edited by - CrazedGenius on August 15, 2002 1:29:57 AM]
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
quote:Original post by daerid
I''ve been trying to use just a little bit of MFC without using the whole god damn thing for years now.

Why? Do you have some strange compulsion that makes you use every feature of MFC?
No.

Idunno, its just that every time I try to use things like CString in my project, it seems like its way too much of a hassle unless I create an MFC application from scratch.
daerid@gmail.com
quote:Original post by SabreMan
Why? Do you have some strange compulsion that makes you use every feature of MFC?


Where did you get the idea that we mean "you must use every feature of MFC"? What we mean, is that you cannot simply create a pure Win32 application and add just a few MFC classes when you need them. If you want to use any MFC class in a program, you have to create an MFC project, which in turn encapsulates ALL of Win32 (WinMain, WndProc, etc.). Thus, If you want to use MFC, it becomes the core of your application. You can't simply use parts of it.

quote:Original post by CrazedGenius
I have projects where I use bits of MFC all the time.


How? Do you mean that you actually created a non-MFC app and were able to add MFC classes (like CString) into it?

Lastly, when I describe MFC as the "core" of an application, I mean "core" as in the portion of the program that performs message handling and controls the overall execution loop. I am not referring to the functions which perform the majority of the app's logic.


-Mike

[edited by - doctorsixstring on August 15, 2002 2:11:32 PM]
You could choose a Win32 Application from the "new project" menu, and then view the Project settings (alt+F7), where you should be able to find an option which includes MFC as ''a Shared DLL''.

Johan Ersvik
Johan
MSVC 6.0 had a problem where you couldn''t use CString without including the rest of MFC--it actually just needs afxbeginthread and afxendthread. For MSVC 7.0 (.NET) they''ve made CString a templated class (I presume for unicode fun) and might have fixed this problem, though I haven''t tried it yet.

There are a few classes that are independent of MFC that you can use without making your project MFC, but generally, it''s true that you need the core window map (thread-local CWnd registry) to use the handy GDI classes, and the whole message-dispatching structure I believe is necessary for any of the window classes.

OTOH, this has nothing to do with STL. There''s a small amount of overlap between MFC and STL--that being CString and some of MFC''s container classes. There''s generally no reason to use MFC''s classes--STL''s are superior in every way except that std::string doesn''t have a sprintf-type (e.g. CString::Format) function (which some people would say makes it better).

This topic is closed to new replies.

Advertisement