Results 1 to 3 of 3

Thread: Always on top window ..

  1. #1

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    Question Always on top window ..

    Hi,
    I have this code to put a form always on top but I don't know how to get it to work.

    _________________________________________________

    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 HWND_NOTOPMOST = -2
    Private Const HWND_TOPMOST = -1

    Public Function WinSetFloating(ByVal pHwnd As Long, _
    ByVal flOnTop As Boolean) As Boolean

    ' Sets a window to float or releases it
    Dim llngRet As Long
    Dim llngMess As Long

    If flOnTop = True Then
    llngMess = HWND_TOPMOST
    Else
    llngMess = HWND_NOTOPMOST
    End If

    llngRet = SetWindowPos(pHwnd, llngMess, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)

    If llngRet = 0 Then
    Err.Raise APIWinErrors.FLOATING_NOT_SET, "WinSetFloating", _
    "Windows has not been set on top."
    WinSetFloating = False
    Else
    WinSetFloating = True
    End If

    End Function

    _______________________________________________


    I just copied that code to the code view window.
    How can I call that command.

    this
    ________________-

    Call WinSetFloating

    ______________________

    won't work.


    Please help me..
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  2. #2
    Megatron
    Guest
    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
    
    Private Sub Form_Load()
        SetWindowPos hwnd, -1, 0,0,0,0,3
    End Sub

  3. #3
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252
    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
    Public res As Integer
    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

    'and

    Private Sub Command1_Click()
    If res = 0 Then
    SetWindowPos Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    res = 1
    ElseIf res = 1 Then
    SetWindowPos Form1.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    res = 0
    End If
    End Sub

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