views:

302

answers:

0

Hi - I'm posting this question again - as i got some potentially useful comments on my question, but unfortunately when i replied to the comments i got no answers. It seems that unless i post the question again, no one will look at it. Sorry if this is against StackOverFlow moral code - If it is - Then what is the way to resurface a question? Anyway, to the point :

I'm developing for Windows Mobile in C++, and i'm running into a problem - I added my window class, and in it i handle the keyboard input with my WndProc implementation. The problem is that i'm getting the wrong codes, and identifying keys such as the func key incorrectly. And to make it worse, the values i'm getting (the wParam of the WM_KEYDOWN message) differ between the two phones i have here for testing - who knows what will happen on other phones.

In my previous question, someone commented that i should not take notice of the WM_KEYDOWN message, but of the WM_CHAR message. But that is exactly the problem - On some keys i only get the WM_KEYDOWN message, without it followed by a WM_CHAR message - So Obviously there is a problem with the TranslateMessage (caused by me/API)

After playing around with it for ages, i found out that if i only create a window from the predefined "EDIT" class, i actually do get the input correctly ( in terms of letters/keys ). So the problem must not be in the phone, but rather the modes of getting messages (a bit of a newbie in win32, excuse me for lack of knowledge). I tried playing around with input modes, but sending a message to my window using EM_NUMBERS and the such, always failed.

So what i would want to do ( though i'm open for suggestions ), is somehow just get the characters from some hidden EDIT window, and forward them to my window. (Though i still need my window to have the focus so it would react correctly to messages different from WM_KEYDOWN and the like)

Is there any way to do this?

Thanks alot!!

Dan

here are some code extracts :

Class registration :
WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ROADMAP));
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = szWindowClass;

window creation
if (width == -1) width = CW_USEDEFAULT;
if (height == -1) height = CW_USEDEFAULT;
RoadMapMainWindow = CreateWindow(g_szWindowClass, szTitle, OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL,
NULL, g_hInst, NULL);

MessageLoop
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

WNDPROC excerpt
case WM_KEYDOWN:
{ WORD Code = (WORD)wParam;
int iRepeatTimes = (lParam & 0x0000FFFF);
int iScanCode = (lParam & 0x00FF0000) >> 16;
BOOL bALT_IsDown = (lParam & 0x20000000)? TRUE: FALSE;
BOOL bAlreadyPressed= (lParam & 0x40000000)? TRUE: FALSE;
BOOL bNowReleased = (lParam & 0x80000000)? TRUE: FALSE;
return DefWindowProc(hWnd, message, wParam, lParam);
}