雪千渔Blog

  • 首页
  • Coding
    • dotNet
    • C++
    • Lua
    • Visual Basic
    • Java
    • Android
    • Web
  • DCC
    • Maya
    • Maya-Plug
    • AfterEffect
    • AfterEffect-Plug
    • PhotoShop-Plug
  • GameDev
    • Unity3D
    • UnrealEngine
    • 经验杂谈
    • 游戏设计
    • 自研引擎
    • 效果实现
  • Graphics
    • OpenGL
    • Vulkan
    • 计算机图形学
  • 其他
    • 乱七八糟
    • 软件工具
    • 留言板
    • 自制素材
    • 关于我
雪千渔blog
唯有热爱,能抵漫长岁月
  1. 首页
  2. Coding
  3. Visual Basic
  4. 正文

Visual Basic6 美化简洁类模块 扁平UI

2016年1月11日 6593点热度 33人点赞 0条评论

效果:

以下为FEUI类模块内容
'FlatEazyUI
'BY: JayshonYves
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_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF010&
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2

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

Dim WithEvents frmclose As Label
Attribute frmclose.VB_VarHelpID = -1
Dim WithEvents SmallCt As Label
Attribute SmallCt.VB_VarHelpID = -1
Dim WithEvents frmbigs As Shape
Attribute frmbigs.VB_VarHelpID = -1
Dim WithEvents frmbig As Label
Attribute frmbig.VB_VarHelpID = -1
Dim WithEvents Frmad As Form
Attribute Frmad.VB_VarHelpID = -1
Dim FrmObj As Form
Dim QLineC
Dim wCtColor
Dim SmallB As Boolean, BigB As Boolean, CloseB As Boolean

Public Function FEUI(frm As Form, SmallCtB As Boolean, BigCtB As Boolean, CloseCtB As Boolean, Optional FrmBC As String, Optional Linecolor As String, Optional CtColor As String, Optional Alpha As Integer) As String
On Error Resume Next
'设置默认参数
If AlphaAm = True Then Alpha = 0
If Linecolor = "" Then Linecolor = &HFFFF00
If CtColor = "" Then CtColor = vbWhite
If FrmBC = "" Then FrmBC = &H404040
If Alpha > 255 Then Alpha = 255
If Alpha < 0 Then Alpha = 0

SmallB = SmallCtB
BigB = BigCtB
CloseB = CloseCtB
Set FrmObj = frm
Set Frmad = frm
QLineC = Linecolor
wCtColor = CtColor

With frm
.AutoRedraw = True
.BackColor = FrmBC
End With

'窗体标题
Set frmCaption = frm.Controls.Add("vb.label", "TitleCaption")
With frmCaption
.Visible = True
.Font = "微软雅黑"
.AutoSize = "true"
.Caption = frm.Caption
.Left = 200
.Top = 120
.BackStyle = 0
.ForeColor = CtColor
.FontSize = 10
End With

'设置关闭按钮
If CloseCtB = True Then
Set frmclose = frm.Controls.Add("vb.label", "Closebtn")
With frmclose
.Visible = True
.AutoSize = False
.Top = 150
.Left = frm.Width - 150 - 240
.Width = 240
.Height = 240
.BackStyle = 0
End With
frm.Line (frm.Width - 150 - 240, 150)-(frm.Width - 150, 150 + 240), CtColor
frm.Line (frm.Width - 150, 150)-(frm.Width - 150 - 240, 150 + 240), CtColor
End If

'设置最小化按钮
If SmallCtB = True Then
Dim Mo As Integer
If BigCtB = True Then Mo = 150 + 240 Else Mo = 0
If CloseCtB = False Then Mo = Mo - (150 + 240) Else Mo = Mo
frm.Line (frm.Width - 150 - 240 - 150 - 240 - Mo, 150 + 230)-(frm.Width - 150 - 240 - 150 - Mo, 150 + 230), CtColor
Set SmallCt = frm.Controls.Add("vb.label", "Smallbtn")
With SmallCt
.Visible = True
.AutoSize = False
.Top = 150
.Left = frm.Width - 150 - 240 - 150 - 240 - Mo
.Width = 240
.Height = 240
.BackStyle = 0
End With
End If

'设置最大化按钮
If BigCtB = True Then
Dim MoB As Integer
If CloseCtB = True Then MoB = 150 + 240 Else MoB = 0
Set frmbigs = frm.Controls.Add("vb.shape", "Bigbtn")
With frmbigs
.BorderColor = CtColor
.Visible = True
.Height = 255
.Width = 255
.Top = 150
.Left = frm.Width - 150 - 240 - MoB
.BorderStyle = 1
.BackColor = 0
.FillStyle = 1
.Shape = 0
.BorderWidth = 1
End With
Set frmbig = frm.Controls.Add("vb.label", "Bigbtns")
With frmbig
.Visible = True
.AutoSize = False
.Top = 150
.Left = frm.Width - 150 - 240 - MoB
.Width = 255
.Height = 255
.BackStyle = 0
End With

End If

Call PrintLines

Dim rtn As Long
rtn = GetWindowLong(frm.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong frm.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes frm.hwnd, 0, Alpha, LWA_ALPHA
End Function
Private Sub RePrint()
'重绘过程
FrmObj.Cls
PrintLines
'CloseButton
If CloseB = True Then
FrmObj.Line (FrmObj.Width - 150 - 240, 150)-(FrmObj.Width - 150, 150 + 240), wCtColor
FrmObj.Line (FrmObj.Width - 150, 150)-(FrmObj.Width - 150 - 240, 150 + 240), wCtColor
frmclose.Left = FrmObj.Width - 150 - 240
End If
'BigButton
If BigB = True Then
Dim MoB As Integer
If CloseB = True Then MoB = 150 + 240 Else MoB = 0
frmbigs.Left = FrmObj.Width - 150 - 240 - MoB
frmbig.Left = FrmObj.Width - 150 - 240 - MoB
End If
'SmallButton
If SmallB = True Then
Dim Mo As Integer
If BigB = True Then Mo = 150 + 240 Else Mo = 0
If CloseB = False Then Mo = Mo - (150 + 240) Else Mo = Mo
FrmObj.Line (FrmObj.Width - 150 - 240 - 150 - 240 - Mo, 150 + 230)-(FrmObj.Width - 150 - 240 - 150 - Mo, 150 + 230), wCtColor
SmallCt.Left = FrmObj.Width - 150 - 240 - 150 - 240 - Mo
End If
End Sub
Private Sub PrintLines()
FrmObj.Line (0, 0)-(0, FrmObj.Height), QLineC
FrmObj.Line (0, 0)-(FrmObj.Width, 0), QLineC
FrmObj.Line (FrmObj.Width - 10, 0)-(FrmObj.Width - 10, FrmObj.Height - 10), QLineC
FrmObj.Line (0, FrmObj.Height - 10)-(FrmObj.Width, FrmObj.Height - 10), QLineC
End Sub
Private Sub frmclose_Click()
Unload FrmObj
End Sub
Private Sub Smallct_Click()
FrmObj.WindowState = 1
End Sub
Private Sub frmbig_Click()
If FrmObj.WindowState <> 2 Then
FrmObj.WindowState = 2
Else
FrmObj.WindowState = 0
End If
RePrint
End Sub
Private Sub Frmad_Resize()
'FrmObj.Cls
'Call PrintLines
End Sub
Private Sub Frmad_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If FrmObj.WindowState <> 2 Then
ReleaseCapture
SendMessage FrmObj.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0
End If
End Sub

使用方法

Dim FEUI As New FEUI

Private sub Form_Load()

FEUI.FEUI Me, False, False, True, , , , 230

End sub

'参数:

'FEUI.FEUI Me,是否开启最小化按钮,是否开启最大化按钮,是否开启关闭按钮,背景颜色(不填写为灰色),线条颜色(不填写为蓝色),标题栏颜色(标题 最小化 关闭),窗体透明度(不填写为无透明)

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: ui vb
最后更新:2016年1月11日

JomiXedYu

独游开发者 & 技术美术

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

JomiXedYu

独游开发者 & 技术美术

最新 热点 随机
最新 热点 随机
HLSL对Vulkan的适应性以及伪语义绑定 GPU呈现模式与垂直空白 自研引擎PulsarEngine的Shader编译流程 UE材质Custom节点与HLSL的HACK操作 UE5出现D3D12崩溃报错解决方案 游戏引擎脚本绑定的三种写法与利弊
HLSL对Vulkan的适应性以及伪语义绑定
VSTO之唯一不销毁浮动面板 gitbook两个bug解决方法与修复工具 LuaSharp:适用于.Net开发者的Lua框架 Visual Basic6使用Cmd命令行创建Res资源文件 GPU呈现模式与垂直空白 Visual Basic6 美化简洁类模块 扁平UI
友情链接
  • DorinXL
  • 小博博客
  • 秋橘斋

COPYRIGHT © 2014-2023 雪千渔Blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

辽ICP备20006894号-1