|
-
Nov 3rd, 2000, 06:44 AM
#1
Thread Starter
Hyperactive Member
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.
-
Nov 3rd, 2000, 06:58 AM
#2
Fanatic Member
?
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...
-
Nov 3rd, 2000, 08:10 AM
#3
Member
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&)
-
Nov 3rd, 2000, 09:03 AM
#4
Thread Starter
Hyperactive Member
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.
-
Nov 3rd, 2000, 09:14 AM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|