Click to See Complete Forum and Search --> : Caret & WM_CHAR


johny_1015_1981
October 21st, 2008, 08:32 AM
1-> i am trying to add a caret on child window(not on typical class)
but cann't create the reason is i cant get focus on child window even if i create without having focus it doesnt show up.
2-> i added a WM_CHAR message in child windows message handler function. the problem is when i press first character it change the mouse cursor with hourglass. if i move the mouse mouse cursor came back to normal. but message does not processed. in this situation if i press 'Alt' window message is processed.

LPRESULT __stdcall ChildWndProc(HWND,UINT msg,WPARAM,LPARAM)
{
switch(msg)
{
case WM_CHAR:
MessageBox(NULL,TEXT("Message"),TEXT("Caption"),MB_OK);
return 0;
}
return 0;
}


can any one tell me what is wrong with the program

olivthill
October 22nd, 2008, 12:13 PM
i cant get focus on child windowAre you using SetFocus() with a correct handle?
if i create without having focus it doesnt show up.What is "it"?

Your piece of code looks all right to me. The problem should reside elsewhere.
For your other questions, it is difficult to give an answer without seeing your source code.

N.B. Use and instead of and . Write a capital letter at the start of your sentences. Write "I" instead of "i". Write "can't" or "cannot" instead of "cann't".

johny_1015_1981
October 23rd, 2008, 01:49 AM
Are you using SetFocus() with a correct handle?
What is "it"?

Your piece of code looks all right to me. The problem should reside elsewhere.
For your other questions, it is difficult to give an answer without seeing your source code.

N.B. Use and instead of and . Write a capital letter at the start of your sentences. Write "I" instead of "i". Write "can't" or "cannot" instead of "cann't".

the problem is not with setfocus. the problem is more disgusting but not complicated.

the problem is
I have created a window as a child then I wanted to create a caret on the child window.
The policy of creating caret is programmer will create caret when the winow will get focus. but my child window never get focus.
even if i Call SetFocus then the WM_KILLFOCUS is called and focus is lost and also the caret get destroyed

olivthill
October 23rd, 2008, 05:35 AM
create caretI presume you are talking about the cursor (the hourglass or the arrow) and not about the caret (a blinking bar in an edit control).
The policy of creating caret is programmer will create caret when the winow will get focus.Are you sure? Usually, the cursor is the one that is chosen when the class of your window is registered. You can change it later with SetCursor() and ShowCursor().