Solved

Making my window focused and ontop

Posted on 2004-08-16
4
170 Views
Last Modified: 2010-05-02
Im having an odd problem here.  My program subclasses another program so that I can add menu items to it, and interact with my program through the 3rd party programs menu.

The problem I am having is, when I click the menu item on the 3rd party program that shows my program's form, my form does not always become the active form (not focused, and not ontop).

I have tried, setforegroundwindow, setfocus, bringwindowtotop, setwindowpos, changing the zorder to 0, and a few other things, but I simply can't get it to consistantly be focused and ontop.  Im not sure if I am calling it at the wrong time, or what I am doing wrong.

Thanks in advance!



0
Comment
Question by:TAF2000
  • 3
4 Comments
 

Author Comment

by:TAF2000
ID: 11814032
Also.. I don't want the window to be always on top.  I have tried making it topmost (HWND_TOPMOST), and then making it not topmost, and that does make it ontop, but it still wasn't the focused window.
0
 
LVL 14

Accepted Solution

by:
Matti earned 400 total points
ID: 11815136
Hi!

Have you tried whit a timer inside that form:

Private Sub Form_Load()
Timer1.Interval = 400
End Sub

Private Sub Timer1_Timer()
Form1.SetFocus
DoEvents
End Sub

You need to stop the timer after user has selected  someting from your form and start again where that call comes from the menu. Timer1.Enabled= False/True

Using API to bring it always on top is probable the best way to do it.

Matti
0
 

Author Comment

by:TAF2000
ID: 11835977
nope.. that didn't do the trick either..  yet it works sometimes.. not always..
0
 

Author Comment

by:TAF2000
ID: 11849577
Anyone else have any ideas what would cause those commands to not be affective?  They will bring the form above other forms in my program, but not above the window I need it to be above.  No, the window is not always ontop.

Thanks,
TAF
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now