• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

move from one editbox to another automatically(SDI)

I am trying to use two editboxes to hold a scanned in nine character ( 4 )-( 5 )control number.  I can't seem to find any info on automatically moving from one editbox to the next.  I thought I could some-how link the tab sequence on the controls in the SDI I am using.....?  I would greatly appreciate any help you could give me (a direction to point me in).  Thanks for your time.
0
ducksoup
Asked:
ducksoup
  • 6
  • 3
  • 2
  • +2
1 Solution
 
thresher_sharkCommented:
Would SetFocus fullfill your needs?  You might want to look into it, it is a member function of the CWnd class.  The way you could implement it would be something like:

1) Wait for edit box one to get filled up to 4 characters.
2) Once the limit is reached, use SetFocus to set the focus to the second edit box.

You can pass GetDlgItem (IDC_IDOFEDITBOX2)'s return value to the SetFocus function.

If you have further questions on how to implement this, please feel free to ask.  Thanks!
0
 
rwilson032697Commented:
You could also use WM_NEXTDLGITEM...
0
 
rwilson032697Commented:
Oops that should be WM_NEXTDLGCTL
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Answers2000Commented:
Use SetFocus as thresher suggested

Each edit control sends an EN_CHANGE notification to the parent window when it's contents change, use this to know when to move between controls.

Either

GetDlgitem( ID_EDIT ) -> SetFocus() ;

or

::SetFocus( ::GetDlgItem(m_hWnd,ID_EDIT) ) ;
0
 
Answers2000Commented:
Use SetFocus as thresher suggested

Each edit control sends an EN_CHANGE notification to the parent window when it's contents change, use this to know when to move between controls.

Either

GetDlgitem( ID_EDIT ) -> SetFocus() ;

or

::SetFocus( ::GetDlgItem(m_hWnd,ID_EDIT) ) ;
0
 
thresher_sharkCommented:
Perhaps I should "Answer" ?
0
 
thresher_sharkCommented:
Perhaps I should "Answer" ?
0
 
pagladasuCommented:
I think you should thresher_shark. You have started as a comment which is in the right direction.
0
 
Answers2000Commented:
Yep thresher
0
 
thresher_sharkCommented:
Okay.  ducksoup - If you have any questions implementing my solution, please feel free to ask.  Thanks!
0
 
ducksoupAuthor Commented:
thresher_shark, could you give me a little more info on SetFocus(), I researched this function but can't seem to get the syntax correct.  I have tried somethings but I am still struggling, here is one of the things I have tried.
      if (m_strControlNum1.GetLength() == 4) {
            SetFocus()->GetDlgItem(IDC_EDIT2);
            //CWnd *pEdit2 = GetDlgItem(IDC_EDIT2);
            //GotoDlgCtrl(pEdit2);
                  CDialog::OnOK();
          }
   This will compile and run with no effect on the cursor position.  Some of the other things I have tried won't compile.  Thanks for any help
0
 
thresher_sharkCommented:
Sure no problem.  What you want to do is add a handler for when the first edit box is updated like so:

void CYourDlg::OnChangeWhatever ()
{ UpdateData (TRUE); // Update numbers in variables.

  if (m_strControlNum1.GetLength () == 4)  // If 4 chars full
  { ::SetFocus (m_strControlNum2.GetSafeHwnd ()); // Set focus
    m_strControlNum1.SetSel (0, -1);  // Remove selection
  }
}

Also, one other note (for the future), you do not want to "accept" someone's answer until they have followed through completely with the solution.  Often the answers are vague and require clarification.  If that is the case either reject the answer or request clarification before awarding the points.  You see, some people will just answer and not follow through with it at all.

In any case, does that solve your problem?  If you have any other questions, please ask.  Thanks!
0
 
pagladasuCommented:
Well done, thresher. Keep up the good work.
0
 
thresher_sharkCommented:
Thanks!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now