Solved

Visual Foxpro detect if grid is focused

Posted on 2011-09-13
7
1,371 Views
Last Modified: 2012-05-12
Hello experts,

Is there a way to know if a grid as focus or not?
I mean is there a property or a way to know where the focus is? If its in another grid or field and not in a specific object?

i can't use the gotfocus and lostfocus events, because i'm a timer routine checking stuff, and one of the things i need to know is if a specific grid as focus or not..

Thx in advanced
0
Comment
Question by:justaphase
  • 4
  • 3
7 Comments
 
LVL 41

Expert Comment

by:pcelba
Comment Utility
IF TYPE("thisform.ActiveControl.Name") = "C"
  *-- thisform.ActiveControl.Name  is active object
ELSE
  *-- No active object exists on the form
ENDIF
0
 
LVL 1

Author Comment

by:justaphase
Comment Utility
I tried to make tests with that code and doesn't work...
maybe i'm doing it wrong..

my grid name "grid1"

and this how i call refer to the grid in code: formname.pageframe1.page1.cont1.grid1

How should do the code?
0
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
Comment Utility
ActiveControl does not recognize where the object is placed but allows to access it directly:

IF TYPE("thisform.ActiveControl.Name") = "C" AND LOWER(thisform.ActiveControl.Name) = "grid1"
  *-- The grid1 has focus
ENDIF

If you need to check the parent container of the grid then you have to look at its parent objects:

thisform.ActiveControl.Parent.Name
thisform.ActiveControl.Parent.Parent.Name
etc.

If you have several grids named "grid1" then you may place some specific text into the grid.Tag property and distinguish several grids by the Tag text.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 41

Expert Comment

by:pcelba
Comment Utility
I would also recommend to store the ActiveControl reference to a variable and work with this variable in your Timer. It will avoid possible problems when you change focus to some other object.
0
 
LVL 1

Author Comment

by:justaphase
Comment Utility
COOL!!

Since the cont1 is a container where the grid1 is in, i made it this way:

x = TYPE("formname.pageframe1.page1.cont1.ActiveControl")
IF x="O"
  * Active
ELSE
  * Not Active
ENDIF

When cont1 is not focused the type is "U"

Thx allot man :)
0
 
LVL 41

Expert Comment

by:pcelba
Comment Utility
The problem could be if the Form is not active. Then it has no ActiveControl.

If this is your case then you need to store the last active object into a form property in each Object's GotFocus event and check this property in your Timer.
0
 
LVL 1

Author Comment

by:justaphase
Comment Utility
I know, in my code i first make sure if the form is opened then i make that code.
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now