Solved

Making my window focused and ontop

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 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