设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: roych
打印 上一主题 下一主题

[API] 【API】自定义字体如何消除锯齿化?

[复制链接]
11#
 楼主| 发表于 2015-7-9 11:35:34 | 只看该作者
  1. Private Function UnRGB(RGBCol As Long, position As Integer) As Long
  2. 'Part: 0=Red, 1=Green, 2=Blue

  3. 'Can't divide by ZERO!
  4.     If RGBCol = 0 Then
  5.     UnRGB = 0
  6.     Exit Function
  7.     End If

  8. Select Case position
  9.     Case 0
  10.     UnRGB = RGBCol And &HFF

  11.     Case 1
  12.     UnRGB = (RGBCol And &HFF00)
  13.     If UnRGB = 0 Then Exit Function
  14.     UnRGB = UnRGB / 256  '&HFF
  15.     UnRGB = UnRGB And &HFF

  16.     Case 2
  17.     UnRGB = (RGBCol And &HFF0000)
  18.     If UnRGB = 0 Then Exit Function
  19.     UnRGB = UnRGB / 65536 '&HFFFF
  20.     UnRGB = UnRGB And &HFF

  21. End Select

  22. End Function



  23. Private Function GetUniqueFilename(Optional Path As String = "", _
  24. Optional Prefix As String = "", _
  25. Optional UseExtension As String = "") _
  26. As String

  27. ' originally Posted by Terry Kreft
  28. ' to: comp.Databases.ms -Access
  29. ' Subject:  Re: Creating Unique filename ??? (Dev code)
  30. ' Date: 01/15/2000
  31. ' Author: Terry Kreft <terry.kreft@mps.co.uk>

  32. ' SL Note: Input strings must be NULL terminated.
  33. ' Here it is done by the calling function.

  34.   Dim wUnique As Long
  35.   Dim lpTempFileName As String
  36.   Dim lngRet As Long
  37.   
  38.   wUnique = 0
  39.   If Path = "" Then Path = CurDir
  40.   lpTempFileName = String(MAX_PATH, 0)
  41.   lngRet = GetTempFileName(Path, Prefix, _
  42.                             wUnique, lpTempFileName)

  43.   lpTempFileName = Left(lpTempFileName, _
  44.                         InStr(lpTempFileName, Chr(0)) - 1)
  45.   Call Kill(lpTempFileName)
  46.   If Len(UseExtension) > 0 Then
  47.     lpTempFileName = Left(lpTempFileName, Len(lpTempFileName) - 3) & UseExtension
  48.   End If
  49.   GetUniqueFilename = lpTempFileName
  50. End Function


  51. Private Function BoundBox(ByRef lpSZ As Size, ByRef lpRect As RECT, ByVal lngRotate As Long) As SizeX2

  52. ' *****************************************************
  53. ' I would like to thank Rod Stephen's for Permission to
  54. ' use his Trig Calculations from his book
  55. ' "Custom Controls Library". I also highly reccommend his
  56. ' book "Visual Basic Graphics Programming".
  57. ' *****************************************************

  58.     Dim x(1 To 4) As Single
  59.     Dim y(1 To 4) As Single
  60.     Dim xmin As Single
  61.     Dim xmax As Single
  62.     Dim ymin As Single
  63.     Dim ymax As Single
  64.     Dim stheta As Single
  65.     Dim ctheta As Single
  66.     Dim i As Integer
  67.     Dim tmp As Single
  68.     Dim bbsz As SizeX2
  69.             
  70.         ' Calculate a bounding box for the text.
  71.         x(1) = 0
  72.         x(2) = lpSZ.cx
  73.         x(3) = x(2)
  74.         x(4) = 0
  75.         y(1) = 0
  76.         y(2) = 0
  77.         y(3) = lpSZ.cy
  78.         y(4) = y(3)
  79.    
  80.         ' Rotate the bounding box.
  81.         stheta = Sin(Abs(lngRotate) * PI_180)
  82.         ctheta = Cos(Abs(lngRotate) * PI_180)
  83.         For i = 2 To 4
  84.             tmp = x(i) * ctheta + y(i) * stheta
  85.             y(i) = -x(i) * stheta + y(i) * ctheta
  86.             x(i) = tmp
  87.         Next i
  88.         
  89.         ' Bound the rotated bounding box.
  90.         xmin = x(1)
  91.         xmax = xmin
  92.         ymin = y(1)
  93.         ymax = ymin
  94.         For i = 2 To 4
  95.             If xmin > x(i) Then xmin = x(i)
  96.             If xmax < x(i) Then xmax = x(i)
  97.             If ymin > y(i) Then ymin = y(i)
  98.             If ymax < y(i) Then ymax = y(i)
  99.         Next i
  100.    

  101.         ' Let's set the size our finished Image Control
  102.         ' to be exactly the  size of the Rotated Text
  103.     With lpRect
  104.         .top = 0
  105.         .Left = 0
  106.                
  107.         ' Horizontal Alignment is only LEFT for this version
  108.         tmp = .right / 2 - (xmin + xmax) / 2
  109.         For i = 1 To 4
  110.         x(i) = tmp + x(i)
  111.         Next i
  112.         
  113.         ' Vertical Alignment is only Center for this version
  114.         tmp = .Bottom / 2 - (ymin + ymax) / 2
  115.         For i = 1 To 4
  116.         y(i) = tmp + y(i)
  117.         Next i
  118.     End With
  119.       
  120.        bbsz.cx = x(1)
  121.        bbsz.cy = y(1)
  122.        bbsz.widthX = (xmax - xmin) + 1
  123.        bbsz.widthY = (ymax - ymin) + 1
  124.    
  125.    BoundBox = bbsz
  126. ' ******************************
  127. ' END OF ROTATED TEXT TRIG CALCS
  128. ' ******************************
  129. End Function



  130. ' Original Code by Terry Kreft
  131. ' Modified by Stephen Lebans
  132. ' Contact Stephen@lebans.com

  133. '***********  Code Start  ***********
  134. Public Function aDialogColor() As Long
  135.   Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long

  136.   CS.lStructSize = Len(CS)
  137.   CS.hwnd = hWndAccessApp
  138.   CS.Flags = CC_SOLIDCOLOR
  139.   CS.lpCustColors = String$(16 * 4, 0)
  140.   x = ChooseColor(CS)
  141.   If x = 0 Then
  142.     ' ERROR - use Default White
  143.     'Access Maps Pure White(R255,G255,B255) to its
  144.     ' standard Grey color. Get around this by
  145.     ' selecting (R254,G254,B254)
  146.     aDialogColor = RGB(254, 254, 254) ' White
  147.     Exit Function
  148.   Else
  149.     ' Normal processing
  150.     If CS.rgbResult = RGB(255, 255, 255) Then
  151.         aDialogColor = RGB(254, 254, 254)
  152.     Else
  153.         aDialogColor = CS.rgbResult
  154.     End If
  155.   End If
  156. End Function
  157. '***********  Code End   ***********


  158. ' To call it from your Form with use code like:

  159. ' ***Code Start
  160. 'Private Sub CmdChooseBackColor_Click()
  161. ' Pass the TextBox Control to the function
  162. 'Me.textCtl.BackColor = DialogColor(Me.textCtl)
  163. 'End Sub
  164. ' ***Code End
复制代码
12#
 楼主| 发表于 2015-7-9 11:36:11 | 只看该作者
  1. '报表模块
  2. '*********************************************************************************
  3. '调用函数简要说明:
  4. '
  5. '实现原理:创建自定义逻辑字体,保存在内存中,创建场景将内容保存为图片,再进行读取。
  6. '
  7. 'Call fCmdButTextPic(ctl, BGColor)
  8. '参数说明:
  9. 'ctl:必选,按钮控件
  10. 'BGColor:可选,已修改默认为白色。
  11. '*********************************************************************************
  12. Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
  13. '显示按钮标题
  14. Me.CmdColorNum.Caption = Me.ColorNumber
  15. '调整角度
  16. Me.CmdColorNum.Tag = 180
  17. fCmdButTextPic Me.CmdColorNum
  18. Me.ImgColorNum.PictureData = Me.CmdColorNum.PictureData
  19. '处理标签部分。
  20. Me.CmdPrimary.Caption = "Primary:Daylight D65"
  21. Me.CmdPrimary.Tag = 180
  22. fCmdButTextPic Me.CmdPrimary
  23. Me.ImgPrimary.PictureData = Me.CmdPrimary.PictureData

  24. Me.CmdIIIuminat.Caption = "IIIuminat used:"
  25. Me.CmdIIIuminat.Tag = 180
  26. fCmdButTextPic Me.CmdIIIuminat
  27. Me.ImgIIIuminat.PictureData = Me.CmdIIIuminat.PictureData
  28. End Sub
复制代码
13#
发表于 2015-7-9 17:04:37 | 只看该作者
{:soso_e134:}这么多
得慢慢看了.谢谢斑竹了
14#
 楼主| 发表于 2015-7-9 17:11:40 | 只看该作者
风中漫步 发表于 2015-7-9 17:04
这么多
得慢慢看了.谢谢斑竹了

贴的时候每个帖子不能超过10000字,所以就只能全部贴上来了……晕,为什么没想到导出txt再传上来呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-1 19:31 , Processed in 0.095022 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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