Solved

Visual Foxpro detect if grid is focused

Posted on 2011-09-13
7
1,448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 36528414
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
ID: 36528448
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 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 36528487
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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
LVL 42

Expert Comment

by:pcelba
ID: 36528499
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
ID: 36528513
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 42

Expert Comment

by:pcelba
ID: 36528515
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
ID: 36529467
I know, in my code i first make sure if the form is opened then i make that code.
:)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

736 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