🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #3269

Controlling the input focus

#3269
From: Steven Dollins
Date: Mon, 17 Jun 1991 00:55
32 lines
1912 bytes
Hi, all.
    The program I'm working on has a dialog box that contains an edit
field.  The edit field should only accept integers in a specified range.
If the user enters a non-integer or an integer out of the specified
range and then attempts to leave the edit control, the program pops up
an error message box.
    When the user rids himself of the error message, I would like the
input focus to return to the edit control, forcing the user to enter a
valid number.  Here's what I have so far:

    case IDSLICE_INDEX:     /* ID for the edit field. */
        if (HIWORD(lParam)==EN_KILLFOCUS) {
            iIndex = GetDlgItemInt(hwnd, IDSLICE_INDEX, &bErr, FALSE);
            if (!bErr || (iIndex>iMaxIndex)) {
                wsprintf(TextBuf,
                    "The index must be between 1 and %d.", iMaxIndex);
                ErrMsg(TextBuf);
                return FALSE;
            }
        }
        break;

    Is there any simple way to put the input focus back if the user
tries to TAB to another field or, in the worst case, tries to hit OK?
The user should, on the other hand, have the option to "Cancel".

    Suggestions anyone?

                                        - Steven Dollins
                                          sdollins@ncsa.uiuc.edu

    "We have no theology.  We have no philosophy.  We dance."
Technical Details
Message-ID: <1991Jun17.005532.4543@ux1.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!ux1.cso.uiuc.edu!yoyodyne!sdollins

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!ux1.cso.uiuc.edu!yoyodyne!sdollins
From: sdollins@yoyodyne.ncsa.uiuc.edu (Steven Dollins)
Newsgroups: comp.windows.ms.programmer
Subject: Controlling the input focus
Message-ID: <1991Jun17.005532.4543@ux1.cso.uiuc.edu>
Date: 17 Jun 91 00:55:32 GMT
Sender: usenet@ux1.cso.uiuc.edu (News)
Organization: National Center for Supercomputing Applications at Urbana Illinois
Lines: 32