Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Text field access in another function

Posted on 2003-02-28
6
Medium Priority
?
195 Views
Last Modified: 2013-11-20
Hello

I got a little routine for checking a date field.
Now i want to automatically set the focus to that field by using f.e:

(where EF_DATUMINDIENST is the name of the text field)
(GetDlgItem(EF_DATUMINDIENST))->SetFocus();

but my idea was of making a function with as param. the name of that text field.

now i set for example a
CString fieldname = "EF_DATUMINDIENST"
and i call the routine here:
DoChecksAndSetFocusAt(fieldname);

but in the routine "DoChecksAndSetFocusAt"
i can't set focus on that control becz it believes it is a CString text

fieldname = result;
UpdateData(FALSE);

This of course doesn't work .. but i have no idea of how to make it work  :(
So i want to access the text field correctly.


Can anyone help me?

Thanks
Jens
0
Comment
Question by:JensB
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Priyesh earned 200 total points
ID: 8046472
you could do this by using CMapPtrToPtr by using string ptrs to the IDs you want.

if you don't want to use maps, you could try something like

CStringArray szArray ;
CUIntArray idArray ;

szArray.Add("EF_DATUMINDIENST") ;
idArray.Add(EF_DATUMINDIENST) ;

then when you get in the function,

void DoChecksAndSetFocusAt(char* szName)
{
  for(int i = 0; i < szArray.GetSize();i++)
  {
    if(szArray[i] == szName)
    {
      GetDlgItem(idArray[i])->SetFocus() ;
      break ;
    }
  }
}
0
 

Author Comment

by:JensB
ID: 8102926
ok thanks
i've already found a easier way, just by passing the control id to the function :)
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 8108174
alright, your question made me think that you have to pass the string for some reason. that's why i posted the comment about map.

good luck
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…
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.
Loops Section Overview

569 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