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 21-02-2005, 11:38
zlatev
Guest
 
Posts: n/a
Default Palette (or Colors array) property in VBA class in CDR12

Hi all,
I am writing some script that will collect statistics about colors in document.
However I am having problems with the class that will collect these statistics.

This is what I try in order to have a property in the class that will collect colors from the document.
Code:
Dim oPalette As Palette

Public Property Set Palette(ByRef thePalette As Palette)
    Set oPalette = thePalette
End Property

Public Property Get Palette() As Palette
    Set Palette = oPalette
End Property

Private Sub Class_Initialize()
    Dim oPalette As Palette
    Set oPalette = New Palette
    Set Me.Palette = oPalette
End Sub
However as soon as I try to instantiate object of this class I get
Quote:
Run-time error '429':
ActiveX component can't create object
When I click on the debug button, it shows me that the error is on the line where I try to instantiate object of the class defined in the sample code above. When I step into I see that the initialization fails on line
Code:
Set oPalette = New Palette
So I guess I am doing something wrong.
The idea is to collect colors from the ones that are used in the document in a property of the instance of the class.
Hope it makes sense :roll:

_____

Looking through the VBA help of CDR12 I found Palettes.Create
However I do not like to have a physical file for the palette.
Is it possible, or I am riding the wrong horse?

_____
Another thing that I am not sure - is it possible to combine colors from different standard palettes in one custom one?
Reply With Quote
  #2  
Old 21-02-2005, 21:35
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Palette (or Colors array) property in VBA class in CDR12

Yes, unfortunately you can't create an instance of pallete by just using the New keyword.. You need to use Application.Palettes.Create method instead.

However I'm not sure why you need this in your case. I would use Palettes.CreateFromDocument to create a palette from all the colors from the current (active) document like this:

Code:
Set oPalette = Application.Palettes.CreateFromDocument("MyPalette")
or if you want to do this yourself somehow, I would use something like a regular VBA's Collection object to keep the dynamic array of colors. Or have some other way, something like MS Scripting Runtime's Dictionary object which is essentially a map with very quick lookup...
Reply With Quote
  #3  
Old 22-02-2005, 01:27
zlatev
Guest
 
Posts: n/a
Default

Quote:
However I'm not sure why you need this in your case. I would use Palettes.CreateFromDocument to create a palette from all the colors from the current (active) document like this:
Well I hesitate to use this because I would use only subset of used colors in the document.

Quote:
or if you want to do this yourself somehow, I would use something like a regular VBA's Collection object to keep the dynamic array of colors.
I think Collection object will do the trick. Thank you
Reply With Quote
  #4  
Old 22-02-2005, 10:24
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

It all depends on the object's fill type. If it is Uniform Fill, then use UniformColor property, if it is fountain fill, then use Fountain and go through all of the colors in the list and so on. Obviously, No fill means no color at all...
Reply With Quote
  #5  
Old 22-02-2005, 10:31
zlatev
Guest
 
Posts: n/a
Default

OK Thank you for you reply, but I figured out that the error was in my code bellow the line I mentioned.
This is why I deleted my question

For the record - it was something like
Quote:
How can I get 100% sure the color of the fill of an object. For the moment I use Shape.Fill.UniformColor
____
If you are still willing to answer: whats the difference (if any) between cdrColorPantoneHex and cdrColorPantone?
Well actually I need to know which color types have Tint property, and because I am not a CorelDraw expert, I actually am not aware of differences between palettes.
Reply With Quote
  #6  
Old 22-02-2005, 11:00
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Quote:
Originally Posted by zlatev
If you are still willing to answer: whats the difference (if any) between cdrColorPantoneHex and cdrColorPantone?
Well actually I need to know which color types have Tint property, and because I am not a CorelDraw expert, I actually am not aware of differences between palettes.
The just about to be released CorelDESIGNER 12 has some cool additions to the Color object, methods such as IsGray, IsWhite, IsSpot, IsTintable, IsValidDuotoneColor, and so on. I'm sure they will be in CorelDRAW 13 too.

But in meanwhile, a tintable color is any of the Pantones (except for Pantone Process) including Pantone Hexachrome, as well as DIC, TOYO, HKS, DUPONT, FOCOLTONE, and User Inks.

I hope this helps
Reply With Quote
  #7  
Old 22-02-2005, 11:11
zlatev
Guest
 
Posts: n/a
Default

Hopefully last thing in this thread... :roll:

Is there any fast way to get a name for an "unnamed color" like "R: 22 G: 89 B: 111" (At the moment I am doing this "by-hand" in the program code)

I mean CorelDraw12 shows a shape filled with uniform fill with such an RGB color, with name "R: 22 G: 89 B: 111" in Object Manager, but when I programatically check the Name property of the Color object - it has a value "unnamed color"

Also is there a better way to check wether a color has a name than comparing its Name property with value "unnamed color"?

And thank you for the help!
Reply With Quote
  #8  
Old 22-02-2005, 11:28
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

The Name property actually has a Boolean parameter which is optional. Set it to True to return the actual component string, rather than the color name:

Code:
MsgBox ActiveShape.Fill.UniformColor.Name(True)
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
CDR12 ?Bug?: HSB Colors zlatev CorelDRAW/Corel DESIGNER VBA 2 22-02-2005 13:21
How to set palette as default palette with VBA ? hmalme CorelDRAW/Corel DESIGNER VBA 1 22-12-2004 13:26


All times are GMT -5. The time now is 22:24.


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