Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

GetWindowText gives error 1400

$
0
0
Hello.

I am getting error 1400 for somereason when calling GetWindowText. However  GetWindowTextLenght gives me proper value. Why does GetWindowTextLenght work when GetWindowText gives error 1400? The handle is same for both so it cant be problem.

char* WinGetTitle(HWND hWnd){
	int lenght = GetWindowTextLength(hWnd);
	wchar_t* title = L"";
	GetWindowText(hWnd,title,lenght+1);
	printf("%d\n",GetLastError());
	return (char*)title;
}

This is how I test this function:
printf("Title: %s\n", WinGetTitle(GetForegroundWindow()));


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>