📄 subject_30462.htm
字号:
<blockquote><p>
回复者:dr0 回复日期:2003-02-23 19:38:08
<br>内容:OK了?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:dr0 回复日期:2003-02-23 19:39:44
<br>内容:嗯可以。不过<BR>int (__stdcall *p)(HWND,COLORREF,BYTE,DWORD);<BR>int (__stdcall *)(struct HWND__ *,unsigned long,unsigned char,unsigned long))<BR>最好一致,保持清晰。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xiongli 回复日期:2003-02-23 19:45:02
<br>内容:用getlasterror发现错误代码87,参数错误<BR>看来是lwa_alpha错了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:dr0 回复日期:2003-02-23 19:49:15
<br>内容:API Declarations <BR><BR> 'Creating Layered windows in VB. I only tested VB6 and not any previous <BR>'versions with Win 2000 Professional.<BR>'According to MS these are new features to win platform and will only work <BR>'under Win 2000.<BR>'For more Information goto http://msdn.microsoft.com/library/techart/layerwin.htm<BR><BR>Option Explicit<BR>'Requires Windows 2000 (NT 5):<BR>Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long<BR><BR>Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<BR><BR>Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long<BR><BR>Declare Function UpdateLayeredWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal hdcDst As Long, pptDst As Any, psize As Any, ByVal hdcSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, ByVal dwFlags As Long) As Long<BR><BR>Public Type POINTAPI<BR> x As Long<BR> y As Long<BR>End Type<BR><BR>Public Type SIZE<BR> cx As Long<BR> cy As Long<BR>End Type<BR><BR>Public Type BLENDFUNCTION<BR> BlendOp As Byte<BR> BlendFlags As Byte<BR> SourceConstantAlpha As Byte<BR> AlphaFormat As Byte<BR>End Type<BR><BR>Public Const GWL_STYLE = (-16)<BR>Public Const GWL_EXSTYLE = (-20)<BR>Public Const WS_EX_LAYERED = &H80000<BR>Public Const ULW_COLORKEY = &H1<BR>Public Const ULW_ALPHA = &H2<BR>Public Const ULW_OPAQUE = &H4<BR>Public Const AC_SRC_OVER = &H0<BR>Public Const AC_SRC_ALPHA = &H1<BR>Public Const AC_SRC_NO_PREMULT_ALPHA = &H1<BR>Public Const AC_SRC_NO_ALPHA = &H2<BR>Public Const AC_DST_NO_PREMULT_ALPHA = &H10<BR>Public Const AC_DST_NO_ALPHA = &H20<BR>Public Const LWA_COLORKEY = &H1<BR>Public Const LWA_ALPHA = &H2<BR><BR>'Check Windows Version Declarations<BR>'For quick implementation I used ready source and slight modifications <BR>'from Andrea VB site @ http://www.andreavb.com/tip020005.html<BR><BR>Public Type OSVERSIONINFO<BR> dwOSVersionInfoSize As Long<BR> dwMajorVersion As Long<BR> dwMinorVersion As Long<BR> dwBuildNumber As Long<BR> dwPlatformId As Long<BR> szCSDVersion As String * 128<BR>End Type<BR><BR>'API Calls:<BR>Public Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long<BR><BR>'API Constants<BR>Public Const VER_PLATFORM_WIN32_WINDOWS = 1<BR>Public Const VER_PLATFORM_WIN32_NT = 2 <BR><BR>Module <BR><BR> Public Function IsLayeredWindow(ByVal hWnd As Long) As Boolean<BR> Dim WinInfo As Long<BR><BR> WinInfo = GetWindowLong(hWnd, GWL_EXSTYLE)<BR> If (WinInfo And WS_EX_LAYERED) = WS_EX_LAYERED Then<BR> IsLayeredWindow = True<BR> Else<BR> IsLayeredWindow = False<BR> End If<BR>End Function<BR><BR>Public Sub SetLayeredWindow(ByVal hWnd As Long, _<BR>ByVal bIsLayered As Boolean)<BR> Dim WinInfo As Long<BR><BR> WinInfo = GetWindowLong(hWnd, GWL_EXSTYLE)<BR> If bIsLayered = True Then<BR> WinInfo = WinInfo Or WS_EX_LAYERED<BR> Else<BR> WinInfo = WinInfo And Not WS_EX_LAYERED<BR> End If<BR> SetWindowLong hWnd, GWL_EXSTYLE, WinInfo<BR>End Sub<BR><BR>'get a string with the description of the operating system<BR>Public Function GetWindowsVersion(ByRef IsWin2000 As Boolean) As String<BR> Dim TheOS As OSVERSIONINFO<BR> Dim strCSDVersion As String<BR><BR> TheOS.dwOSVersionInfoSize = Len(TheOS)<BR> GetVersionEx TheOS<BR> Select Case TheOS.dwPlatformId<BR> Case VER_PLATFORM_WIN32_WINDOWS<BR> If TheOS.dwMinorVersion >= 10 Then<BR> GetWindowsVersion = "Windows 98 version: "<BR> Else<BR> GetWindowsVersion = "Windows 95 version: "<BR> End If<BR> Case VER_PLATFORM_WIN32_NT<BR> GetWindowsVersion = "Windows NT version: "<BR> End Select<BR> 'Extract the Additional Version Information from the string with null char terminator<BR> If InStr(TheOS.szCSDVersion, Chr(0)) <> 0 Then<BR> strCSDVersion = ": " & Left(TheOS.szCSDVersion, InStr(TheOS.szCSDVersion, Chr(0)) - 1)<BR> Else<BR> strCSDVersion = ""<BR> End If<BR> GetWindowsVersion = GetWindowsVersion & TheOS.dwMajorVersion & "." & _<BR> TheOS.dwMinorVersion & " (Build " & TheOS.dwBuildNumber & strCSDVersion & ")"<BR> 'Set ByRef Parameter<BR> If TheOS.dwMajorVersion = 5 Then IsWin2000 = True Else IsWin2000 = False<BR><BR>End Function<BR> <BR><BR>Usage <BR><BR> 'Create a form with 3 Command Buttons and a Slider <BR><BR>Option Explicit<BR><BR>Private Sub Command3_Click()<BR> MsgBox IsLayeredWindow(Me.hWnd)<BR>End Sub<BR><BR>Private Sub Command2_Click()<BR> SetLayeredWindow Me.hWnd, False<BR> Slider1.Visible = False<BR>End Sub<BR><BR>Private Sub Command1_Click()<BR> SetLayeredWindow Me.hWnd, True<BR> Slider1.Value = 70 'set the default value<BR> Slider1.Visible = True<BR>End Sub<BR><BR>Private Sub Slider1_Scroll()<BR> SetLayeredWindowAttributes Me.hwnd,0,(255 * Slider1.Value) / 100, LWA_ALPHA<BR>End Sub<BR><BR>Private Sub Form_Load()<BR> Dim bool As Boolean<BR><BR> GetWindowsVersion bool<BR> If Not bool Then<BR> MsgBox "Requires Windows 2000 or later:" & vbCrLf & "Application will exit", , "Exiting"<BR> Unload Me<BR> End If<BR> 'Little change t my previous submission Create Layered Windows.<BR> 'To see what the presentage of transparency you would like to use <BR> 'I added a slider control to the form.<BR> 'Here is the code <BR> 'that should be added to the form<BR> 'Form_load event <BR> Slider1.Visible = True<BR> Slider1.Min = 25 'anything lower 25 is practically invisible<BR>End Sub<BR> <BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:dr0 回复日期:2003-02-23 19:50:35
<br>内容:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/layerwin.asp<BR><BR>// refer to the above hyperlink.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xiongli 回复日期:2003-02-23 20:05:00
<br>内容:问题不是如何使用这个api<BR>而是我在那里去找这个header
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:dr0 回复日期:2003-02-23 20:21:52
<br>内容:MSDN里有SAMPLE, 你也甭管那里有HEADER<BR><BR>// Set WS_EX_LAYERED on this window <BR>SetWindowLong(hwnd, <BR> GWL_EXSTYLE, <BR> GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);<BR><BR>// Make this window 70% alpha<BR>SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);<BR><BR>// Sample from MSDN, 试试能不能编译。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xiongli 回复日期:2003-02-23 20:39:41
<br>内容:在http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/layerwin.asp <BR><BR>里面没有sample阿,只有一个step by step。但是看上去好像不行。我在mfc里面用::SetLayeredWindowAttributes也不行
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xiongli 回复日期:2003-02-24 19:42:47
<br>内容:http://www.codeproject.com/win32/Quaker1.asp
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -