Thread: Catching tab or enter in an EDIT control in a regular window

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    125

    Preventing the user from aligning text in an edit box left and right

    (original main problem resolved, see edit below)

    OK, here's my problem.
    I've got a regular window (made with CreateWindowEx) with a bunch of edit controls in a row (also made with CreateWindowEx in the first window's WM_CREATE) in each of which the user has to enter 0, 1 or 2 characters. To be able to do this at any kind of acceptable speed I want the user to be able to go to the next control by pressing Tab (like you would in a dialog) or Enter, or when there's already 2 characters in the box. I've managed to do the latter, but for the life of me I can't figure out how to catch an Enter, and I don't even know where to start looking for Tab.
    Here's the code I've got so far (still a little beefy for a forum post, but hey, it's Windows and I couldn't make it any shorter than this, sorry 'bout that)

    *code no longer necessary after edit*

    I've tried searching the MSDN for a few hours and read this tutorial http://winprog.org/tutorial/ (and the accompanying FAQ) several times over but came up blank; the only examples I found all applied to dialogs, not regular windows.
    Any help on how to get this (switching to the next control when the user presses enter or tab) to work or where to find out how would be greatly appreciated!

    (edit) Oops. I had the forum set to showing only posts one month old, so after checking what I thought were all posts I didn't think I needed to do a search. The question has already been answered more than adequately before by adrianxw: http://cboard.cprogramming.com/showt...threadid=34436 My other question is still relevant though:


    Another little thing, is it possible to prevent the user to right-click on a control and align the text to the left or right? I've found on the MSDN how to catch the user doing this in the parent window, but can't figure out how to center it again after it's happened (there doesn't seem to be a function or message for that). Thanks in advance!
    Last edited by Boksha; 11-19-2005 at 01:21 PM.
    Typing stuff in Code::Blocks 8.02, compiling stuff with MinGW 3.4.5.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tab order in Tab Control
    By Halloko in forum Windows Programming
    Replies: 2
    Last Post: 05-08-2005, 11:08 PM
  2. Buttons + Edit Control
    By jay kay in forum Windows Programming
    Replies: 6
    Last Post: 03-09-2005, 05:36 PM
  3. Dialog Edit Control and Enter Key
    By Quantrizi in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2004, 07:59 AM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM