Solved

Making my window focused and ontop

Posted on 2004-08-16
4
175 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
[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
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
Suggested Courses
Course of the Month6 days, 18 hours left to enroll

622 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