Results 1 to 3 of 3

Thread: API edit control losing focus on arrow keys

  1. #1

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    API edit control losing focus on arrow keys

    This thing keeps me in "what the..." category: whenever I push an arrow key in an edit control that I have created using API, the focus moves to any other control that is available. However, none of the tutorials, guides etc. have a mention about this feature. What causes this and how can I get the "normal" behavior for the arrow keys? Page up, down, home and end are working, but arrow keys not.

    Also, I haven't seen a style flag that would affect this behavior.

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: API edit control losing focus on arrow keys

    I couldn't duplicate the problem.
    Are you sure something isn't wrong in WndProc ? Have you tried in a fresh project ?
    Can you post the code ?
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: API edit control losing focus on arrow keys

    For more details, I've wrapped the control in an usercontrol; and I can't make it much more "fresh" than it is.

    VB Code:
    1. ' init styles
    2.     lngStyle = WS_CHILD Or WS_VISIBLE Or ES_NOHIDESEL
    3.     If m_MultiLine Then
    4.         Select Case m_ScrollBars
    5.             Case vbSBNone
    6.                 lngStyle = lngStyle Or ES_MULTILINE Or ES_AUTOVSCROLL Or ES_AUTOHSCROLL
    7.             Case vbHorizontal
    8.                 lngStyle = lngStyle Or ES_MULTILINE Or ES_AUTOHSCROLL Or WS_HSCROLL
    9.             Case vbVertical
    10.                 lngStyle = lngStyle Or ES_MULTILINE Or ES_AUTOVSCROLL Or WS_VSCROLL
    11.             Case vbBoth
    12.                 lngStyle = lngStyle Or ES_MULTILINE Or ES_AUTOHSCROLL Or WS_HSCROLL Or WS_VSCROLL
    13.         End Select
    14.     Else
    15.         lngStyle = lngStyle Or ES_AUTOHSCROLL
    16.     End If
    17.    
    18.     ' create new textbox
    19.     m_hWnd = CreateWindowExW(0&, StrPtr("Edit"), StrPtr(m_Text), _
    20.         lngStyle, _
    21.         m_BorderStyle, m_BorderStyle, m_RC.Right - m_BorderStyle * 2, m_RC.bottom - m_BorderStyle * 2, _
    22.         UserControl.hWnd, 0&, App.hInstance, 0&)

    This is the part of the code that creates the edit control; before that only properties are read, then this code is next to be called. The only other extra I can think of is that the host usercontrol redirects the focus automatically to the edit control. Nothing else should have effect on the default behaviour of the control.

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