Solved

Making my window focused and ontop

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

773 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