Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox and listindex
Message
De
05/01/2004 09:21:53
 
 
À
05/01/2004 06:44:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00863734
Message ID:
00863838
Vues:
15
Hi Marcia,

Yes, I do have code in the form's keypress. It sets the focus to the first control on every page when the user presses pageup or pagedown anywhere on the form. That works fine, except that when the user presses pagedwn if the first control on the next page is a listbox, the selected item in the listbox is the last record in the table or the last item in the listbox. That is all I need to change. I must've overlooked something?

Since these pages are added and removed dynamically during runtime in the form's init based on page names that are listed in an array, I have named the first control on each page controltop and the last control on each page controlbottom so I can use generic code to know which control to set focus to when the user changes pages.

What is strange is that when the user moves to the next page by exiting the last control on a page when the next page receives focus, the listbox is at the top of the list as it should be. I have posted the lostfocus code of the last control on a page below also. It is strange that it works in that case but not when using pagedown.

I realize I could shorten the below code now that all the top controls share the same name, but I haven't done it yet.

Form's keypress:
LPARAMETERS nKeyCode, nShiftAltCtrl

DO CASE
   CASE nKeyCode = 18 .AND. nShiftAltCtrl = 0  && Page Up
      IF THISFORM.PAGEFRAME.ACTIVEPAGE > 1
         THISFORM.PAGEFRAME.ACTIVEPAGE = THISFORM.PAGEFRAME.ACTIVEPAGE - 1
      ELSE
         THISFORM.PAGEFRAME.ACTIVEPAGE = THISFORM.PAGEFRAME.PAGECOUNT
      ENDIF
      DO CASE
*--This works fine when moving through pages using pageup the listbox
*--is at the top of the list everytime on everypage.
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 1
            THISFORM.PAGEFRAME.Page1.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 2
            THISFORM.PAGEFRAME.Page2.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 3
            THISFORM.PAGEFRAME.Page3.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 4
            THISFORM.PAGEFRAME.Page4.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 5
            THISFORM.PAGEFRAME.Page5.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 6
            THISFORM.PAGEFRAME.Page6.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 7
            THISFORM.PAGEFRAME.Page7.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 8
            THISFORM.PAGEFRAME.Page8.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 9
            THISFORM.PAGEFRAME.Page9.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 10
            THISFORM.PAGEFRAME.Page10.controltop.SETFOCUS()
      ENDCASE
   CASE nKeyCode = 3  .AND. nShiftAltCtrl = 0   && Page Down
*--This is where if the top control on the next page is a listbox
*--the listbox is at the end of the list when the control receives
*--focus     
      IF THISFORM.PAGEFRAME.ACTIVEPAGE < THISFORM.PAGEFRAME.PAGECOUNT
         THISFORM.PAGEFRAME.ACTIVEPAGE = THISFORM.PAGEFRAME.ACTIVEPAGE + 1
      ELSE
         THISFORM.PAGEFRAME.ACTIVEPAGE = 1
      ENDIF
      DO CASE
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 1
            THISFORM.PAGEFRAME.Page1.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 2
         	THISFORM.PAGEFRAME.Page2.SETFOCUS()
            THISFORM.PAGEFRAME.Page2.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 3
         	THISFORM.PAGEFRAME.Page3.SETFOCUS()
            THISFORM.PAGEFRAME.Page3.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 4
         	THISFORM.PAGEFRAME.Page4.SETFOCUS()
            THISFORM.PAGEFRAME.Page4.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 5
         	THISFORM.PAGEFRAME.Page5.SETFOCUS()
            THISFORM.PAGEFRAME.Page5.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 6
            THISFORM.PAGEFRAME.Page6.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 7
            THISFORM.PAGEFRAME.Page7.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 8
            THISFORM.PAGEFRAME.Page8.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 9
            THISFORM.PAGEFRAME.Page9.controltop.SETFOCUS()
         CASE THISFORM.PAGEFRAME.ACTIVEPAGE = 10
            THISFORM.PAGEFRAME.Page10.controltop.SETFOCUS()
      ENDCASE
   OTHERWISE
      DODEFAULT()
ENDCASE
The below works correctly. Example lostfocus of the last control on a page:
PRIVATE mkey
mkey=LASTKEY()
CLEAR TYPEAHEAD
IF INLIST(mkey,5,15)       && Up Arrow, Shift-Tab
	DODEFAULT()
ELSE
	IF THISFORM.PageFrame.activePage=THISFORM.PageFrame.PageCount	&& on last page, move to 1st page
		THISFORM.PageFrame.activePage = 1
		THISFORM.PageFrame.Page1.controltop.setfocus()
	ELSE															&& move to next page
		THISFORM.PageFrame.activePage=thisform.PageFrame.activepage + 1
		PRIVATE lccommand
		lccommand = "THISFORM.PageFrame.Page"+ALLTRIM(STR(THISFORM.PageFrame.ActivePage))+".controltop.setfocus()"
		&lccommand
	ENDIF
ENDIF
>Hi Tracy.
>
>When the user presses pageUp and goes to the next page the listbox is at the top of the list, but when the user presses PageDwn and goes to the next page the listbox is at the bottom of the page (end of file).
>
>I take it, then, that you have some code that changes the ActivePage when the Page Down key is pressed. Sounds to me like you are missing a NODEFAULT somewhere.
>
>Also, when the listbox does NOT have the focus I would like NONE of the rows to be highlited. Is there a way to turn that highlite off like there is in grids in VFP8?
>
>Set the list box's ListIndex to 0. But this also changes the underlying data if it is a bound control.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform