Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form keypress Conundrum
Message
From
12/01/2006 09:47:52
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01085658
Message ID:
01086047
Views:
38
This message has been marked as a message which has helped to the initial question of the thread.
>>>Updated form keypress event (for future and lurkers):
>>>
>>>   DO CASE
>>>      CASE nKeyCode = 18 .AND. nShiftAltCtrl = 0  && Page Up
>>>         *--TCH 01/11/2006 Issue#3841 Courtesy Gregory Adam UT Thread 1085658
>>>         NODEFAULT
>>>         IF VARTYPE(THISFORM.ACTIVECONTROL) = "O" .AND. !ISNULL(THISFORM.ACTIVECONTROL) .AND. ;
>>>               PEMSTATUS(THISFORM.ACTIVECONTROL, 'SetFocus', 5)
>>>            THISFORM.ACTIVECONTROL.SETFOCUS()
>>>         ENDIF
>>>*--Etc
>>>
>>
>>Think you can shorten this a bit since vartype returns 'X' for null
>>
>>if( (vartype(m.thisform.ActiveControl) = 'O') and  PEMSTATUS(m.thisform.ActiveControl, 'SetFocus', 5) )
>>...
>>endif
>>
>
>I believe vartype(thisform.ActiveControl) will bomb out.

And I believe you're right. If no control on the form has the focus, then KA-BOOM

I have a form method that returns the active control (null if there is none).

Hence, I always use
local ac
ac = thisform.GetActiveControl()  && which uses type()
So, Tracy should use
local ac

ac = iif(type('m.thisform.ActiceControl') = T_OBJECT, m.thisform.ActiceControl, null)
=iif(!isnull(m.ac) and PEMSTATUS(m.ac, 'SetFocus', 5), m.ac.SetFocus(), .f.)
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform