MFC or Win32 SDK ???

Started by
15 comments, last by krad7 22 years, 1 month ago
MFC most certainly does have a window procedure. But, yes, it's hidden. And it's also generalized. MFC uses a map to retrieve the CWnd object for the received window handle every time the window receives a message. Make no mistake: no matter what kind of application you make, it gets lots of messages. Now, yes, that still doesn't add up to a serious degradation. But why suffer it when you don't need to?

Of course, you can use MFC without its window and message functionality, and that's a fine option. What's so special about MFC's debugging features? Nothing. They just wrap things that are in the Windows API or C runtime library. Just use them directly or wrap yourself, freeing your application from a binding to the dreaded MFC DLL's, which are some of the main culprits in DLL Hell.

[edited by - merlin9x9 on March 23, 2002 6:27:06 PM]
Advertisement
If making games, it is better not using MFC just to create 1 window, however it would make sence to use it for creating External Options or Graphics Adapter dialogs, that are separate windows from your game and don''t show while your game is playing. To create one main game window where other API will draw everything to, it probably would be better to use pure API. Even better use pure Assembly... now that I think about it, Assembly is too slow, so use pure machine code. Machine code is the easiest thing in the world!
Okay, here it goes. I overrode WindowProc in my only window and let my program run for 20 seconds. Each time a message was received, I TRACEd the message number, timestamp, message, wParam and lParam. The results are:

  Loaded symbols for ''e:\cpp\lonestar\string\debug\lsstring.dll''Loaded symbols for ''e:\cpp\lonestar\ark3d\debug\lsark3d.dll''Loaded symbols for ''e:\cpp\lonestar\glfonttest\debug\lsglfonttest.dll''Loaded ''ntdll.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\kernel32.dll'', no matching symbolic information found.Loaded symbols for ''D:\WINDOWS\system32\dxfcd.dll''Loaded symbols for ''D:\WINDOWS\system32\MFC42D.DLL''Loaded symbols for ''D:\WINDOWS\system32\MSVCRTD.DLL''Loaded ''D:\WINDOWS\system32\gdi32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\user32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\advapi32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\rpcrt4.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\ole32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\oleaut32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\msvcrt.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\nvdesk32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\MSCTF.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\clbcatq.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\comres.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\version.dll'', no matching symbolic information found.Loaded symbols for ''D:\WINDOWS\system32\GLBMPd.dll''Loaded ''D:\WINDOWS\system32\opengl32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\glu32.dll'', no matching symbolic information found.Loaded symbols for ''D:\WINDOWS\system32\ddraw.dll''Loaded ''D:\WINDOWS\system32\dciman32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\d3dx8d.dll'', no matching symbolic information found.Direct3D8: (INFO) :    ModeXOnly: 0Direct3D8: (INFO) :    EmulationOnly: 0Direct3D8: (INFO) :    ShowFrameRate: 0Direct3D8: (INFO) :    EnablePrintScreen: 0Direct3D8: (INFO) :    DisableAGPSupport: 0Direct3D8: (INFO) :    DisableMMX: 0Direct3D8: (INFO) :    DisableWiderSurfaces:0Direct3D8: (INFO) :    DisableNoSysLock:0Direct3D8: (INFO) :    ForceNoSysLock:0Direct3D8: (INFO) :    DisableInactivate:0Direct3D8: (INFO) :NOT Setting DDCAPS_BANKSWITCHEDDirect3D8: (WARN) :Checking Processor for MMX support (Benign first-chance exception possible)Direct3D8: (INFO) :This is an MMX machine.Direct3D8: (INFO) :*********** NOT!! ALLOWING MODE X AND VGA MODESDirect3D8: :   CreateSurface returns 00000000 (0)Loaded ''D:\WINDOWS\system32\ijl15.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\comctl32.dll'', no matching symbolic information found.Loaded ''D:\Program Files\Microsoft Hardware\Mouse\point32.dll'', no matching symbolic information found.--Tunnel Effect plugin initializedMessage   1 at  0.00: 0x81, 0, 1242448Message   2 at  0.00: 0x83, 0, 1242520Message   3 at  0.00: 0x1, 0, 1242428Loaded ''D:\WINDOWS\system32\dinput8.dll'', no matching symbolic information found.Loaded symbols for ''D:\WINDOWS\system32\dinput8d.dll''Loaded ''D:\WINDOWS\system32\hid.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\setupapi.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\winmm.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\ctwdm32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\ctwdm32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\ctwdm32.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\nvoglnt.dll'', no matching symbolic information found.Loaded ''D:\WINDOWS\system32\mcd32.dll'', no matching symbolic information found.--Tunnel Effect plugin: loading graphics...D3DX: (INFO) Using 3DNow Instructions--Tunnel Effect plugin: graphics loading finishedMessage   4 at  0.21: 0x5, 0, 65537400LS Driver: Update resize codeMessage   5 at  0.21: 0x3, 0, 6553700Message   6 at  0.21: 0x1c, 0, 128Message   7 at  0.23: 0x18, 1, 0Message   8 at  0.23: 0x46, 0, 1244212Message   9 at  0.23: 0x46, 0, 1244212Message  10 at  0.24: 0x1c, 1, 128Message  11 at  0.24: 0x86, 1, 0Message  12 at  0.25: 0x6, 1, 0Message  13 at  0.25: 0x36e, 1, 1243032Message  14 at  0.25: 0x7, 0, 0Message  15 at  0.25: 0x86, 0, 0Message  16 at  0.25: 0x36d, 4, 0Message  17 at  0.25: 0x0, 0, 0Message  18 at  0.25: 0x85, 1, 0Message  19 at  0.25: 0x14, 1761678333, 0Message  20 at  0.25: 0x47, 0, 1244212Message  21 at  0.25: 0x88, 4, 0Message  22 at  0.25: 0x7f, 2, 0Message  23 at  0.25: 0x7f, 0, 0Message  24 at  0.25: 0x7f, 1, 0Loaded ''D:\Program Files\Microsoft Hardware\Mouse\Msh_zwf.dll'', no matching symbolic information found.Message  25 at  0.26: 0x362, 57345, 0Message  26 at  0.26: 0xc288, 2, 0Message  27 at  0.26: 0xf, 0, 0Message  28 at  0.26: 0x363, 1, 0Loaded ''D:\WINDOWS\system32\mslbui.dll'', no matching symbolic information found.Message  29 at  0.89: 0x363, 1, 0Message  30 at  0.89: 0x363, 1, 0Message  31 at  0.90: 0x363, 1, 0Message  32 at  0.90: 0x363, 1, 0Message  33 at  0.91: 0x363, 1, 0Message  34 at  1.09: 0x363, 1, 0Message  35 at  1.10: 0x363, 1, 0Message  36 at  1.12: 0x363, 1, 0Message  37 at  1.13: 0x363, 1, 0Message  38 at  1.13: 0x363, 1, 0Message  39 at  1.14: 0x363, 1, 0Message  40 at  1.15: 0x363, 1, 0Message  41 at  1.16: 0x363, 1, 0Message  42 at  1.22: 0x363, 1, 0Message  43 at  1.23: 0x363, 1, 0Message  44 at  1.23: 0x363, 1, 0Message  45 at  1.25: 0x363, 1, 0Message  46 at  1.25: 0x363, 1, 0Message  47 at  1.27: 0x363, 1, 0Message  48 at  1.27: 0x363, 1, 0Message  49 at  1.28: 0x363, 1, 0Message  50 at  1.29: 0x363, 1, 0Message  51 at  1.48: 0x363, 1, 0Message  52 at 20.56: 0x104, 18, 540540929Message  53 at 20.56: 0x363, 1, 0Message  54 at 20.59: 0x104, 115, 540934145Message  55 at 20.59: 0x215, 0, 0Message  56 at 20.59: 0x0, 0, 0Message  57 at 20.59: 0x112, 61536, 0Message  58 at 20.59: 0x10, 0, 0Message  59 at 20.59: 0x18, 0, 0Message  60 at 20.59: 0x46, 0, 1240976Message  61 at 20.60: 0x47, 0, 1240976Message  62 at 20.61: 0x86, 0, 0Message  63 at 20.61: 0x6, 0, 0Message  64 at 20.61: 0x36e, 0, 1239428Message  65 at 20.61: 0x86, 0, 0Message  66 at 20.61: 0x36d, 8, 0Message  67 at 20.61: 0x1c, 0, 128Message  68 at 20.62: 0x8, 0, 0Message  69 at 20.62: 0x46, 0, 1240936Message  70 at 20.62: 0x47, 0, 1240936Message  71 at 20.63: 0x2, 0, 0LS Driver: Update destroy codeMessage  72 at 20.64: 0x82, 0, 0--Tunnel Effect plugin shut down (0x00000000)The thread 0x990 has exited with code -1073741749 (0xC000004B).Direct3D8: (INFO) :Resetting primary surfaceDirect3D8: (INFO) :Mode was never changed by this appDirect3D8: (INFO) :MemFini!The thread 0xD08 has exited with code 0 (0x0).The program ''E:\cpp\LoneStar\Driver\Debug\Driver.exe'' has exited with code 0 (0x0).  

As you can see, there were NO messages received between 2 and 20 seconds. Now, to my question: how does MFC slow you down if its code isn''t executed?
---visit #directxdev on afternet <- not just for directx, despite the name
*shrugs*
Use Spy++, and you should see a few more. Even if not, whatever messages received will result in some overhead. Maybe negligable, but it''s so pointless to accept that overhead when using the raw API in a game is more than easy.
I guess we can''t possibly convince each other.
---visit #directxdev on afternet <- not just for directx, despite the name
quote:Original post by IndirectX
Don''t forget that MFC provides you with a load of debugging tools.

Wrappers around CRT debugging tools, and MFC-specific.

quote:
Sure you can use STL, but does your STL ASSERT when you pass -1 to vector''s operator []?

No. But it throws an exception on certain illegal operations, which are more useful (since they''re portable, unwind the stack, etc etc).

quote:
Unless you are writing a 64K demo, I have yet to see a good reason not to use MFC in every program that creates a window.

It''s called the WTL. Leaner, more modern (which results in cleaner design) and generic.

I''m not supporting either side of the argument; I''m introducing a third. While the WTL is still completely undocumented, there are efforts at remedying that based on perusing the sources (most notably at The Code Project). It''s a much leaner toolkit, designed as the GUI complement to the ATL (which rocks for COM!) Thought some might like to know.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Oh, and assert is an ANSI macro defined in <cassert>.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement