扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
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 Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_NCLBUTTONDOWN = &HA1
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 Sub Form_Load()
Me.BackColor = &HFF0000
Dim rtn As Long
BorderStyler = 0
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, &HFF0000, 0, LWA_COLORKEY
End Sub
--------------------------------------------
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, 2, 0
End Sub
这是美化窗体的时候很好的办法,比用编程语句描述一个特殊形状的窗体要简单的多,只要选自己合意的图片即可!
我们都知道象PICTUREBOX,COMBOX,菜单,等等其实都是窗体.由此可以推出我们可以用替换法将其替换.当然这是我的设想了;毕竟我不是高手.
举个例子:
我想做一个图形化的按纽.那么我们可以用IMAGE来摸拟.用IMAGELIST放三张图片用来表示MOUSE_ON,MOUSE_DOWN,MOUSE_UP.当然如果你要求高一点可以用API来弥补其中的不足,使之更完善.
当然象CHECKBOX,OPTIONS用IMAGE来模拟都足足有余。
只要设一个全局变量为BOOLEAN就行了.它们只要两张图片就够了.自己画还是引用 就随你便了.
好了例子也举完了.总结一下:
我想说的就是其实做界面并不是技术高才能做的.转个圈其实用一些简单的方法也可以解决的.
只要大家敢想什么都会变成现实!
希望我也能抛砖引玉啊,当然前提是老大们能用啊。
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者