我想做个窗口换肤的控件。但是不知道如何将一张图片覆盖在标题栏上,就像换肤软件一样,改变窗体样式。代码该怎样写,能给个例子吗?
解决方案 »
- 从a数据表读取数据,逐行写入b数据表,发现b数据表的记录与a数据表的记录顺序不一致,求教为什么?很急!!!帮帮忙!
- 怎样能用sql语句直接导出为一个EXCEL文件??不是一个打开的Excel文件
- 突然转向VB,有事请教!!!
- 怎么才能得到一个EXE文件是否在运行呢?我想双击个EXE文件,开始播放声音,当我第二次双击的时候停止播放?怎么实现呢?
- 怎么才能得到一个EXE文件是否在运行呢?
- vb6中如何使窗体半透明,控件不透明?
- 散
- VB调用dll,结果vb开发环境直接突然关闭了
- 我有个activex控件(ocx)有用户名跟密码 这两样我都有 问题是怎么注册呢
- 无法删除的文件夹,怎么办????
- 分析一下,,,, 简单。。。
- ◆sql语句极限挑战:这样的sql语句应该怎么写?◆
' firestorm.stormynight.net' This code shows you how to create cool looking forms to use in your application
' No OCXs are required, and only one form with minimal coding. Please vote, coz I
' need em! :)' You may use this code, and modify it, as long as you give me lots of credit for it :)' This declaration allows us to click on and hold onto our title bar or corners for resize (Even if they aren't present)
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
' Lets go of the titlebar or corners
Private Declare Sub ReleaseCapture Lib "user32" ()
' Constant for mouse down
Const WM_NCLBUTTONDOWN = &HA1
' Our titlebar
Const WCAPTION = 2
' The South-Eastern corner of our form, for resizing
Const W_SE_RESIZE = 17Private Sub Form_Resize()
' Positions the label at 0,0 and spans the entire form
Label1.Move 0, 0, Me.Width
' Positions our information in the center
Label2.Move Me.Width / 2 - Label2.Width / 2, Me.Height / 2 - Label2.Height / 2
' Label3 is our resize button. This code places it in the corner
Label3.Move Me.Width - Label3.Width, Me.Height - Label3.Height
' Label4 is our close button. Slaps it at the end of our form (up the top)
Label4.Move Me.Width - Label4.Width - 100
' Label5 is the minimize button
Label5.Move Me.Width - Label5.Width - Label4.Width - Label6.Width - 150
' Label6 is the maximize and restore button
Label6.Move Me.Width - Label4.Width - 450
End SubPrivate Sub Label1_DblClick()
' When you double click on a form title, it will maximize. This does the same thing
Label6_Click
End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Grabs onto our form's titlebar. If you want the focus to follow the mouse, then take away the
' if button = 1 if statement
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, WCAPTION, 0&
End If
End Sub
Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' This code grabs onto our resize bars and resizes the form. Try replacing W_SE_RESIZE with a
' number between 10 and 17 to see the resizing effects
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, W_SE_RESIZE, 0&
End If
End Sub
Private Sub Label4_Click()
End
End SubPrivate Sub Label5_Click()
' Minimize the form
Me.WindowState = 1
End SubPrivate Sub Label6_Click()
' Is it maximized? If so, then return it to normal. Else maximize it
If WindowState <> 2 Then
Me.WindowState = 2
Else
WindowState = 0
End If
End Sub
必须
BorderStyle=0
找一个第三方的菜单控件(可以定义位置),反正你做换皮效果,搞个COOL的菜单也是应该的,这种菜单很容易用的。:-)
运行的时候把窗体的一部分拉到屏幕外面再拉回来。' 窗体模块
Option ExplicitPrivate Sub Form_Load()
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End SubPrivate Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.hwnd, GWL_WNDPROC, ret
End Sub
' 标准模块
Option Explicit
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC = (-4)
Public Const WM_RBUTTONDOWN = &H204
Private Const WM_NCPAINT = &H85
Public ret As LongFunction WindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_NCPAINT Then
Debug.Print "收到 WM_NCPAINT 消息"
Else
WindowProc = CallWindowProc(ret, hwnd, Msg, wParam, lParam)
End If
End Function