Results 1 to 6 of 6

Thread: Allway OnTop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    77

    Red face

    How do i make my form ONTOP of those free internet ads, and it stay thatway.

  2. #2
    Guest
    Use the SetWindowPos api function.

    Code:
    Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"_
      (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
    
    Global Const SWP_NOMOVE = 2 
    Global Const SWP_NOSIZE = 1 
    Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE 
    Global Const HWND_TOPMOST = -1 
    Global Const HWND_NOTOPMOST = -2
    
    Private Sub Form_Load()
    Timer1.Interval = 1
    End Sub
    
    Private Sub Timer1_Timer()
    ontop& = SetWindowPos (Me.hWnd, HWND_TOPMOST, _
    0, 0, 0, 0, FLAGS) 
    End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    77
    i put Declarations in Modules, and put code in form_load and timer1_timer event but when i run the program it tell me that 'SetWindowPos' Sub or Function not defined.

    [/code] [/B][/QUOTE]

  4. #4
    Guest
    Code:
    Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"_
      (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

  5. #5
    Guest
    Matthew Gates: You don't need to place your code in a Timer, because you will be repeating the same code over and over for nothing. All you really need is to place it in the Load event.
    Code:
    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 Sub Form_Load()
        SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
    End Sub

  6. #6
    Guest
    Oh yeah, silly mistake. Stays on top all the time .

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