Solved

move from one editbox to another automatically(SDI)

Posted on 1998-10-27
14
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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