Jump to content
  • Advertisement
Sign in to follow this  
incertia

CreateWindowExW not setting window title

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

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
Advertisement

Turns out that the problem was I was returning TRUE when handling WM_NCCREATE instead of forwarding it to DefWindowProc so the standard things were not performed.

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
m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, L"Title", L"Title", 
                        WS_OVERLAPPEDWINDOW, posX, posY, clientWidth, clientHeight, 
                        NULL, NULL, m_hinstance, NULL);

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!