PDA

View Full Version : createwindow title messed up



whiack
05-31-2016, 06:41 AM
This is how I created my window. I'm creating it in ASCII, the title showed is random characters.
I'm using cygwin in windows. this code works totally fine with virtual studio 2010. with CreatWindow without A. However, I cannot compile CreateWindow here.

What I have tried:
change 1 to static wchar_t szTitle[] = L"Getting..."
change 1 to static wchar_t szTitle[] = _T(str)
change 2 to L"Getting..."
change 2 to _T(str)


static char szAppName[] = "OpenGL";
1. static char szTitle[]="Getting Started With OpenGL";

hWnd = CreateWindowA(
szAppName, // app name
2. szTitle, // Text for window title bar
WS_OVERLAPPEDWINDOW// Window style
// NEED THESE for OpenGL calls to work!
| WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
left, top, width, height,
NULL, // no parent window
NULL, // Use the window class menu.
m_hInstance,// This instance owns this window
NULL // We don't use any extra data
);

Alfonse Reinheart
05-31-2016, 06:46 AM
Besides the fact that you used the string "OpenGL", what does this question have to do with OpenGL? This is clearly a Win32 issue, and it probably has to do with some ANSI locale setting or somesuch.

Agent D
05-31-2016, 06:47 AM
Ther are two versions of CreateWindow (and similar functions): CreateWindowW that supports wide characters and CreateWindowA that doesn't.

If you have "UNICODE" defined via the preprocessor inclusion of the winapi header containing the declaration, CreateWindow is defined to
CreateWindowW. If you don't have UNICODE defined, it points to CreateWindowA.

VisualStudio has the macro UNICODE defined by default in the project settings.

Edit: Also, as Alfonse Reinheart pointed out, this not an OpenGL related problem in any way whatsoever.

whiack
05-31-2016, 06:57 AM
oh, thank you. I thought of that. But I just want to make sure there is no problem with the code.