1 Replies - 2237 Views - Last Post: 19 March 2011 - 09:23 AM

#1 Reverand Dave   User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 375
  • Joined: 27-July 08

Set your app to always on top

Posted 23 October 2008 - 06:57 AM

Description: I like to tie this to a menu option with the checked event, but the function can be called in numerous ways. To copy directly, create a menu option entitled "Always on Top" and had a sub menu option entitled Yes Add part1 to the declaration sections Add part2 somewhere in a module Add Part3 somewhere on your form codeGives you the option to keep your application always on top.
'Part1     
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

'Part2
      
Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) _
    As Long

         If Topmost = True Then 'Make the window topmost
            SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, _
               0, FLAGS)
         Else
            SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, _
               0, 0, FLAGS)
            SetTopMostWindow = False
         End If
      
End Function


'Part3

Private Sub Yes_Click()

If Yes.Checked = False then
     Yes.Checked = True 'Checks the list item
     lR = SetTopMostWindow(Me.hwnd, True) 'Me may be substitued with your form name
ElseIf Yes.Checked = True Then 
     Yes.Checked = False 'Unchecks the list item
     lR = SetTopMostWindow(Me.hwnd, False) '
End if

End Sub





Is This A Good Question/Topic? 0
  • +

Replies To: Set your app to always on top

#2 huzi8t9   User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 374
  • Joined: 11-July 07

Re: Set your app to always on top

Posted 19 March 2011 - 09:23 AM

This also resizes your application to 0x0...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1