PDA

View Full Version : SetLayeredWindowAttributes not recognized!


leojose
07-13-2005, 12:57 PM
HI all,

I am trying to use the function SetLayeredWindowAttributes() but unfortunately MSVC doesn't recognize it
I use VC++v6.0 with Windows Server 2003 SP1 SDK installed.
i have also include windows.h, user32.lib as defined in MSDN, but no hope.

What could be the problem?

aman
07-14-2005, 03:35 AM
See this article on Using the Windows Headers (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/using_the_windows_headers.asp)

You have to define the proper macros in order to use functions that aren't available in older versions of Windows. Take a look in winuser.h and you'll notice that SetLayeredWindowAttributes() is only available if #if(_WIN32_WINNT >= 0x0500) is true.

According to the docs, this function is only available in Windows2000 and above.

If you are compiling on Win2k, then you'll open Project->Settings->C/C++ tab and add add _WIN32_WINNT=0x0500to the Preprocessor definitions list, and any functions available in Win2k and above will be available to you.

Functions like this should be avoided if you can, because a program using them probably won't work properly on older versions of Windows. If that restriction is OK, then go for it. If not, then look for SetWindowLong() which is available in older versions of Windows, and is used to do similar things such as set window transparancy.

leojose
07-14-2005, 06:57 AM
hi aman,

THanks for the detailed reply
I am developing my code in WInXP now, but will need to test its compatibilty with older windows also. I guess your suggestions would prove useful then also. :)