设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2515|回复: 3
打印 上一主题 下一主题

[API] 用API 设置窗口背景图为拉伸的代码?

[复制链接]
跳转到指定楼层
1#
发表于 2013-1-12 17:07:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2013-1-12 17:33:52 | 只看该作者
谢谢分享,我的系统环境是win7+office2010点击该实例没有任何反应
3#
发表于 2013-1-12 17:39:06 | 只看该作者
谢谢分享,呵呵。发现论坛的链接错了。
4#
 楼主| 发表于 2013-1-13 08:08:01 | 只看该作者
调用的图片不能平铺
代码:
Private Sub CmdPic_Click()   
    SetBackGround CurrentProject.Path & "\login0.jpg"
  模块  
End SubPrivate Const GCL_HBRBACKGROUND = -10
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, ByVal lpRect As Any, ByVal bErase As Long) As Long

Public Sub SetBackGround(wpv_Arg As Variant)

Dim wlo_Image As Object
Dim wlv_Brush As Long
Dim wlv_Hwnd As Long

If Not IsNumeric(wpv_Arg) Then

    Set wlo_Image = LoadPicture(wpv_Arg)
   
    wlv_Brush = CreatePatternBrush(wlo_Image.Handle)
   
    Set wlo_Image = Nothing

Else
   
    wlv_Brush = CreateSolidBrush(wpv_Arg)
End If
   
    wlv_Hwnd = FindWindowEx(Application.hWndAccessApp, 0, "MDIClient", vbNullString)
    SetClassLong wlv_Hwnd, GCL_HBRBACKGROUND, wlv_Brush
    InvalidateRect wlv_Hwnd, vbNullString, 1
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-12-27 15:03 , Processed in 0.112228 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表