Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

c++ Why am I getting CreateWindowW, when I call CreateWindow ?

This topic is 4818 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, i've got two projects, with the same code. One was created from the Visual c++ 2005 beta 1, and the other was created in beta 2 version. With the beta1, when I call 'CreateWindow', which is when I put my mouse over it, says 'CreateWIndowA' has been defined as 'CreateWindow'. But with beta2 the 'CreateWindow' has been defined as 'CreateWindowW'. I've looked through the two different project files, and I can't see any major differences that would cause the two projects to get a different definition of the 'CreateWindow' function. Anyone know what is going on here? Thanks

Share this post


Link to post
Share on other sites
Advertisement
CreateWindow is (along with many other Win32 functions) mapped to one of two functions, CreateWindowA or CreateWindowW, depending on whether or not UNICODE has been defined. Your project in beta2 apparently has unicode defined, so you're getting the wide character version of the function. I'm away from my own computer right now, but some googling says you should be able to remove the unicode flag by doing the following:

-Look under Project Settings -> C/C++ tab -> Category: General -> Preprocessor Definitions
-Remove UNICODE and/or _UNICODE

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Nemesis2k2
CreateWindow is (along with many other Win32 functions) mapped to one of two functions, CreateWindowA or CreateWindowW, depending on whether or not UNICODE has been defined.

winuser.h:
#ifdef UNICODE
#define CreateWindow CreateWindowW
#else
#define CreateWindow CreateWindowA
#endif // !UNICODE

Quote:
Original post by Nemesis2k2
...to remove the unicode flag by doing the following:

Sure, but there's really no good reason to do this, unless you need to run on Windows 9x.

Windows NT/2000/XP and upcoming versions of Windows are all natively designed for Unicode.

CreateWindowW is the actual implementation, CreateWindowA is only a wrapper that converts CHAR strings to WCHAR strings and then calls CreateWindowW. This holds for all Win32 APIs that has both A and W versions. So from a performance point of view it's better to use the WCHAR versions. Of course it also makes your applications easier to localize.

Share this post


Link to post
Share on other sites
Read chapter 2 of Charles Petzold's "Programming Windows". It explains the situation and rationale for _UNICODE quite well.

Share this post


Link to post
Share on other sites
Macros. Yuck. This really annoys me when creating OO wrappers around the Win32 API. They didn't even bother with the all caps naming convention for macros.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nitage
Macros. Yuck. This really annoys me when creating OO wrappers around the Win32 API. They didn't even bother with the all caps naming convention for macros.


Well its nice you think this way:) but the win32 api is C not C++, you can't impose your own arbitrary decisions on the rest of the programming world. The reason they don't use the all caps naming convention is two fold a) its just your convention not a standard, b) they wan't it to look like a funtion call as that's how it was from the windows 3.1 days. This way other people dont' have to modify their code.

Just because you've never worked on a serious project doesn't mean others haven't. Maintaing legacy code is very important, and your "rant" would cause most of it to break.

EDIT, sorry that came off alittle harsh on you, didn't mean it to:) You just need to learn that most microsoft "hacks" are acutallly very well thought out and implemented by people who have forgotten more about programming than we'll ever know:)

Cheers
Chris

Share this post


Link to post
Share on other sites
Good post [smile]

Quote:
Original post by chollida1
You just need to learn that most microsoft "hacks" are acutallly very well thought out and implemented by people who have forgotten more about programming than we'll ever know
[lol] I presume you didn't mean "forgotten" in that sentence?! Either way it's funny, you get a cookie.

Jack

Share this post


Link to post
Share on other sites
That's a common saying - think Grandpa Simpson voice:
"Listen here sonny, I've forgotten more than you'll ever know!"

It took me about 26 years before I really started listening to my dad. Hopefully it won't take other people quite so long.

Share this post


Link to post
Share on other sites
Quote:
Quote:
Original post by Nemesis2k2
...to remove the unicode flag by doing the following:

Sure, but there's really no good reason to do this, unless you need to run on Windows 9x.

Windows NT/2000/XP and upcoming versions of Windows are all natively designed for Unicode.

He'd already posted with problems created by this. I was trying to just give him what he wanted and avoid a followup post. A bit lazy on my behalf I'll grant you, but anyway.

Quote:
CreateWindowW is the actual implementation, CreateWindowA is only a wrapper that converts CHAR strings to WCHAR strings and then calls CreateWindowW. This holds for all Win32 APIs that has both A and W versions. So from a performance point of view it's better to use the WCHAR versions.

I didn't know that; thanks for the tip.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!