Print HWND to messagebox
How to print HWND value to MessageBox in visual c++?
Update:
I tried to print the handle ID to a messagebox, but instead it ap开发者_如何学编程pears with Chinese characters. Here's the code I'm working on ..
char szBuff[64];
sprintf(szBuff, "%p", m_hWnd);
MessageBox(NULL, LPCWSTR(szBuff), L"Test print handler", MB_OK);
A HWND is just a pointer.
char szBuff[64];
sprintf(szBuff, "%p", hWnd);
MessageBox(NULL, szBuff, "Title", MB_OK);
Update
Sounds like you are having trouble with wide and narrow characters (ASCII and UTF-16). Try the following:
#include <Windows.h>
#include <cstdio>
int _tmain(int argc, TCHAR* argv[])
{
HWND hWnd=::GetConsoleWindow();
TCHAR szBuff[64];
_stprintf(szBuff, _T("%p"), hWnd);
MessageBox(NULL, szBuff, _T("Title"), MB_OK);
return 0;
}
精彩评论