Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUGS: Pageframe and Page.Deactivate NODEFAULT
Message
De
03/07/2005 04:12:03
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01028103
Message ID:
01028584
Vues:
10
>>I discovered this a long time ago, don't remember when
>>
>>I have a standard maintenance form class ( a la Tastrade ). A form with a pageframe consisting of two pages
>>The left page allows you to modify a record, the right page gives a list (grid) of all records
>>
>>In the left page's DeActivate event, when the data has changed, you get a prompt: Save ? Yes No Cancel
>>
>>The cancel does a NODEFAULT.
>>
>>Now, when one is on page1 caption and a LeftArrow or RightArrow is pressed it produces a page DeActivate event.
>>When a NODEFAULT is done there, it is not reliable, ie it switches to page2 anyway
>>
>>Since then, I have the following code in the form Keypress (the solution you are suggesting)
>>
>>
>>do case
>>case inlist(nKeyCode, nKEY_LEFT_ARROW, nKEY_RIGHT_ARROW)
>>	local ac
>>	ac = this.GetActiveControl()
>>	if( !isNull(ac) )
>>		if( ac.BaseClass = 'Page' )
>>			NODEFAULT
>>		endif
>>	endif
>>...
>>
>>
>>When you are on page1 and you click on the header of page2, the NODEFAULT works without any problem. It's just the arrow keys that may cause a problem
>
>Gregory,
>
>I have two questions:
>
>1) How do you solve the problem of not doing your code if the user clicks on the same page?
>
>2) What if your form's baseclass already has code in KeyPress? How can you add your new code? If you would call dodefault in KeyPress, it would fire key sequence twice, would it?
>
>Thanks.


Nadya,

(1) I don't. I have not found a way. If you click on the page header of the page you are on then the deactivate fires

(2) the code above is in my form's base class. It prevents switching pages with Left|Right arrow on all pageframes

All forms derived from my form's baseclass call the Dodefault().
The code in the form's baseclass' Keypress returns TRUE if it handled the keystroke, FALSE if it did not

&& Excerpt of code in form's baseclass
LPARAMETERS nKeyCode, nShiftAltCtrl

&& returns TRUE if char processed here

do case
case inlist(nKeyCode, nKEY_LEFT_ARROW, nKEY_RIGHT_ARROW)
	local ac
	ac = this.GetActiveControl()
	if( !isNull(ac) )
		if( ac.BaseClass = 'Page' ) 
			NODEFAULT
			return TRUE
		endif
	endif
	
case ...	

endcase

&& if we get here, then the char has not been processed here
&& hence
return FALSE
So, the keypress of any form looks like this
LPARAMETERS nkeycode,nshiftaltctrl

if( DoDefault(m.nkeycode, m.nshiftaltctrl) )
	return TRUE
endif
	
&& code specific to the form below
do case
case	m.nshiftaltctrl = 0
	do case
	case inlist(m.nKeyCode, nKey_F7)
		NODEFAULT
		
	endcase

endcase
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform