Thread: Creating own, focusable, control

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    245

    Creating own, focusable, control

    I want to create an object on a window that accepts user input (keyboard & mouse), but is completely drawn by my own program and can take the focus.

    Doing most of this seems quite easy - I can draw on the window directly with no problems, and get WM_KEYDOWN etc and mouse messages, but of course, since there's no actual control there, I can't shift the input focus to that part of the window. Since the window contains other controls (such as edit boxes) this makes it difficult for me to see whether I should be accepting the input for my control or not.

    I could take a listview, listbox, etc and do complete custom drawing, but that seems overkill for the simple task I want.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Seems your options are:

    1. Subclass/superclass an existing windows control.
    2. Create your own diy registered window.
    3. Continue as you are.

    Assuming 3 is what you want to do then i'm not sure what aspect of 'focus' is troublesome for you since you seem to be in control of mouse and keyboard messages. If it's the visual aspect ie the focus rectangle then DrawFocusRect may be what you need.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    The problem is that I have a number of edit boxes on my form, and Windows will not allow the focus to move out of these boxes because it assumes that there's nothing else that can accept input. So, in effect, once you click the mouse into one of these, I can't click back to my own "control".

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Unless you handle control TABbing/focus yourself (set the focus to main/parent window to shift it away from a 'normal' control so that control no longer appears selected) I think you may be left with implementing either option 1 or 2.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    I will have a look to see if I can handle tabbing myself (not sure how yet), but if I can't work it out, or it appears too complex, then I may just do a simple DIY window.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Creating Functions that use Format control Strings
    By tzuchan in forum C Programming
    Replies: 6
    Last Post: 03-29-2004, 12:50 PM
  4. creating an activex control
    By Benzakhar in forum Windows Programming
    Replies: 9
    Last Post: 12-29-2003, 06:32 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM