views:

51

answers:

3

i want show a message dialog with a dword value like this

MessageBox(0, (LPCWSTR) hProcess ,TEXT("My MessageBox Info"),MB_OK | MB_ICONERROR);

hProcess is a DWORD value but it when messagebox appear , body part of message that should show dowrd value is empty.

+1  A: 
char *s = (char*)malloc(10);
sprintf(s, "%d", hProcess);
MessageBox(NULL, s, ...);
free(s);
Jonathan
it raise below error.error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR'
Phoenix
You can just cast it, sorry.MessageBox(NULL, (LPCWSTR)s, ...);
Jonathan
+1  A: 

First convert the value to a string, then display it in message box.

Take a look at this: ultoa

Markos
+3  A: 
TCHAR msg[100];

StringCbPrintf(msg, 100, TEXT("%d"), hProcess);

MessageBox(NULL, msg, TEXT("My MessageBox Info"), MB_OK | MB_ICONERROR);
gtikok
thank you a lot
Phoenix