Results 1 to 5 of 5

Thread: Why is it different

  1. #1

    Thread Starter
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    Unhappy

    Does anyone know why this works for VB 5&6 but not with 4 ?

    Code:
    Private Declare Function SetWindowPos Lib "user32" (ByVal h%, ByVal hb%, ByVal X%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer
    
    Private Const SWP_NOMOVE = 2
    Private Const SWP_NOSIZE = 1
    Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    Private Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2
    
    Public Sub Make_Top()
    ' Make sure the user cannot send the form to the back and ignore it
    
    Dim lngRes As Long
    
    lngRes = SetWindowPos(PCDetails.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
    
    End Sub
    It's a damn useful bit of code which I picked up from somewhere ( can't remember where ) so if anyone wants to use it, feel free.

    Thanks for any help.
    That's Mr Mullet to you, you mulletless wonder.

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    ?

    This API returns a Long - might it be the declaration As Integer?

    I have a feeling that I know this but the mists of time have clouded my memory somewhat. I'll have a dig...

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3
    Member
    Join Date
    Oct 2000
    Posts
    35
    I don't know why it works in VB5, but you should use this declare in a 32-Bit app.

    Code:
    Declare Sub SetWindowPos Lib "user32" (ByVal hwnd&, ByVal hWndInsertAfter&, ByVal X&, ByVal Y&, ByVal cx&, ByVal cy&, ByVal wFlags&)
    rfo

  4. #4

    Thread Starter
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    I've copied the correct declare from the API viewer, complete with the long datatype and all the correct parameters but it still returns a code of 1. This is the declare I've used :

    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
    Thanks for looking at it guys.
    That's Mr Mullet to you, you mulletless wonder.

  5. #5

    Thread Starter
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    Now it's working ! Something I've changed has done the trick. Thanks for your help guys.

    Here's the final code if you want ot use it :

    Code:
    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 = 2
    Private Const SWP_NOSIZE = 1
    Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    Private Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2
    
    Public Sub Make_Top()
    ' Make sure the user cannot send the form to the back and ignore it
    
    Dim lngRes As Long
    
    lngRes = SetWindowPos(PCDetails.hwnd, HWND_TOPMOST, 0, 0, 1, 1, FLAGS)
    
    End Sub
    thanks again.
    That's Mr Mullet to you, you mulletless wonder.

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