OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 16-03-2005, 14:05
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default Changing color space in an RGB only world...

I am currently working on a macro that will put a 3D looking highlight on the currently selected object. I am allowing the user to chose between CMYK and RGB. The problem that I am running into is this...

I am using an image box for my swatch sample and converting the Backcolor to match the text boxes (see below). This is all fine and good if the user is using RGB, but when it is set to CMYK, I can't figure out how to convert my C, M, Y, and K inputs to RGB so that I can update the "swatch".

Here is some of the code... I am posting the full code in the CodeCritique for any advice...
Code:
Option Explicit

Private Sub cbxColorSpace_Change()
    If cbxColorSpace.Value = "CMYK" Then
        start1.Visible = True
        start1.Caption = "C"
        sColor1.Visible = True
        spinSColor1.Visible = True
        spinSColor1.Max = 100
        'continue toggling visibility and captions
    Else
        start1.Visible = True
        start1.Caption = "R"
        sColor1.Visible = True
        spinSColor1.Visible = True
        spinSColor1.Max = 255
        'continue toggling visibility and captions
    End If
    
    
End Sub

Private Sub sColor1_Change()
    spinSColor1.Value = sColor1.Value
    UpdateStartSwatch
End Sub

Private Sub fcolor1_Change()
    spinFColor1.Value = fColor1.Value
    UpdateFinishSwatch
End Sub

'...various other spinner to textbox updates...

Private Sub UserForm_Initialize()
    Dim as1 As Shape
    Set as1 = ActiveSelection
    Dim c As New Color
    
    With cbxColorSpace
        .AddItem "CMYK"
        .AddItem "RGB"
    End With
    cbxColorSpace.Value = "CMYK"
    
    If cbxColorSpace.Value = "RGB" Then
        as1.Fill.UniformColor.ConvertToRGB
    End If
    
    c.CopyAssign as1.Fill.UniformColor
    c.ConvertToRGB
    
    StartColor.BackColor = RGB(c.RGBRed, c.RGBGreen, c.RGBBlue)
    FinishColor.BackColor = RGB(255, 255, 255)
    optLow.Value = True
    optTL.Value = True
    Sample.Picture = LoadPicture(Application.GMSManager.GMSPath & "samples\low_TL.bmp")
End Sub

Private Sub UpdateSample()

    'This area is used to update the "preview" sample    
End Sub

Private Sub UpdateStartSwatch()
    If cbxColorSpace.Value = "RGB" Then
        StartColor.BackColor = RGB(sColor1.Value, sColor2.Value, sColor3.Value)
    Else
        'need operations
    End If
    
End Sub

Private Sub UpdateFinishSwatch()
    Dim c As New Color
    
    If cbxColorSpace.Value = "RGB" Then
        FinishColor.BackColor = RGB(fColor1.Value, fColor2.Value, fColor3.Value)
    Else
        With c
            .CMYKCyan = fColor1.Value
            .CMYKMagenta = fColor2.Value
            .CMYKYellow = fColor3.Value
            .CMYKBlack = fColor4.Value
        End With
        
        c.ConvertToRGB
        FinishColor.BackColor = RGB(c.RGBRed, c.RGBGreen, c.RGBBlue)
    End If
    
End Sub
the following code is where it messes up and I don't know what to do...
Code:
Else
        With c
            .CMYKCyan = fColor1.Value
            .CMYKMagenta = fColor2.Value
            .CMYKYellow = fColor3.Value
            .CMYKBlack = fColor4.Value
        End With
        
        c.ConvertToRGB
        FinishColor.BackColor = RGB(c.RGBRed, c.RGBGreen, c.RGBBlue)
    End If
Attached Images
 
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 16-03-2005, 14:44
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Changing color space in an RGB only world...

When you create a new color object it is uninitialized. Meaning that it is not a CMYK nor RGB nor anything else. Just setting CMYKCyan and other components won't make it a CMYK color. What you need to use is CMYKAssign method:

Code:
Else 
    c.CMYKAssign fColor1.Value, fColor2.Value, fColor3.Value, fColor4.Value 
    c.ConvertToRGB 
    FinishColor.BackColor = RGB(c.RGBRed, c.RGBGreen, c.RGBBlue) 
End If
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
changing Caption bumblebee CorelDRAW/Corel DESIGNER VBA 6 13-12-2004 09:13
VBA help needed - changing colours fremoikaner CorelDRAW/Corel DESIGNER VBA 1 18-11-2004 06:06
Have a major problem with events ,commands changing pls help ayo CorelDRAW/Corel DESIGNER VBA 2 20-04-2004 14:53
Changing the linecross to mousepointer Scrat CorelDRAW/Corel DESIGNER VBA 2 28-10-2003 03:17
Keeping the stacking order when changing layers Rick Randall CorelDRAW/Corel DESIGNER VBA 1 04-02-2003 22:34


All times are GMT -5. The time now is 04:32.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com