
常用软件类: |
|杀毒安全 | |联络聊天 | |网络软件 | |多媒体类 | |系统工具 | |图形图像 | |系统工具 | |应用软件 | |行业软件 |
开发设计类: |
|动画制作 | |图像处理 | |3D设计 | |操作系统 | |站长学院 | |网络相关 | |WEB设计 | |数据库类 | |程序开发 |
如何把小图片填满 MDIForm 成为背景图?
以下这个范例,要:
1、一个 MDIForm:不必设定任何属性。
2、一个 Form1:不一定是 MDIChild,最好 MDIChild 为 False,但是 AutoRedraw 设成 True。
3、Form1 上面放一个隐藏的 PictureBox:名称为 Picture1,不必设定 Picture 属性。
4、一张图片的完整路径。
| ’将以下模组放入 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) |
| Dim RetVal As Long RetVal = Shell("C:\Windows\Notepad.exe C:\Test.txt", 3) ’3代表视窗会最大化,并具有驻点,细节请查 Help |
| ’在声明区中加入以下声明: Const MAX_PATH = 260 Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Public Function GetWinPath() Dim strFolder As String Dim lngResult As Long strFolder = String(MAX_PATH, 0) lngResult = GetWindowsDirectory(strFolder, MAX_PATH) If lngResult <> 0 Then GetWinPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1) Else GetWinPath = "" End If End Function ’在程序中使用方法如下: Private Sub Command1_Click() Call MsgBox("您电脑中 Windows 目录的正确路径是: " & GetWinPath, vbInformation) End Sub |