Text field access in another function

Posted on 2003-02-28
Medium Priority
Last Modified: 2013-11-20

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)

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:

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

fieldname = result;

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?

Question by:JensB
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
  • 2

Accepted Solution

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 ;


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 ;

Author Comment

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

Expert Comment

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

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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