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 28-03-2004, 17:35
AARRGGHHH
Guest
 
Posts: n/a
Default Finding Color Currently Selected in RGB or CMYK Palette

Hi Everyone

I'm a VB programmer with VERY little experience using VBA, and I'm completely stuck on what is probably a simple issue: How do I find which color is currently selected in the RGB or CMYK palette?

I thought something like this would work:
Code:
lblColor.BackColor = Application.ActivePalette.Color
But the only thing this seems to let me do is ASSIGN a color (not GET a color).

Thanks
Reply With Quote
  #2  
Old 30-03-2004, 10:03
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Finding Color Currently Selected in RGB or CMYK Palette

Well, I'm not sure I understand your problem. As far as I know, there is no "selected color" in a palette. When you click on a color well in a palette, the color gets applied to the selected object(s) fills/outlines but the palette itself loses the color selection the same instant. It doesn't know and it doesn't care which one you selected.

If you want to inspect the fill color of selected object, then you can do it like this:

Code:
ActiveShape.Fill.UniformColor.RGBRed
to return the value of red component of RGB color. Of course, you need to test first if the object has the uniform color first. If this is the case, then you need to see the color model. Finally, if it's RGB, you can access all those RGBRed, RGBGreen, RGBBlue properties.

You can create a copy of the color object and convert the color to the specific color model if you want to get RGB equivalent of the current fill color:

Code:
Sub InspectColors()
    Dim c As New Color
    
    If ActiveShape Is Nothing Then
        MsgBox "No object selected", vbCritical
        Exit Sub
    End If
    
    If ActiveShape.Fill.Type <> cdrUniformFill Then
        MsgBox "The selected object doesn't have a uniform fill", vbCritical
        Exit Sub
    End If
    
    c.CopyAssign ActiveShape.Fill.UniformColor
    c.ConvertToRGB
    MsgBox "The fill color RGB equivalent is: RGB(" & c.RGBRed & "," & c.RGBGreen & "," & c.RGBBlue & ")"
End Sub
Obviously, you can do a lot more with colors, and they don't have to be in object's fill/outline. But I don't know what exactly you are trying to do, so I'll let you figure out the rest

If you want some more examples, you might want to take a look at Color replacer macro (http://www.oberonplace.com/vba/drawm...acer/index.htm). Or look in the VBA help file on Color object, or read the CorelDRAW VBA programming guide manual (dvba_pg.pdf in Programs folder of your CorelDRAW installation). This should give you more info.
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
Palette (or Colors array) property in VBA class in CDR12 zlatev CorelDRAW/Corel DESIGNER VBA 7 22-02-2005 12:28


All times are GMT -5. The time now is 16:14.


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