Sign in to follow this  
incertia

CreateWindowExW not setting window title

Recommended Posts

This is a really odd problem I have never experienced.

This is how I initialize my window:
 
CWindow::CWindow(WNDCLASSEXW *pWndClass, Infinity::INFINITY_WND_DESC *pWnd_Desc)
: m_refCount(1UL), m_hWnd(nullptr) {
	//Set m_wc
	memcpy(&this->m_wc, pWndClass, sizeof(this->m_wc));

	//Register the class provided
	RegisterClassExW(&this->m_wc);

	//Create the window
	this->m_hWnd = CreateWindowExW(pWnd_Desc->dwExStyle, pWnd_Desc->lpClassName, pWnd_Desc->lpWindowName, pWnd_Desc->dwStyle, pWnd_Desc->x, pWnd_Desc->y, pWnd_Desc->nWidth, pWnd_Desc->nHeight, pWnd_Desc->hWndParent, pWnd_Desc->hMenu, pWnd_Desc->hInstance, pWnd_Desc->lpParam);
}
and I pass L"blargh" as lpWindowName. However, when the window pops up, it has no text in the title bar. Has anyone else had the same problem before?

Share this post


Link to post
Share on other sites

You might try passing (LPCWSTR)"blargh" rather than L"blargh"


Why would you convert a const char* pointer to a const wchar_t*? I can't think of a situation where that even makes sense.

Share this post


Link to post
Share on other sites

 

You might try passing (LPCWSTR)"blargh" rather than L"blargh"


Why would you convert a const char* pointer to a const wchar_t*? I can't think of a situation where that even makes sense.

 

He isn't. Did notice the title of the thread? CreateWindowExW points out that this is a unicode build.

Share this post


Link to post
Share on other sites
No, that's exactly what's going on. "blargh" is a narrow character literal no matter what the compiler settings are because it doesn't have either the L prefix or any of the TCHAR macros applied. (LPCWSTR)"blargh" the takes a narrow character string literal and casts it to a pointer to a wide character string.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this