CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2009
    Posts
    65

    Setting Keyboard Focus on a TEdit Control

    I basically have a InputQuery Box with a TEdit control. I obtain the handles(HWND) of both the Box & the Control.

    My only issue is that when the InputBox is displayed the TEdit control isn't focused by default, I have to press a key to make it take keyboard focus.

    Is there anyway (PostMessage?) through which I can give the focus to TEdit Control. Originally the Window has the control since if I press Down Arrow, the Move,Close Menu appears on the InputBox.

    P.S. I've tried WM_ACTIVATE, SETFOCUS,WM_KEYDOWN('A'). None work however the KEYDOWN does print an 'A' in the TEdit control however the keyboard focus is still not belonging to it.

    Regards,
    Nisheeth Barthwal

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Setting Keyboard Focus on a TEdit Control

    Quote Originally Posted by nbaztec View Post
    I basically have a InputQuery Box with a TEdit control. [...]
    Are they Visual C++ stuff?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Jun 2009
    Posts
    65

    Re: Setting Keyboard Focus on a TEdit Control

    Yes. A Form control having a Edit Box & Button. Only VCL.

  4. #4
    Join Date
    Jun 2009
    Posts
    65

    Re: Setting Keyboard Focus on a TEdit Control

    The problem is that after calling SetFocus, the Edit Box is in a paused state but it has focus (the cursor is visible but not blinking). So I have to press a key to remove it's paused status. WM_KEYDOWN does *not* work.

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Setting Keyboard Focus on a TEdit Control

    Quote Originally Posted by nbaztec View Post
    Yes. A Form control having a Edit Box & Button. Only VCL.
    • VCL (Visual Component Library)
      is a visual component-based object-oriented framework for developing Microsoft Windows applications. It was developed by Borland...
    • Visual C++
      is a integrated development environment (IDE) product engineered by Microsoft for the C, C++, and C++/CLI programming languages.

    Quite different, isn't it?
    Here is a Visual C++ forum and not a VCL one.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  6. #6
    Join Date
    Jun 2009
    Posts
    65

    Re: Setting Keyboard Focus on a TEdit Control

    Well my query considered the Message I needed to Post to the control(Edit Control), hence it was posted here. I agree there are far many differences b/w VCL, MFC/ VC++ but I only needed to know the message I needed to post & I have found it: WM_LBUTTONDBLCLK

    Thanks anyway.

    PS: VC++ & VCL both implement the Message Queue using the WNDPROC

  7. #7
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Setting Keyboard Focus on a TEdit Control

    Quote Originally Posted by nbaztec View Post
    PS: VC++ & VCL both implement the Message Queue using the WNDPROC
    Both wrap the same Windows API but in quite differnt concrete ways. Not any bad intention, just recommending a VCL forum to find better and quicker answers for VCL problems.
    However, if a problem is a Windows API problem and does not imply specific library (MFC, ATL, VCL, whatever else) implementation, you can ask in C++ and WinAPI forum.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  8. #8
    Join Date
    Jun 2009
    Posts
    65

    Re: Setting Keyboard Focus on a TEdit Control

    Thank you. I'll see to it next time. However I wish to point that thought the general syntax may differ yet solution for one is solution for other as underneath the functionality is the same.

    P.S. I thought of C++ & WinAPI forum earlier but the description: "This is a non-MFC forum" mis-leaded me since my original problem involves the Edit Controls - also native to MFC.

  9. #9
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Setting Keyboard Focus on a TEdit Control

    Quote Originally Posted by nbaztec View Post
    my original problem involves the Edit Controls - also native to MFC.
    Nope. Your original problem involves
    Quote Originally Posted by nbaztec View Post
    A Form control having a Edit Box & Button.
    Again: quite different stuff.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  10. #10
    Join Date
    Jun 2009
    Posts
    65

    Re: Setting Keyboard Focus on a TEdit Control

    Edit Box is a control on a Windows Form & so is the Button. Please elaborate how they don't belong to MFC. The only difference being - mine belongs to class TEdit & of MFC, to CEdit. As far as Message Queue is concerned both behave similarly to like messages.

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