Moving focus in code 
Author Message
 Moving focus in code

What  follows is a small snippet of code that I am working on. What I
would like to do is move the focus ot a certain page and field.  In this
case, page1, Dispatcher field.   The problem is with the line I have
highlighted in italics between the arrows.   I can use this in a form,
but I need to do this from code.  How can I change focus to a different
page/field within code?

Thanks.  I know this is another dumb question, but after a while brain
numbness sets in and I look to the group, lately, I have a lot of
numbness!!!

If .not. found()
                                         -->>
thisform.entry_pages.page1.dispatcher.setfocus()<<--
        =messagebox("Error Code 1.1.1-Dispatcher is unrecognized,
misspelled or incorrect. Please correct and try again.",16,Phrase1)
        vsys = temp
        verified = .F.
endif



Wed, 05 Mar 2003 03:00:00 GMT  
 Moving focus in code

Just a thought, off the top of my head, would be that even tho your code is solid, with the setfocus()
just after the set focus, you chage it again with the messagebox funcion.

what I would do, is set debug on just before the if ! found() and trace what is actually going on...

Bob

  What  follows is a small snippet of code that I am working on. What I would like to do is move the focus ot a certain page and field.  In this case, page1, Dispatcher field.   The problem is with the line I have highlighted in italics between the arrows.   I can use this in a form, but I need to do this from code.  How can I change focus to a different page/field within code?
  Thanks.  I know this is another dumb question, but after a while brain numbness sets in and I look to the group, lately, I have a lot of numbness!!!

  If .not. found()
                                           -->> thisform.entry_pages.page1.dispatcher.setfocus()<<--
          =messagebox("Error Code 1.1.1-Dispatcher is unrecognized, misspelled or incorrect. Please correct and try again.",16,Phrase1)
          vsys = temp
          verified = .F.
  endif



Wed, 05 Mar 2003 03:00:00 GMT  
 Moving focus in code

I know of two ways you can refer to any form you are after....  the first is good if you know that the form is going to be the currently selected form...

if _screen.activeform.name = "nameOfYourForm"
  _screen.activeform.entry_pages.page1.dispatcher.setfocus()
endif

Use the second method if you don't know what form is selected...

   cNo = _screen.formcount
   FOR i = 1 to cNo
    IF(_screen.forms(i).name="nameOfYourForm")
        <DO YOUR STUFF HERE>
        _screen.forms(i).entry_pages.page1.dispatcher.setfocus()
    ENDIF
   ENDFOR

That should solve your form referencing probs but I can't garuantee it'll solve your setfocus probs...

Cheers,
Rob


  Just a thought, off the top of my head, would be that even tho your code is solid, with the setfocus()
  just after the set focus, you chage it again with the messagebox funcion.

  what I would do, is set debug on just before the if ! found() and trace what is actually going on...

  Bob

    What  follows is a small snippet of code that I am working on. What I would like to do is move the focus ot a certain page and field.  In this case, page1, Dispatcher field.   The problem is with the line I have highlighted in italics between the arrows.   I can use this in a form, but I need to do this from code.  How can I change focus to a different page/field within code?
    Thanks.  I know this is another dumb question, but after a while brain numbness sets in and I look to the group, lately, I have a lot of numbness!!!

    If .not. found()
                                             -->> thisform.entry_pages.page1.dispatcher.setfocus()<<--
            =messagebox("Error Code 1.1.1-Dispatcher is unrecognized, misspelled or incorrect. Please correct and try again.",16,Phrase1)
            vsys = temp
            verified = .F.
    endif



Thu, 06 Mar 2003 08:25:20 GMT  
 Moving focus in code

What  follows is a small snippet of code that I am working on. What I would
like to do is move the focus ot a certain page and field.  In this case,
page1, Dispatcher fieldIf .not. found()

                                         -->>
thisform.entry_pages.page1.dispatcher.setfocus()<<--
        =messagebox("Error Code 1.1.1-Dispatcher is unrecognized, misspelled
or incorrect. Please correct and try again.",16,Phrase1)
        vsys = temp
        verified = .F.
endif

Hi Jack

Try
Thisform.Entry_pages.ActivePage=1

As this page becomes ActivePage you could set focus to the control named
Dispatcher in the UIEnable or the Activate avent of that page of that's what
you normally want done.
I think I would find it confusing, as a user, suddenly to be dumped on
another page then the one I'm working on. How do I find my way back?
Shouldn't I have a combobox list to pick valid dispatchers from in the first
place. No room for unrecognized, misspelled or incorrect dispatchers at all.

-Anders



Thu, 06 Mar 2003 03:00:00 GMT  
 Moving focus in code
Funny you should mention that, about the combo field.  Actually I have that
there!  I just picked this as a random selection ;)  I still do a check on it to
make sure that nobody gets cute and types something in.  It was a holdover fro
the pre-Foxpro days, i.e. dBase.

I seemed to have misstated myself on my problem.  When the entire page and form
is filled out, the user click on a button.  Inside that button is a line that
runs a separate bit of code that verifies the data is correct.  If it is not
correct, a message window is put up stating that there is a problem and where it
is, control is then put back to the user.  What I would like to happen is that
when that error is found, the message is put on the screen and page where the
problem is becomes active and the cursor is moved to the (suspected) problem
field.
Moving to a different page and field is no problem in a method.  Doing it from a
chunk of code seems to be a different bit of a {*filter*}.

Thanks for your time....

Quote:



> What  follows is a small snippet of code that I am working on. What I would
> like to do is move the focus ot a certain page and field.  In this case,
> page1, Dispatcher fieldIf .not. found()

>                                          -->>
> thisform.entry_pages.page1.dispatcher.setfocus()<<--
>         =messagebox("Error Code 1.1.1-Dispatcher is unrecognized, misspelled
> or incorrect. Please correct and try again.",16,Phrase1)
>         vsys = temp
>         verified = .F.
> endif

> Hi Jack

> Try
> Thisform.Entry_pages.ActivePage=1

> As this page becomes ActivePage you could set focus to the control named
> Dispatcher in the UIEnable or the Activate avent of that page of that's what
> you normally want done.
> I think I would find it confusing, as a user, suddenly to be dumped on
> another page then the one I'm working on. How do I find my way back?
> Shouldn't I have a combobox list to pick valid dispatchers from in the first
> place. No room for unrecognized, misspelled or incorrect dispatchers at all.

> -Anders



Thu, 06 Mar 2003 03:00:00 GMT  
 Moving focus in code
Hi Jack,

if i understand your problem,  you are trying to change the focus from code
stored outside of the form itself with code something like

do verify_items   && or some other procedure name.

If this is correct,  the " Thisform" object has no meaning in a seperate
procedure file.  You will have to pass a refernce to the form object

do verify_items with thisform

*** Now in your code
Parameters lform
.......

If .not. found()
lform.entry_pages.activepage=1  && also need this line
-->> lform.entry_pages.page1.dispatcher.setfocus()<<--
        =messagebox("Error Code 1.1.1-Dispatcher is unrecognized, misspelled
or incorrect. Please correct and try again.",16,Phrase1)
        vsys = temp
        verified = .F.
endif

****

Duane Walker


Quote:
> Funny you should mention that, about the combo field.  Actually I have
that
> there!  I just picked this as a random selection ;)  I still do a check on
it to
> make sure that nobody gets cute and types something in.  It was a holdover
fro
> the pre-Foxpro days, i.e. dBase.

> I seemed to have misstated myself on my problem.  When the entire page and
form
> is filled out, the user click on a button.  Inside that button is a line
that
> runs a separate bit of code that verifies the data is correct.  If it is
not
> correct, a message window is put up stating that there is a problem and
where it
> is, control is then put back to the user.  What I would like to happen is
that
> when that error is found, the message is put on the screen and page where
the
> problem is becomes active and the cursor is moved to the (suspected)
problem
> field.
> Moving to a different page and field is no problem in a method.  Doing it
from a
> chunk of code seems to be a different bit of a {*filter*}.

> Thanks for your time....




> > What  follows is a small snippet of code that I am working on. What I
would
> > like to do is move the focus ot a certain page and field.  In this case,
> > page1, Dispatcher fieldIf .not. found()

> >                                          -->>
> > thisform.entry_pages.page1.dispatcher.setfocus()<<--
> >         =messagebox("Error Code 1.1.1-Dispatcher is unrecognized,
misspelled
> > or incorrect. Please correct and try again.",16,Phrase1)
> >         vsys = temp
> >         verified = .F.
> > endif

> > Hi Jack

> > Try
> > Thisform.Entry_pages.ActivePage=1

> > As this page becomes ActivePage you could set focus to the control named
> > Dispatcher in the UIEnable or the Activate avent of that page of that's
what
> > you normally want done.
> > I think I would find it confusing, as a user, suddenly to be dumped on
> > another page then the one I'm working on. How do I find my way back?
> > Shouldn't I have a combobox list to pick valid dispatchers from in the
first
> > place. No room for unrecognized, misspelled or incorrect dispatchers at
all.

> > -Anders



Fri, 07 Mar 2003 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Don't want backspace in textbox to move focus

2. Moving Focus From a Text Box

3. moving focus between grids and other objects

4. When the grid gets focus the form gets moved

5. Can't move focus to child window

6. Moving Visual FoxPro 5.0 code to other Microsoft Language

7. Any code for a move window?

8. Code sluggish when moving from VFP 5.0 to 6.0

9. Using New 6.0 wizstyle and moving class libs/app code

10. runtime exe ( forms focus / no focus)

11. Lost Focus Event - Setting Focus

12. VFP 3.0b - Move to Front, Move to Back

 

 
Powered by phpBB® Forum Software