Jump to content
  • Advertisement
Sign in to follow this  

A new way to create a window?

This topic is 4620 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

I'm transitioning to Visual Studio 2K5 and currently am trying to create a window, however I'm getting errors about the function unable to use standard char *, it requires LPCWSTR. I have no idea what these are, is there any alternative? I typecast my char * to this (the classname, and window title, and even my width and height arguments give me problems) but the window is all wierded out. The window has no pre-defined size (it shrunk to the minimum) and the title is in chinese characters. any help would be more than enjoyed!! -stealthgate

Share this post

Link to post
Share on other sites
VS 2005 uses the unicode versions of CreateWindow etc by default. You need to pass it unicode strings, rather than ASCII strings. To use these, use the type "WCHAR *" or "LPCWSTR" instead of "char *", and prefix your string literals with L, eg:

CreateWindow(..., L"Title", ...);

Share this post

Link to post
Share on other sites
I prefer using the _T macros because it will use wide characters where needed and regular characters where needed depending on whether UNICODE or MBCS is defined. Here's a simple example that will work the same whether UNICODE or MBCS is defined.

#include <iostream>
#include <tchar.h> // definition of TCHAR and lots of good stuff

// make sure we use the proper stream
// depending on whether UNICODE or MBCS is defined
#if defined(UNICODE)
std::wostream &out_stream = std::wcout;
std::ostream &out_stream = std::cout;

int main(int,char**){
out_stream << _T("Whaddup");
return 0;

Also in tchar.h there are a lot of the old c-style string functions that are defined to be either the UNICODE or MBCS versions. for example ::_tcslen will be ::wcslen in UNICODE or ::strlen in MBCS. Its very useful and saves time. However, I'm not sure if tchar.h is actually a standard header. But you should be fine using any of the MSVC products at least.

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!