Solved

move from one editbox to another automatically(SDI)

Posted on 1998-10-27
14
185 Views
Last Modified: 2013-11-20
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
Comment
Question by:ducksoup
  • 6
  • 3
  • 2
  • +2
14 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323917
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1323918
You could also use WM_NEXTDLGITEM...
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1323919
Oops that should be WM_NEXTDLGCTL
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Expert Comment

by:Answers2000
ID: 1323920
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1323921
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323922
Perhaps I should "Answer" ?
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323923
Perhaps I should "Answer" ?
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1323924
I think you should thresher_shark. You have started as a comment which is in the right direction.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1323925
Yep thresher
0
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1323926
Okay.  ducksoup - If you have any questions implementing my solution, please feel free to ask.  Thanks!
0
 

Author Comment

by:ducksoup
ID: 1323927
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323928
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
 
LVL 4

Expert Comment

by:pagladasu
ID: 1323929
Well done, thresher. Keep up the good work.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323930
Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sum28 challenge 31 115
tripleUp challenge 7 86
ShiftLeft challenge 21 85
Problem to App source 6 70
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question