vb窗体怎么写

1.如何用VB写一个简单的窗体Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()RunIe ""End SubPrivate Sub RunIe(ByVal Url As String)ShellExecute 0, vbNullString, "IEXPLORE.EXE " & Url, vbNullString, vbNullString, vbNormalFocusEnd Sub 。
2.VB 怎么写透明窗体不太明白点击什么意思,
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 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)
按钮1代码:
Private Sub Command1_Click()
Dim ExsTyle As Long, crKey As Long, bAlpha As Byte, dwFlags As Long
ExsTyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
ExsTyle = ExsTyle Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, ExsTyle
dwFlags = 2 '2 所有颜色都透明,忽略 bAlpha 参数 '1 只有 crKey 指定的颜色才透明
' Me.BackColor = 123设置背景颜色
crKey = Me.BackColor '窗体中那种颜色设为透明
bAlpha = 160 '透明度,范围是 0-255,0的透明度最大,窗体将不可见
'设为 1 会产生这样的效果:窗体实际是可见的,因透明度高好像不可见,看见的下面的其他程序却无法使用 。
Me.hwnd, crKey, bAlpha, dwFlags
' Me.hwnd, 0, 255, 2 '不透明
End Sub
3.如果想让VB切换窗体,应该写什么代码1. VB中的窗体是程序执行的窗口,也是其他控件的容器 。一个VB工程中可能含有多个窗体,但只有一个窗体是主窗体,VB程序的运行默认从主窗体开始 。可以在VB6.0 菜单栏“工程”最下方“工程属性”设置启动窗体 。
2. VB是一种面向对象的事件驱动机制的程序设计语言 。窗体的常用事件有Hide(隐藏船体);Show(显示窗体);Unload(将窗体从内存中卸载);Load(将窗体加载到内存中) 。
3. 切换窗体比如当前是窗体1,需要切换到窗体2可以用以下代码:
Unload Form1 '从内存卸载Form1
Form2.Show '显示Form2,完成切换
【vb窗体怎么写】如果不想把Form1从内存卸载,以后还要用到Form1,可以用以下代码:
Form1.Hide '隐藏Form1,但保留在内存中
Form2.Show '显示Form2,完成切换
4.VB 窗体在任务栏的前端的代码怎么写一、窗体置前代码:
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 Const HWND_TOPMOST& = -1
Private Const SWP_NOSIZE& = &H1
Private Const SWP_NOMOVE& = &H2
然后
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
全部盖住屏幕,要先用上面的代码,然后把width和height设置为屏幕的分辨率*15,然后left和top为0即可
二、没得最小化事件!但是在最小化时会触发resize事件,在这个时候检查是否窗体的windowstate为1
三、去掉最大化按钮:窗体的Maxbutton=false

vb窗体怎么写

文章插图