Solved

move from one editbox to another automatically(SDI)

Posted on 1998-10-27
14
184 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
Define unique primary key 9 92
Complete beginner needs help making a cron job 9 116
canBalance challenge 34 81
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

776 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