Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

CreateWindowExW(A) issue

Moderators: larsivi kris

Posted: 10/13/09 18:12:29

After discovering some downsides of SDL other than major bloat, I wanted to try and just do a windows app sine the app i'm making will only be windows.

I found a topic in here about getting it up and running, but it didn't go into much detail.

I went and grabbed the phobos example and copied over the creation of a window.

Everything works fine, but the title of the window isn't correct. It only shows the first character of the char array i send it.

HINSTANCE hInst = GetModuleHandleA(null);
    	WNDCLASS wc;
    	wc.lpszClassName = "DWndClass";
    	wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    	wc.lpfnWndProc = &WindowProc;
    	wc.hInstance = hInst;
    	wc.hIcon = LoadIconA(cast(HINSTANCE) null, IDI_APPLICATION);
    	wc.hCursor = LoadCursorA(cast(HINSTANCE) null, IDC_CROSS);
    	wc.hbrBackground = cast(HBRUSH) (COLOR_WINDOW + 1);
    	wc.lpszMenuName = null;
    	wc.cbClsExtra = wc.cbWndExtra = 0;
    	auto a = RegisterClassW(&wc);
    	assert(a);
    	
    	HWND hWnd, btnClick, btnDontClick;
    	hWnd = CreateWindowExA(WS_EX_APPWINDOW, "DWndClass", "Just a window", WS_THICKFRAME |
    		WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE,
    		CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP,
    		cast(HMENU) null, hInst, null);
    	assert(hWnd);

All i get in the title bar is "J".

Any ideas on how to fix?

Author Message

Posted: 10/15/09 16:11:56

Try changing WNDCLASS to WNDCLASSA and RegisterClassW to RegisterClassA