Jump to content
  • Advertisement
Sign in to follow this  
AlexanderXXX

Weird WM_CHAR Problem

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

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!