• Advertisement

Archived

This topic is now archived and is closed to further replies.

Win32 programming confusion

This topic is 5060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I''ve had 2 questions about win32 programming that have been confusing me for quite some time. First, if your not using MFC when and where do you declare the #WIN_32_LEAN_AND_MEAN macro? Do you need to use it every time a source file uses windows.h? Can I just declare it once in some random source file and my program will be good from MFC? Second, what does stdafx stand for? I see it in a lot of programs that want to store their std header information somewhere. Why must I use such a weird name for my general include map! Ok thanks for any help :]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by xorjesus
First, if you''re not using MFC when and where do you declare the #WIN_32_LEAN_AND_MEAN macro?
Before you include windows.h or any other Win32 header.

quote:
Do you need to use it every time a source file uses windows.h?
Yes, if you want its effects.

quote:
Can I just declare it once in some random source file and my program will be good from MFC?
Short version: No.

quote:
Second, what does stdafx stand for?
It''s the name of a special file used by MSVC for precompiled header functionality. Look through your IDE documentation for more info.

Share this post


Link to post
Share on other sites
You define WIN_32_LEAN_AND_MEAN before you include your windows header file. It is not a macro, it is a flag. If you have a look at your compiler windows header file, you will find directives like :

#ifdef WIN_32_LEAN_AND_MEAN
...include this...
...declare that...
#else
...do something else...
#endif

A look at these instructions show that WIN_32_LEAN_AND_MEAN flag is used to trim your windows header down to the strict minimum to be able to create and manage a window.

Regarding the stdafx file, I guess you are using Microsoft Visual C++. I would advise you to check your own manual since this is specific to that compiler. (I have Borland C++ 5.01).

Hope that helps.
Ghostly yours,
Red.

Share this post


Link to post
Share on other sites

  • Advertisement