设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 2011-7-19 00:29:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式








界面导航元素:选项卡、子窗体、按钮

(注:照片的存储格式为直接的JPG文件存储在image字段,显示采用MSFORM2.0.Image控件,非ACCESS的Image和绑定对象控件, 这样的好处是占用空间小。)

请大家评评。






本帖子中包含更多资源

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

x

本帖被以下淘专辑推荐:

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏4 分享分享 分享淘帖2 订阅订阅
2#
发表于 2011-7-19 06:05:54 | 只看该作者
好早呀

点击这里给我发消息

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

点击这里给我发消息

4#
 楼主| 发表于 2011-7-19 10:44:59 | 只看该作者
t小宝 发表于 2011-7-19 10:01
界面布置紧凑合理,赞!
照片显示采用MSFORM2.0.Image控件,是否还要释放临时图片文件?

不用产生临时文件,直接读字段内容。
注:MSFORM2.0为Office自带控件,通常用于UserForm(用户窗体)。
5#
发表于 2011-7-19 10:58:36 | 只看该作者
漂亮啊,学习.

点击这里给我发消息

6#
 楼主| 发表于 2011-7-19 11:03:08 | 只看该作者
贴一段读图片的代码:
  1. Option Compare Database
  2. Option Explicit

  3. Private Const S_OK = 0    ' indicates successful HRESULT
  4. Private Const sIID_IPicture = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"
  5. Private Const GMEM_MOVEABLE = &H2

  6. Private Type GUID    ' 16 bytes (128 bits)
  7.   dwData1 As Long    ' 4 bytes
  8.   wData2 As Integer  ' 2 bytes
  9.   wData3 As Integer  ' 2 bytes
  10.   abData4(7) As Byte ' 8 bytes, zero based
  11. End Type

  12. Public Enum CBoolean   ' enum members are Long data types
  13.   CFalse = 0
  14.   CTrue = 1
  15. End Enum

  16. Private Declare Function GlobalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal dwBytes As Long) As Long
  17. Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
  18. Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
  19. Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long

  20. Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pCLSID As GUID) As Long
  21. Private Declare Function OleLoadPicture Lib "olepro32" (pStream As Any, ByVal lSize As Long, ByVal fRunmode As CBoolean, riid As GUID, ppvObj As Any) As Long

  22. Private Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As Long, ByVal fDeleteOnRelease As CBoolean, ppstm As Any) As Long

  23. Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)


  24. Public Function PictureFromBits(abPic() As Byte) As IPicture  ' not a StdPicture!!
  25.     Dim nLow As Long, cbMem  As Long, hMem  As Long
  26.     Dim lpMem  As Long, IID_IPicture As GUID
  27.     Dim IStm As stdole.IUnknown, IPic As IPicture
  28.     ' Get the size of the picture's bits
  29.     On Error GoTo Out
  30.     nLow = LBound(abPic)
  31.     On Error GoTo 0
  32.     cbMem = (UBound(abPic) - nLow) + 1
  33.     ' Allocate a global memory object
  34.     hMem = GlobalAlloc(GMEM_MOVEABLE, cbMem)
  35.     If hMem Then
  36.         ' Lock the memory object and get a pointer to it.
  37.         lpMem = GlobalLock(hMem)
  38.         If lpMem Then
  39.             ' Copy the picture file bytes to the memory pointer
  40.             ' and unlock the handle.
  41.             MoveMemory ByVal lpMem, abPic(nLow), cbMem
  42.             Call GlobalUnlock(hMem)
  43.             ' Create an ISteam from the pictures bits (we can
  44.             ' explicitly free hMem below, but we'll have the
  45.             ' call do it here...)
  46.             If (CreateStreamOnHGlobal(hMem, CTrue, IStm) = S_OK) Then
  47.                 If (CLSIDFromString(StrPtr(sIID_IPicture), _
  48.                     IID_IPicture) = S_OK) Then
  49.                     ' Create an IPicture from the IStream (the docs
  50.                     ' say the call does not AddRef its last param, but
  51.                     'it looks like the reference counts are correct..)
  52.                     Call OleLoadPicture(ByVal ObjPtr(IStm), cbMem, CFalse, IID_IPicture, PictureFromBits)
  53.                 End If   ' CLSIDFromString
  54.             End If   ' CreateStreamOnHGlobal
  55.         End If   ' lpMem
  56.         Call GlobalFree(hMem)
  57.     End If   ' hMem
  58. Out:
  59. End Function


  60. 'With Form Inet1 Control
  61. 'Private Function GetPicFromHTTP(strURL As String, Optional Username As String, Optional Password As String) As IPicture
  62. '    Dim bytearray() As Byte
  63. '
  64. '    Inet1.URL = strURL
  65. '    Inet1.Username = Username
  66. '    Inet1.Password = Password
  67. '    bytearray() = Inet1.OpenURL(, icByteArray)
  68. '
  69. '    Set GetPicFromHTTP = PictureFromBits(bytearray)
  70. '
  71. 'End Function


  72. '
  73. 'Private Sub Command1_Click()
  74. '    Picture1.Picture = GetPicFromHTTP("http://msdn.microsoft.com/library/shared/toolbar/graphics/banners/MSDN_banner.gif";) '("http://www.wandtv.com/rdrimg.jpg";)
  75. 'End Sub


  76. Public Function LoadPictureFromField(f As ADODB.field) As StdPicture
  77.     Dim b1() As Byte
  78.    
  79.     If f.ActualSize <> 0 Then
  80.         ReDim b1(1 To f.ActualSize) As Byte
  81.         b1 = f.GetChunk(f.ActualSize)
  82.         Set LoadPictureFromField = PictureFromBits(b1)
  83.     End If
  84. End Function


  85. Public Function LoadPictureFromFile(filePath As String) As StdPicture
  86.     Dim b1() As Byte
  87.    
  88.     Open filePath For Binary As #1
  89.     ReDim b1(1 To LOF(1))
  90.     Get 1, , b1
  91.     Close 1
  92.    
  93.     Set LoadPictureFromFile = PictureFromBits(b1)
  94. End Function
复制代码



点击这里给我发消息

7#
 楼主| 发表于 2011-7-19 11:08:16 | 只看该作者
调用Public Function LoadPictureFromField(f As ADODB.field) As StdPicture函数从字段读图片到MSFORM20.Image控件。当然,这个Field可以是SQL Server的Image字段,也可以是mdb的OLE字段,关键是这个字段存储的图片的内容,而非OLE对象。
8#
发表于 2011-7-19 12:31:46 | 只看该作者
老师就是厉害!!

点击这里给我发消息

9#
发表于 2011-7-19 12:56:30 | 只看该作者
回复 zhuyiwen 的帖子

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

点击这里给我发消息

10#
 楼主| 发表于 2011-7-19 12:58:21 | 只看该作者
t小宝 发表于 2011-7-19 12:56


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

能否共享一下?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-1 19:34 , Processed in 0.175360 second(s), 37 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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