CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Caret & WM_CHAR

  1. #1
    Join Date
    Aug 2007
    Posts
    4

    Caret & WM_CHAR

    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.
    [block]
    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;
    }
    [/block]

    can any one tell me what is wrong with the program

  2. #2
    Join Date
    Jun 2005
    Posts
    1,255

    Smile Re: Caret & WM_CHAR

    i cant get focus on child window
    Are 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 [code] and [/code] instead of [block] and [/block]. Write a capital letter at the start of your sentences. Write "I" instead of "i". Write "can't" or "cannot" instead of "cann't".

  3. #3
    Join Date
    Aug 2007
    Posts
    4

    Re: Caret & WM_CHAR

    Quote Originally Posted by olivthill
    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 [code] and [/code] instead of [block] and [/block]. 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
    Last edited by johny_1015_1981; October 23rd, 2008 at 12:57 AM.

  4. #4
    Join Date
    Jun 2005
    Posts
    1,255

    Smile Re: Caret & WM_CHAR

    create caret
    I 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().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured