以前见到过一个有趣的小程序,叫snow,可以在桌面上下雪,学还可以在窗体边缘、图像边缘堆积,关键是并非屏幕保护,可以边下雪便运行其它程序。
我就用VB模仿了一个。先贴上效果图:
源代码 Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long 'GetDC()功能是获取指定窗体的设备场景的句柄(hDC),用参数0则可以获取整个屏幕的场景句柄 Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long 'GetPixel用于取得场景(这里是整个屏幕)中某点的颜色值 Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long 'SetPixel用于设置场景(这里是整个屏幕)中某点的颜色值 Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long '释放由GetDC()获取的设备场景句柄,否则可能造成系统锁死 Private Declare Function InvalidateRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long) '清理窗口雪花 Private Type POINTAPI '定义坐标点结构 x As Long y As Long End Type Private Type RECT '定义“区域”数据结构
源代码 Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long 'GetDC()功能是获取指定窗体的设备场景的句柄(hDC),用参数0则可以获取整个屏幕的场景句柄 Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long 'GetPixel用于取得场景(这里是整个屏幕)中某点的颜色值 Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long 'SetPixel用于设置场景(这里是整个屏幕)中某点的颜色值 Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long '释放由GetDC()获取的设备场景句柄,否则可能造成系统锁死 Private Declare Function InvalidateRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long) '清理窗口雪花 Private Type POINTAPI '定义坐标点结构 x As Long y As Long End Type Private Type RECT '定义“区域”数据结构