Module1.bas
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:6k
- Attribute VB_Name = "ISNTMD"
-
- '带DLL与不带是不同的,不带DLL按常规查找,带DLL要到注册表中找相近的,
- '与到SYSTEM目录找,没找到则会出错
- '如果出现找不到.DLL文件可到把DLL去掉试试
- Public DilamicWin As myWinclass
- Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
- Public Type OSVERSIONINFO
- dwOSVersionInfoSize As Long
- dwMajorVersion As Long
- dwMinorVersion As Long
- dwBuildNumber As Long
- dwPlatformId As Long
- szCSDVersion As String * 128
- End Type
-
- Public Const VER_PLATFORM_WIN32s = 0
- Public Const VER_PLATFORM_WIN32_WINDOWS = 1
- Public Const VER_PLATFORM_WIN32_NT = 2
- Public Const SW_SHOW = 5
- Public Const SW_SHOWDEFAULT = 10
- Public Const SW_SHOWMAXIMIZED = 3
- Public Const SW_SHOWMINIMIZED = 2
- Public Const SW_SHOWMINNOACTIVE = 7
- Public Const SW_SHOWNA = 8
- Public Const SW_SHOWNOACTIVATE = 4
- Public Const SW_SHOWNORMAL = 1
- Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
- Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
- Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
- Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
- Declare Function GetKeyboardState Lib "user32" (pbKeyState As KeyboardBytes) As Long
- Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
- Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long
- Declare Function GetActiveWindow Lib "user32" () As Long
- Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
- 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 Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
- Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
- '建立隋圆形区域
- Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
- '建立矩形区域
- Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
- '建立一个由点构成的区域
- Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
- '合并两个区域
- Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
- Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
- Declare Function GetDesktopWindow Lib "user32" () As Long
- Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
- Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
- Public Const GWL_EXSTYLE = (-20)
- Public Const WS_EX_TRANSPARENT = &H20
- Public Const LWA_ALPHA = &H2
- Public Const LWA_COLORKEY = &H1
- Public Const WS_EX_LAYERED = &H80000
- Public Const WS_POPUP = &H80000000
- Public Const WS_DISABLED = &H8000000
- Const VK_LEFT = &H25
- Type KeyboardBytes
- kbByte(0 To 255) As Byte
- End Type
- Type POINTAPI
- x As Long
- y As Long
- End Type
- '定义一个矩形类型
- Type RECT
- Left As Long 'x(横向)方向。
- Top As Long 'Y(竖方)方向
- right As Long ''x(横向)方向
- bottom As Long ''y(横向)方向
- End Type
- Dim pp(10) As POINTAPI '定义一个数组
- Public act As Long 'form1 form4共用此变量
- Public myFullWinRect As RECT
- Public WinTogether As Boolean '窗口跟随
- Public NumPicture As Long
- Public WorkPath As String
- Public oldhwnd As Long
- Public mySendKey As Long
- Public Form4Hight As Long
- Public Form5Hight As Long
- Public Function MySetActiveWindow(ByVal hwnd As Long) As Boolean
-
- SetActiveWindow hwnd
- ' Form5.Label1.Caption = SetFocus(hwnd)
- End Function
- Public Function IsWinNT() As Boolean
- 'Returns True if the current operating system is WinNT
- Dim osvi As OSVERSIONINFO
- osvi.dwOSVersionInfoSize = Len(osvi)
- GetVersionEx osvi
- IsWinNT = (osvi.dwPlatformId = VER_PLATFORM_WIN32_NT)
-
- End Function
- Sub windowsdraw() '为各点赋值,以绘制窗口
- Dim firtX As Long, firtY As Long
- firtX = 0
- firtY = 0
- pp(0).x = firtX
- pp(0).y = firtY
- pp(1).x = firtX + 240
- pp(1).y = firtY
- pp(2).x = firtX + 240
- pp(2).y = firtY + 300
- pp(3).x = firtX + 70
- pp(3).y = firtY + 300
- pp(4).x = firtX + 70
- pp(4).y = firtY + 30
- pp(5).x = firtX + 0
- pp(5).y = firtY + 30
- End Sub
- Sub ModifyWindow1(hwnd As Long)
- Dim R1 As Long
- '调用函数给各点赋值
- windowsdraw
- R1 = CreatePolygonRgn(pp(1), 6, 1)
- SetWindowRgn hwnd, R1, True
- DeleteObject R1
-
- End Sub
- Sub ModifyWindow2(ww As Long)
- Dim Mrgn As Long
- Dim MyRec As RECT
-
- GetWindowRect ww, MyRec
-
- Mrgn = CreateEllipticRgn(0, 0, MyRec.right - MyRec.Left, MyRec.bottom - MyRec.Top)
- SetWindowRgn ww, Mrgn, True
- DeleteObject Mrgn
- End Sub
- '形状不规则的窗体
- Sub ShapeWindow(hwnd As Long, color As Long)
- Dim rtn As Long
- rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
- rtn = rtn Or WS_EX_LAYERED
- SetWindowLong hwnd, GWL_EXSTYLE, rtn
- If IsWinNT Then
- SetLayeredWindowAttributes hwnd, color, 0, LWA_COLORKEY '将扣去窗口中的蓝色
- End If
- End Sub
- '透明窗体
- Sub WindowVisable(hwnd As Long)
- Dim rtn As Long
- rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
- rtn = rtn Or WS_EX_LAYERED Or WS_DISABLED Or WS_POPUP
- SetWindowLong hwnd, GWL_EXSTYLE, rtn
- If IsWinNT Then
- SetLayeredWindowAttributes hwnd, 0, 150, LWA_ALPHA
- End If
- End Sub