×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Always on top?

Always on top?

Always on top?

(OP)
Does anyone know an API call to give a VB6 form the AlwaysOnTop property? Zorder doesn't work when trying to dominate the windows of other apps.
I need to present a message to the users, center owner, at a critical moment, regardless of the type and number of windows opened at the time.
The users will REALLY want to see the message but I haven't had much luck going front and center over some windows.
Any ideas?

RE: Always on top?

(OP)
Thanks, DougP! I'll give it a try.

RE: Always on top?

Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

Form_Load :

Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)

Eric

Eric De Decker
vbg.be@vbgroup.nl
Visual Basic Center

RE: Always on top?

Just an addition to Eric's reply - when I used this a while ago I found that I had to call SetWindowPos from a number of different events (inc the form resize event as I remember) to ensure it stayed on top.

This behaviour could easily depend upon which version of windows you are running.

Mike

Mike Lacey
Mike_Lacey@Cargill.Com
Cargill's Corporate Web Site

RE: Always on top?

(OP)
That may be the case. The floating property is lost when the window is minimized but it doesn't always seem to return when the window is restored with SetWindowsPos in the resize event. (Sort of like DougP's original answer, mysteriously missing from this thread.)
So far, I've only played with the function under '98 (original) and it seems to work well enough, as long as you keep the user from fiddling with the window.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close