
常用软件类: |
|杀毒安全 | |联络聊天 | |网络软件 | |多媒体类 | |系统工具 | |图形图像 | |系统工具 | |应用软件 | |行业软件 |
开发设计类: |
|动画制作 | |图像处理 | |3D设计 | |操作系统 | |站长学院 | |网络相关 | |WEB设计 | |数据库类 | |程序开发 |
如何把小图片填满 Form 成为背景图?
对于这个问题,我看过很多方法,有的方法很麻烦,要声明一大堆 Type,用一大堆的 API,但是有一个最笨但我认为最好的方法如下: (就好像拼磁砖一样,不用任何 API, 不必声明任何 Type)
在 Form 中放一个 PictureBox,Picture 属性设定为某一张小图,AutoSize 属性性设定 True,完成的模组如下:
| Sub PictureTile(Frm As Form, Pic As PictureBox) Dim i As Integer Dim t As Integer Frm.AutoRedraw = True Pic.BorderStyle = 0 For t = 0 To Frm.Height Step Pic.ScaleHeight For i = 0 To Frm.Width Step Pic.ScaleWidth Frm.PaintPicture Pic.Picture, i, t Next i Next t End Sub |
| Private Sub Form_Load() PictureTile Me, Picture1 End Sub |
| ’将以下模组放入 MDIForm 的声明区中: Sub TileMDIBkgd(MDIForm As Form, bkgdtiler As Form, bkgdfile As String) If bkgdfile = "" Then Exit Sub Dim ScWidth%, ScHeight% ScWidth% = Screen.Width / Screen.TwipsPerPixelX ScHeight% = Screen.Height / Screen.TwipsPerPixelY Load bkgdtiler bkgdtiler.Height = Screen.Height bkgdtiler.Width = Screen.Width bkgdtiler.ScaleMode = 3 bkgdtiler!Picture1.Top = 0 bkgdtiler!Picture1.Left = 0 bkgdtiler!Picture1.Picture = LoadPicture(bkgdfile) bkgdtiler!Picture1.ScaleMode = 3 For n% = 0 To ScHeight% Step bkgdtiler!Picture1.ScaleHeight For o% = 0 To ScWidth% Step bkgdtiler!Picture1.ScaleWidth bkgdtiler.PaintPicture bkgdtiler!Picture1.Picture, o%, n% Next o% Next n% MDIForm.Picture = bkgdtiler.Image Unload bkgdtiler End Sub |
| Private Sub MDIForm_Load() TileMDIBkgd Me, Form1, "c:\windows\Tiles.bmp" End Sub |
| Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Const WM_CLOSE = &H10 |
| Dim winHwnd As Long Dim RetVal As Long winHwnd = FindWindow(vbNullString, "小算盘") Debug.Print winHwnd If winHwnd <> 0 Then RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&) If RetVal = 0 Then MsgBox "Error posting message." End If Else MsgBox "并未开启小算盘程序." End If |
| True:显示鼠标 / False:隐藏鼠标 Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Long) As Long |
| ’在声明区中 (Bas Module / Form Module) 加入以下声明: Public Const EWX_LOGOFF = 0 ’这四个常数值可以并用 Public Const EWX_SHUTDOWN = 1 Public Const EWX_REBOOT = 2 Public Const EWX_FORCE = 4 Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long ’实例:如果您想强迫关机重开机,程序码如下: ret = ExitWindowsEx(EWX_FORCE OR EWX_REBOOT, 0) |
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页