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

x
?
Solved

Want to be on top

Posted on 2000-05-01
7
Medium Priority
?
136 Views
Last Modified: 2010-05-02
I want my program to be "on top".  How do I do this?
0
Comment
Question by:R_N_WARD
[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
7 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2766399
Here ya go..


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 m_TopMost As Boolean

Property Let TopMost(New_Value As Boolean)

  Const HWND_TOPMOST = -1
  Const HWND_NOTOPMOST = -2

  m_TopMost = New_Value
  If New_Value Then
    Call SetWindowPos(Me.hWnd, HWND_TOPMOST, Me.left \ Screen.TwipsPerPixelX, Me.top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, 0)
  Else
    Call SetWindowPos(Me.hWnd, HWND_NOTOPMOST, Me.left \ Screen.TwipsPerPixelX, Me.top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, 0)
  End If
 
End Property
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2766400
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 HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Private Sub Command1_Click()
    Call SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2766404
In case it wasn't obvious from my code, you set a form on top by adding the code to the form and then you can use the code "TopMost = True" from within the form or "TheNameOfTheForm.TopMost = True" from anywhere else.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 32

Accepted Solution

by:
Brendt Hess earned 60 total points
ID: 2766413
0
 

Author Comment

by:R_N_WARD
ID: 2766441
I'm sorry VBmaster, but when I put in your code I recived a compile error that stated that only comments may follow an end sub.  If I incorectly placed the code, please tell me so I can give you the points you desive.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2766467
Did you try my code?
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2767014
In case you want to use the property-solution.. Make sure you go to the Declarations part of the form (top item in first combobox) before you add the code, it will remove that little error.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 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