?
Solved

detect if form has the focus

Posted on 2003-02-24
4
Medium Priority
?
173 Views
Last Modified: 2010-04-07
Hello,

Is there a way to check if a form has the focus ..

I have made a skin OCX for my applications .. I need the skin to be in different color scheme whenever the form has the focus.

Hesham
0
Comment
Question by:tocos
[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 Comments
 
LVL 18

Assisted Solution

by:Sethi
Sethi earned 50 total points
ID: 8012925
Screen.ActiveForm.Name returns the name of the form that has the focus in an application.
0
 
LVL 14

Accepted Solution

by:
Esopo earned 50 total points
ID: 8012987

You can also use GetFocus from the API:

Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Long


This will give you the handle of the window with the "keyboard focus" meaning the window that currently receives keyboard strokes.

Best regards.
0
 

Author Comment

by:tocos
ID: 8021288
Hello,

- Using Screen.ActiveForm.Name on my skin returns error.
- I used GetFocus in a timer control to detect the state of form as follow:

    If GetFocus = UserControl.Parent.hWnd Then
        Shape1.BackColor = vbRed
    Else
        Shape1.BackColor = vbWhite
    End If

It worked fine in design time but when I run the application it gave getfocus value different than the .hwnd

Regards,
Hesham
0
 

Expert Comment

by:CleanupPing
ID: 8901187
tocos:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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