Jump to content
  • Advertisement
Sign in to follow this  

A small problem with CreateWindow()

This topic is 3020 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 folks, I am just getting started with DirectX programming and have encountered a small problem regarding CreateWindow(). It's not a major issue, as the code compiles, and a blank window is created as expected - however my niggle is this: In the title bar of the window, instead of the specified title that I would like it to have, I am being shown a number of odd characters (mainly squares) followed by the final letter of the string that I am passing to parameter 2 of the CreateWindow(). I have done a bit of googling and can find no solutions to the problem. I shall paste the small amount of code that I think is causing the problem (I won't bother you with the rest of it, it's pretty boring :P)
bool initWindow( HINSTANCE hInstance )

	wcex.cbSize			= sizeof(WNDCLASSEX);
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc		= (WNDPROC)WndProc;
	wcex.cbClsExtra			= 0;
	wcex.cbWndExtra			= 0;
	wcex.hInstance			= hInstance;
	wcex.hIcon			= 0;
	wcex.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground		= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName		= NULL;
	wcex.lpszClassName		= (LPCWSTR)"Foo";
	wcex.hIconSm			= 0;

	LPCWSTR appName = (LPCWSTR)"Foo";
	LPCWSTR titlebarText = (LPCWSTR)"Bar";

	wndHandle = CreateWindow(

I will endeavour on while I accumulate some replies (which would be appreciated), but don't feel you need to rush to my aid, as it's such a minor issue. Much love! Culgan

Share this post

Link to post
Share on other sites
What happens if you change



I personally have never encountered any problems when using that macro.
More information about TEXT(str) can be found here.

Share this post

Link to post
Share on other sites
Thank you both for the speedy replies.

The problem was rectified after reading the first article you posted Evil Steve.

About the second one:

I'll be honest, I'm learning DirectX from a collection of books that I have purchased.
When I saw that it was casting the WndProc function pointer, it brought back some scary memories from when I first started programming C++, and a number of instances when casting function pointers has been used by people I work with - which let's say did not have the desired effect.

So, I was wary of the fact that the book I am learning from seems to recommend using this method, I shall proceed with due care.

Thank you again for your help.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!