Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Focus
Message
From
01/08/2003 14:28:26
Gerry Schmitz
GHS Automation Inc.
Calgary, Alberta, Canada
 
 
To
31/07/2003 17:11:34
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Re: Focus
Miscellaneous
Thread ID:
00815251
Message ID:
00815983
Views:
19
>I didn´t get it Gerry. Maybe i did not explain myself very clear. I need to know if one of the lines in a grid object is select or not. I triggered the DELETE key to delete the current record, but nothing should happen if the cursor would be focusing any other object on the form. Only when i click on the grid that the procedure triggered by ON KEY LABEL DEL must delete the cursor record and refresh the grid. I found a way by using GETFOCUS and LOSTFOCUS of the TEXT1 object of each colunm by setting a flag each time any of the colunms got the focus. Is there an easy way to do that.

OK ... that narrows things down a bit :)

The general approach is the same though; you can test "if a Grid has focus" in your ON KEY routine as follows:
IF TYPE( "_SCREEN.ActiveForm.ActiveControl" ) <> "U" ;
AND _SCREEN.ActiveForm.ActiveControl.BaseClass = "Grid" ;
AND _SCREEN.ActiveForm.ActiveControl.ActiveColumn > 0     && Just in case.
   ...
ENDIF
If you use the Form's .KeyPress event (recommended) instead of ON KEY, then you can use the less verbose THISFORM instead of _SCREEN.ActiveForm.

In VFP 8.0 it is even simpler because Grids have a .KeyPress event; in that case you can pretty well assume the Grid has focus anytime the Grid's .KeyPress fires.

And, if you want to know if there are any records to delete, a Grid's RecordSource is automatically selected when the Grid has focus so a test for !EOF() should do it.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform