设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

Show 一个没有菜单的界面(ADP)

[复制链接]

点击这里给我发消息

1#
发表于 2011-7-19 10:01:55 | 显示全部楼层
界面布置紧凑合理,赞!
照片显示采用MSFORM2.0.Image控件,是否还要释放临时图片文件?

点击这里给我发消息

2#
发表于 2011-7-19 12:56:30 | 显示全部楼层
回复 zhuyiwen 的帖子

朱总的代码好呀,我也曾用了类似的方法。
其实jpg图片数据也可用代码转换后,在ACCESS.image控件显示。

点击这里给我发消息

3#
发表于 2011-7-19 14:08:39 | 显示全部楼层
回复 zhuyiwen 的帖子

  1. 下面的代码从位图句柄获取位图数据

  2. Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  3. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  4. Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
  5. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
  6. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  7. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

  8. Private Type bitmap
  9.     bmType As Long
  10.     bmWidth As Long
  11.     bmHeight As Long
  12.     bmWidthBytes As Long
  13.     bmPlanes As Integer
  14.     bmBitsPixel As Integer
  15.     bmBits As Long
  16. End Type

  17. Private Type BITMAPINFOHEADER
  18.         biSize As Long
  19.         biWidth As Long
  20.         biHeight As Long
  21.         biPlanes As Integer
  22.         biBitCount As Integer
  23.         biCompression As Long
  24.         biSizeImage As Long
  25.         biXPelsPerMeter As Long
  26.         biYPelsPerMeter As Long
  27.         biClrUsed As Long
  28.         biClrImportant As Long
  29. End Type
  30. Private Type RGBQUAD
  31.         rgbBlue As Byte
  32.         rgbGreen As Byte
  33.         rgbRed As Byte
  34.         rgbReserved As Byte
  35. End Type

  36. Private Type BITMAPINFO
  37.         bmiHeader As BITMAPINFOHEADER
  38.         bmiColors As RGBQUAD
  39. End Type

  40. Private Const DIB_RGB_COLORS = 0
  41. Private Const BI_RGB = 0&

  42. Private Function GetPictureDataFromBitmap(hBitmap As Long, bPictureData() As Byte) As Boolean
  43.     Dim bm As bitmap
  44.     Dim bi24BitInfo As BITMAPINFO
  45.     Dim hMemDc As Long
  46.     Dim bBytes() As Byte

  47.     GetObject hBitmap, Len(bm), bm
  48.     With bi24BitInfo.bmiHeader
  49.         .biWidth = bm.bmWidth
  50.         .biHeight = bm.bmHeight
  51.         .biBitCount = 24
  52.         .biCompression = BI_RGB
  53.         .biPlanes = 1
  54.         .biSize = Len(bi24BitInfo.bmiHeader)
  55.     End With
  56.     ReDim bBytes(1 To ((bm.bmWidth * 3 + 3) \ 4) * 4 * bm.bmHeight) As Byte
  57.     hMemDc = CreateCompatibleDC(0)
  58.     GetDIBits hMemDc, hBitmap, 0, bm.bmHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
  59.    
  60.     ReDim bPictureData(bi24BitInfo.bmiHeader.biSizeImage + 40)
  61.     CopyMemory bPictureData(40), bBytes(1), bi24BitInfo.bmiHeader.biSizeImage
  62.     CopyMemory bPictureData(0), bi24BitInfo.bmiHeader, 40

  63.     DeleteDC hMemDc
  64.     DeleteObject hBitmap

  65. End Function
复制代码
6楼的代码可以获得StdPicture对象,此代码可将StdPicture对象转为access.image控件支持的位图数据,此代码结合6楼的代码如下使用即可:
Dim  bPictureData()  As  Byte
GetPictureDataFromBitmap  LoadPictureFromField(f).Handle,  bPictureData()
Me.Image1.PictureData = bPictureData()
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-3 18:47 , Processed in 0.084235 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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