两种方法实现壁纸切换:
1.截获桌面自绘程序
2.更改壁纸路径,或者使用新图片覆盖当前桌面壁纸,然后刷新
只是要画图的话建议static控件。在WM_PAINT时先Update(hStatic)在用GetDC(hStatic)获得DC绘图。由于先Update,所以绘的图不会被Static覆盖以下方法不管窗体是否填满图片,均可把鼠标移到窗体边缘进行拖放,改变大小。一、把下面代码复制到一个模块中:
Option Explicit
'拖动控件声明
Private Const GWL_STYLE = (-16)
Private Const WS_THICKFRAME = &H40000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOMOVE = &H2
Private Const SWP_DRAWFRAME = &H20
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 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
'拖动控件
Sub ControlSize(ControlName As Object, SetTrue As Boolean)
Dim dwStyle As Long
dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
If SetTrue Then
dwStyle = dwStyle Or WS_THICKFRAME
Else
dwStyle = dwStyle - WS_THICKFRAME
End If
dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
SetWindowPos ControlName.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
End Sub
二、调用举例:
Private Sub Form_Load()
ControlSize Me, True
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)