|
- Private Function UnRGB(RGBCol As Long, position As Integer) As Long
- 'Part: 0=Red, 1=Green, 2=Blue
- 'Can't divide by ZERO!
- If RGBCol = 0 Then
- UnRGB = 0
- Exit Function
- End If
- Select Case position
- Case 0
- UnRGB = RGBCol And &HFF
- Case 1
- UnRGB = (RGBCol And &HFF00)
- If UnRGB = 0 Then Exit Function
- UnRGB = UnRGB / 256 '&HFF
- UnRGB = UnRGB And &HFF
- Case 2
- UnRGB = (RGBCol And &HFF0000)
- If UnRGB = 0 Then Exit Function
- UnRGB = UnRGB / 65536 '&HFFFF
- UnRGB = UnRGB And &HFF
- End Select
- End Function
- Private Function GetUniqueFilename(Optional Path As String = "", _
- Optional Prefix As String = "", _
- Optional UseExtension As String = "") _
- As String
- ' originally Posted by Terry Kreft
- ' to: comp.Databases.ms -Access
- ' Subject: Re: Creating Unique filename ??? (Dev code)
- ' Date: 01/15/2000
- ' Author: Terry Kreft <terry.kreft@mps.co.uk>
- ' SL Note: Input strings must be NULL terminated.
- ' Here it is done by the calling function.
- Dim wUnique As Long
- Dim lpTempFileName As String
- Dim lngRet As Long
-
- wUnique = 0
- If Path = "" Then Path = CurDir
- lpTempFileName = String(MAX_PATH, 0)
- lngRet = GetTempFileName(Path, Prefix, _
- wUnique, lpTempFileName)
-
- lpTempFileName = Left(lpTempFileName, _
- InStr(lpTempFileName, Chr(0)) - 1)
- Call Kill(lpTempFileName)
- If Len(UseExtension) > 0 Then
- lpTempFileName = Left(lpTempFileName, Len(lpTempFileName) - 3) & UseExtension
- End If
- GetUniqueFilename = lpTempFileName
- End Function
- Private Function BoundBox(ByRef lpSZ As Size, ByRef lpRect As RECT, ByVal lngRotate As Long) As SizeX2
- ' *****************************************************
- ' I would like to thank Rod Stephen's for Permission to
- ' use his Trig Calculations from his book
- ' "Custom Controls Library". I also highly reccommend his
- ' book "Visual Basic Graphics Programming".
- ' *****************************************************
- Dim x(1 To 4) As Single
- Dim y(1 To 4) As Single
- Dim xmin As Single
- Dim xmax As Single
- Dim ymin As Single
- Dim ymax As Single
- Dim stheta As Single
- Dim ctheta As Single
- Dim i As Integer
- Dim tmp As Single
- Dim bbsz As SizeX2
-
- ' Calculate a bounding box for the text.
- x(1) = 0
- x(2) = lpSZ.cx
- x(3) = x(2)
- x(4) = 0
- y(1) = 0
- y(2) = 0
- y(3) = lpSZ.cy
- y(4) = y(3)
-
- ' Rotate the bounding box.
- stheta = Sin(Abs(lngRotate) * PI_180)
- ctheta = Cos(Abs(lngRotate) * PI_180)
- For i = 2 To 4
- tmp = x(i) * ctheta + y(i) * stheta
- y(i) = -x(i) * stheta + y(i) * ctheta
- x(i) = tmp
- Next i
-
- ' Bound the rotated bounding box.
- xmin = x(1)
- xmax = xmin
- ymin = y(1)
- ymax = ymin
- For i = 2 To 4
- If xmin > x(i) Then xmin = x(i)
- If xmax < x(i) Then xmax = x(i)
- If ymin > y(i) Then ymin = y(i)
- If ymax < y(i) Then ymax = y(i)
- Next i
-
- ' Let's set the size our finished Image Control
- ' to be exactly the size of the Rotated Text
- With lpRect
- .top = 0
- .Left = 0
-
- ' Horizontal Alignment is only LEFT for this version
- tmp = .right / 2 - (xmin + xmax) / 2
- For i = 1 To 4
- x(i) = tmp + x(i)
- Next i
-
- ' Vertical Alignment is only Center for this version
- tmp = .Bottom / 2 - (ymin + ymax) / 2
- For i = 1 To 4
- y(i) = tmp + y(i)
- Next i
- End With
-
- bbsz.cx = x(1)
- bbsz.cy = y(1)
- bbsz.widthX = (xmax - xmin) + 1
- bbsz.widthY = (ymax - ymin) + 1
-
- BoundBox = bbsz
- ' ******************************
- ' END OF ROTATED TEXT TRIG CALCS
- ' ******************************
- End Function
- ' Original Code by Terry Kreft
- ' Modified by Stephen Lebans
- ' Contact Stephen@lebans.com
- '*********** Code Start ***********
- Public Function aDialogColor() As Long
- Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long
- CS.lStructSize = Len(CS)
- CS.hwnd = hWndAccessApp
- CS.Flags = CC_SOLIDCOLOR
- CS.lpCustColors = String$(16 * 4, 0)
- x = ChooseColor(CS)
- If x = 0 Then
- ' ERROR - use Default White
- 'Access Maps Pure White(R255,G255,B255) to its
- ' standard Grey color. Get around this by
- ' selecting (R254,G254,B254)
- aDialogColor = RGB(254, 254, 254) ' White
- Exit Function
- Else
- ' Normal processing
- If CS.rgbResult = RGB(255, 255, 255) Then
- aDialogColor = RGB(254, 254, 254)
- Else
- aDialogColor = CS.rgbResult
- End If
- End If
- End Function
- '*********** Code End ***********
- ' To call it from your Form with use code like:
- ' ***Code Start
- 'Private Sub CmdChooseBackColor_Click()
- ' Pass the TextBox Control to the function
- 'Me.textCtl.BackColor = DialogColor(Me.textCtl)
- 'End Sub
- ' ***Code End
复制代码 |
|