Weird WM_CHAR Problem

Started by
12 comments, last by AlexanderXXX 18 years, 9 months ago
When I input a Chinese character in the CustomUI sample's EditBox at \Samples\C++\Direct3D\CustomUI, its WM_CHAR message will only trigger one time. But it triggers TWO TIMES in my program and I just cannot understand why T T. Is sombody know what is the keypoint I missed? Thanks for ur help.
Advertisement
For example:
I input a '去' character
Sample program get a value 21435 at wParam of the Message
But my program get two(first 165, second 104) at wParam
That's really weird (=.=)a
can sombody help me >"<
i wont reply this article if no more replys sry^^"
Could it be a diacritic? I had thought it may be a dead character but you should not get a WM_CHAR for that. Anyway check this link out, about half way down it mentions two messages if one is a diacritic:

Big long Microsoft MSDN page link
------------------------See my games programming site at: www.toymaker.info
Could you post your code?

edit: Also, does the same thing happen with English characters?
Hi AlexanderXXX,
Are you using the CDXUTEditBox class or the CDXUTIMEEditBox class?
AFAIK CDXUTIMEEditBox will be best for Chinese characters.
For the best information on CDXUTIMEEditBox in the SDK help file, search on:
"Input Method Editors: Using an IME in a Game"

HTH,
Cambo_frog
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
Quote:Original post by Daniel Miller
Could you post your code?


This is the code of the message passing,
I just can't recognize the difference from mine and the sample's @@

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int zDelta;
switch (message)
{
case WM_TIMER:
ExeTimer(wParam);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_MOUSEWHEEL:
zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
if ( zDelta > 0 ) engine.CameraZoom(camera1,10);
else if ( zDelta < 0 ) engine.CameraZoom(camera1,-10);
break;
case WM_CHAR:
if(!DIorWM) //the var that switch with DirectInput and WM_CHAR
{
switch( (WCHAR)wParam )
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
case VK_RETURN:
DIorWM = true;
engine.ENGInitKeyboard();
break;
default:
//WCHAR DispStr[256];
//int DispStrPtr = 0;
//they are for displaying the char
DispStr[DispStrPtr++] = (WCHAR)wParam;
}
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

and this is he code I draw the text:

font->DrawTextW(NULL, DispStr, -1, &frect, DT_TOP | DT_LEFT, 0xff000000);

and this is the result clip:
BEFORE ENTER DOWN -> http://myweb.ncku.edu.tw/~f7491402/be.jpg
AFTER ENTER DOWN -> http://myweb.ncku.edu.tw/~f7491402/ae.jpg

Quote:edit: Also, does the same thing happen with English characters?


English will only trigger one time in my program, so it's normal.

Quote:Original post by Cambo_frog
Hi AlexanderXXX,
Are you using the CDXUTEditBox class or the CDXUTIMEEditBox class?
AFAIK CDXUTIMEEditBox will be best for Chinese characters.
For the best information on CDXUTIMEEditBox in the SDK help file, search on:
"Input Method Editors: Using an IME in a Game"

HTH,
Cambo_frog


I've studied the code of that part few days ago.
And I'm wondering that if the messsage(WMCHAR) I get could be the same with the Calsses you mentioned above, I should be able to print out the Chinese characters too^^""

thanks all u guys helping me
I don't know, maybe setting character set to multi-byte or unicode during compilation would help? In VC++ 7.0 it is in: Project->Properties->General->Character Set.
Quote:Original post by ReaVeR-Andrey
I don't know, maybe setting character set to multi-byte or unicode during compilation would help? In VC++ 7.0 it is in: Project->Properties->General->Character Set.


I would definitely try that, even though I'm not sure whether it would help (I think WCHAR is wide no matter what).


Could you post your code and the sample's code together? Put your code inside of this: [#source] [#/source] without the #s.

This topic is closed to new replies.

Advertisement