Solved

Visual Foxpro detect if grid is focused

Posted on 2011-09-13
7
1,436 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dynamic rowheight in Foxpro grid 8 359
HOW TO GET AN EXE FILE MADE IN VISUAL FOXPRO 7 50
Visual FoxPro Ver 9. What is UDDATA.PRG? 30 894
Templates to migrate from vfp to WPF 7 118
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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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