[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Visual Foxpro detect if grid is focused

Posted on 2011-09-13
7
Medium Priority
?
1,535 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 43

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 43

Accepted Solution

by:
pcelba earned 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 43

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 43

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

656 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