Results 1 to 4 of 4

Thread: program on the top

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    Orange County
    Posts
    68
    Can anyone help me make my program be on the top of all the other programs?
    Windows XP Professional
    Microsoft Visual Basic 6.0 Professional

  2. #2
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    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 = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_SHOWWINDOW = &H40
    Private Const SWP_NOACTIVATE = &H10

    Public Enum WindowPos
    vbtopmost = -1&
    vbNotTopMost = -2&
    End Enum

    Public Sub SetFormPosition(hWnd As Long, Position As WindowPos)
    Const wFlags As Long = SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE
    If Position = vbtopmost Or Position = vbNotTopMost Then
    SetWindowPos hWnd, Position, 0, 0, 0, 0, wFlags
    End If
    End Sub
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  3. #3
    Lively Member iataman's Avatar
    Join Date
    Jun 2000
    Location
    Turkey
    Posts
    71

    Arrow SetForegroundWindow

    I know two ways of doing that.
    1. Me.Zorder
    2. Public Declare Function SetForegroundWindow lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

    SetForegroundWindow(Me.Hwnd)


    Hope will be helpful..
    While YourAge<=40
    Live(YourLife)
    Wend

  4. #4
    Guest

    Re: SetForegroundWindow

    Originally posted by iataman
    I know two ways of doing that.
    1. Me.Zorder
    2. Public Declare Function SetForegroundWindow lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

    SetForegroundWindow(Me.Hwnd)


    Hope will be helpful..

    Me.ZOrder will only putit on top of other forms and not other programs. This won't keep it on top.

    SetForegroundWindow api function will only give the program focus putting it on top, but will not keep it on top either.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width