Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

On top

Posted on 1999-07-13
7
Medium Priority
?
185 Views
Last Modified: 2010-05-02
I want to make a program that is running (not mine) that is always on top, not always on top.  How do I do this?
0
Comment
Question by:mrcool4444
[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
  • 2
  • 2
7 Comments
 
LVL 7

Accepted Solution

by:
Vbmaster earned 30 total points
ID: 1524414
Here's the code u need to do this. Adding this property to any form gives you the ability to change the "Topmost" property with simple code like

Formname.Topmost = True/False

It's really this easy. =)



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

Property Let TopMost(sTopmost As Boolean)

  Const HWND_TOPMOST = -1
  Const HWND_NOTOPMOST = -2

  Select Case sTopmost
  Case Is = True
    Call SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.Left \ Screen.TwipsPerPixelX, Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, 0)
  Case Is = False
    Call SetWindowPos(Me.hwnd, HWND_NOTOPMOST, Me.Left \ Screen.TwipsPerPixelX, Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, 0)
  End Select
 
End Property


0
 

Author Comment

by:mrcool4444
ID: 1524415
The only thing is it cannot use the name of the program because it doesn't have one.  And I don't understand what you mean.
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 1524416
Ah oki thought that you talked about a VB app. So the program has no caption on its main window?
0
Independent Software Vendors: 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!

 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1524417
Q.10179433

Your not going to get anywhere that way mrcool, the next expert that comes along will tell you the same that I did,  your program you want not topmost checks to make sure that it is topmost, and kills itself if it is'nt.
0
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1524418
If anyone wants to try here's the code that will hide it, the program he wants to hide or make not topmost is netzero:


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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_HIDEWINDOW = &H80
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_NOTOPMOST = -2

Private Sub HideWindow()
    Dim windhndl As Long
    'first get the handle of the window
    windhndl = FindWindow("AwtWindow", "")
    'then hide it
    SetWindowPos windhndl, 0, 0, 0, 0, 0, SWP_HIDEWINDOW Or SWP_NOSIZE Or SWP_NOMOVE
End Sub
0
 

Author Comment

by:mrcool4444
ID: 1524419
Oh well, I figured out how to hide it my self.
0
 

Author Comment

by:mrcool4444
ID: 1524420
Oh well, I figured out how to hide it my self.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

670 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