![]() |
#1
|
|||
|
|||
![]()
Hi. I am using CD11
I use UserAssignEx to open the color selector dialog, and store the selection in a database. When I choose "red" in cmyk (0,100,100,0) , I get the number 1910234 stored in the data table. I don't know what format that is. How do I then use this info to specify a uniform fill color? Once I get access the value from the recordset, rsDotInfo("dotColor"), do I convert it and how do I code it? Can I use something like s.Fill.UniformColor.CMYKAssign once it is converted? |
#2
|
||||
|
||||
![]() Code:
Function ColorToString(clr As Color) As String Dim c0&, c1&, c2&, c3&, c4&, c5&, c6&, c7& clr.CorelScriptGetComponent c0, c1, c2, c3, c4, c5, c6, c7 On Error Resume Next ColorToString = Join(Array(c0, c1, c2, c3, c4, c5, c6, c7), ":") End Function Function ColorAssignFromString(ByRef clr As Color, compStr As String) As Boolean Dim cc() As String On Error GoTo BadString cc = Split(compStr, ":") If clr Is Nothing Then Set clr = New Color If UBound(cc) < 7 Then ReDim Preserve cc(0 To 7) clr.CorelScriptAssign cc(0), cc(1), cc(2), cc(3), cc(4), cc(5), cc(6), cc(7) ColorAssignFromString = True BadString: End Function Code:
dim s as string, с as color --------------------- CONVERT TO STRING set c=new color if c.UserAssignEx then s=ColorToString(c) ........ endif --------------------- ASSIGN FROM STRING s=....from db..... if not ColorAssignFromString (myShape.Fill.UniformColor, s) then 'error .......... Last edited by wOxxOm; 21-05-2007 at 16:13. |
#3
|
|||
|
|||
![]()
Thanks wOxxOm
Not too sure how to correctly implement it. Below is the dblclick event of a text box. "Dot 1" is in the active layer. Code:
Private Sub txtCommon3_Enter() Dim sh As Shape Dim s As Color sh = ActiveLayer.Shapes.FindShape("dot 1") If Not ColorAssignFromString(sh.Fill.UniformColor, s) Then 'error End Sub |
#4
|
||||
|
||||
![]()
:-) s is a string (text) variable that holds color universal description, use F8 if unsure and look at variables and results of functions
Code:
Private Sub txtCommon3_Enter() dim myColorString as string Dim sh As Shape sh = ActiveLayer.Shapes.FindShape("dot 1") myColorString=......... ' do you get it from database? or what? if not sh is nothing then If Not ColorAssignFromString(sh.Fill.UniformColor, myColorString) Then 'error msgbox "Achtung!" endif endif End Sub |
#5
|
|||
|
|||
![]()
Aah.
Good I got it. Just one more blip. I still need to use the color, retrieved from the database, for a userform textbox backcolor. |
#6
|
||||
|
||||
![]()
you need to ensure the color is rgb:
Code:
'....convert to rgb dim c as color ColorAssignFromString c,DBstring c.ConvertToRGB textbox.BackColor=rgb(c.RGBRed, c.RGBGreen, c.RGBBlue) |
#7
|
|||
|
|||
![]()
Vielen Dank again wOxxOm
It is working fine. |
#8
|
||||
|
||||
![]()
portions © 4vR by Alex :-)
|
#9
|
||||
|
||||
![]()
By the way, you can use the native Color to string conversion methods to convert any color object into a string you can store in a database and then you can recreate the color from the database.
For this, you just use Color.ToString method to get a string out of a color object and then you can use Application.CreateColor to get a color from a string (or if you have a color object you want to update just use Color.StringAssign method): Code:
Dim c As New Color If c.UserAssignEx() Then SaveInDatabase c.ToString() End If Code:
Dim s As String Dim c As Color s = GetFromDatabase() Set c = Application.CreateColor(s) |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|