Solved

Visual Foxpro detect if grid is focused

Posted on 2011-09-13
7
1,386 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
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 41

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 41

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 41

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

15 Experts available now in Live!

Get 1:1 Help Now