Solved

Making my window focused and ontop

Posted on 2004-08-16
4
172 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

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!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

713 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