PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 2018
-
13 nov. 2005 à 21:02
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 2018
-
15 nov. 2005 à 19:12
bonjour,
voilà, sur un ocx en cours, je vais utiliser SetLayeredWindowAttributes qui n'est reconnu que sous W2K+
j'ai juste besoin que quelqu'un sous Windows98 puisse m'aider à écrire les lignes ci-dessous, en conditionnelles.
le but est grossièrement de savoir : WXP/2K = ok, sinon message.
mais que l'appli ne plante pas pour autant. (puisque bibliothèque introuvable)
Option Explicit
'
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
'
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
'
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
'
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hWnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
'
'
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net
Dim Ret As Long
'Set the window style to 'Layered'
Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
'Set the opacity of the layered window to 128
SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA
End Sub
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 13 nov. 2005 à 21:27
voici le code à tester.
ne fonctionne pas sous XP avec #....
' à mettre dans un module
Option Explicit
'
Private Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer
'
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
wServicePackMajor As Integer ' Version Majeur du Service Pack
wServicePackMinor As Integer ' Version Mineur du Service Pack
End Type
'
Private Const VER_PLATFORM_WIN32s = 0 ' Win32s / Windows 3.1
Private Const VER_PLATFORM_WIN32_WINDOWS = 1 ' Windows 95, Windows 98, ou Windows Me
Private Const VER_PLATFORM_WIN32_NT = 2 ' Windows NT, Windows 2000, Windows XP, ou Windows Server 2003 familiale.
' Version Version
' Système Platforme Majeur Mineur Build
' Windows 95 1 4 0
' Windows 98 1 4 10 1998
' Windows 98SE 1 4 10 2222
' Windows Me 1 4 90 3000
' NT 3.51 2 3 51
' NT 2 4 0 1381
' 2000 2 5 0
' XP 2 5 1 2600
' Server 2003 2 5 2
Public Function VBWinVer() As String
Dim OSInfo As OSVERSIONINFO
Dim retvalue As Integer
OSInfo.dwOSVersionInfoSize = 156
OSInfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(OSInfo)
With OSInfo
Select Case .dwPlatformId
Case VER_PLATFORM_WIN32s ' Win32s / Windows 3.1
VBWinVer = "Windows 3.1"
Case VER_PLATFORM_WIN32_WINDOWS ' Windows 95, Windows 98,
Select Case .dwMinorVersion ' ou Windows Me
Case 0
VBWinVer = "Windows 95"
Case 10
If (OSInfo.dwBuildNumber And &HFFFF&) = 2222 Then
VBWinVer = "Windows 98SE"
Else
VBWinVer = "Windows 98"
End If
Case 90
VBWinVer = "Windows Me"
End Select
Case VER_PLATFORM_WIN32_NT ' Windows NT, Windows 2000, Windows XP,
Select Case .dwMajorVersion ' ou Windows Server 2003 family.
Case 3
VBWinVer = "Windows NT 3.51"
Case 4
VBWinVer = "Windows NT 4.0"
Case 5
Select Case .dwMinorVersion
Case 0
VBWinVer = "Windows 2000"
Case 1
VBWinVer = "Windows XP"
Case 2
VBWinVer = "Windows Server 2003"
End Select
End Select
Case Else
VBWinVer = "Failed"
End Select
End With
End Function
'remplacer le form load
Private Sub Form_Load()
Dim WinVersion As String
WinVersion = VBWinVer: MsgBox WinVersion
If (WinVersion "Windows 2000") Or (WinVersion "Windows XP") Or _
(WinVersion = "Windows Server 2003")) Then
Dim Ret As Long
'Set the window style to 'Layered'
Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
'Set the opacity of the layered window to 128
SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA
Else
MsgBox "Pas d'erreur mais pas de 'SetLayered' non plus^^", 32
End If
End Sub
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 15 nov. 2005 à 19:12
tous -> je répète la 2e partie de ma question : SetLayer fonctionne-t'il sous Win NT svp
rt15 -> ok merci, j'attend çà alors ;).
et pour la colorisation, bah c'est fait maison à partir d'une classe trouvée sur VbF (pas mal de défauts, mais bien pratique)