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 12-01-2004, 15:24
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 ComboBox Pantone Population

:?: Is it possible to populate a combo box drop-down with a pantone color palette for CD11? What I'm going for is a print order form that I can choose the spot print colors from a drop down list. We only use PMS colors so, I want to use PMS Coated color palette as my drop-down list. Then, let's say I choose PMS 367 from the drop down list. I want the color name to be placed on the document using the CreateArtisticText command.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 12-01-2004, 16:41
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: ComboBox Pantone Population

Here is a sample for you. It looks for PMS Coated palette. If it's not open, then it opens the palette, then it goes through each color in the palette and prints the color index in the palette and the color name to the Immediate window in VBA:

Code:
Sub PaletteList()
    Dim c As Color
    Dim pal As Palette
    For Each pal In Palettes
        If pal.Type = cdrFixedPalette Then
            If pal.PaletteID = cdrPANTONECoated Then
                Exit For
            End If
        End If
    Next pal
    
    If pal Is Nothing Then
        Set pal = Palettes.OpenFixed(cdrPANTONECoated)
    End If
    
    For Each c In pal.Colors
        If c.Name <> "unnamed color" Then
            Debug.Print c.PaletteIndex; c.Name
        End If
    Next c
End Sub
Here is an alternative solution which doesn't require to open the palette first, but it assumes you know the number of colors in the palette:

Code:
Sub PaletteList2()
    Dim c As New Color
    Dim Index As Long
    
    For Index = 1 To 1148
        c.FixedAssign cdrPANTONECoated, Index
        If c.Name <> "unnamed color" Then
            Debug.Print c.PaletteIndex; c.Name
        End If
    Next Index
End Sub
In either case, the palette may have "gaps" in their color list where some colors are undefined. For example, the PANTONE Coated palette has gaps at colors #19, 20, 21, 28, 566, 567, 574,... and some more.

You can clearly see these gaps when you open the CorelDRAW color dialog. These gaps are to correspond the color indices with the actual entries in PANTONE palette which seem to have some entries missing (or so I was told).

To resolve this, I have the checks for colors with the name "unnamed color" which might change in localized versions of CorelDRAW (e.g. French, German, etc) so be careful when using the above code with those applications.

I hope this helps.
Reply With Quote
  #3  
Old 13-01-2004, 07:33
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 Yeah but...

So even if I put that code in, how do I get it to populate a drop-down list so the user can choose a color or do a type-in match?
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #4  
Old 13-01-2004, 10:36
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Yeah but...

Quote:
Originally Posted by ddonnahoe
So even if I put that code in, how do I get it to populate a drop-down list so the user can choose a color or do a type-in match?
Well, if the combo box is on a form in VBA then it should be fairly straightforward:

Code:
    MyComboBox.Clear
    For Each c In pal.Colors 
        If c.Name <> "unnamed color" Then 
            MyComboBox.AddItem c.Name
        End If 
    Next c
You need to keep in mind that some indices are skipped therefor you will need another list which will keep a list in combobox in correspondence with the palette color ID.

For example:

Code:
Dim ColorIndex As New Collection
...

Sub PaletteList() 
...
    MyComboBox.Clear
    For Each c In pal.Colors 
        If c.Name <> "unnamed color" Then 
            MyComboBox.AddItem c.Name
            ColorIndex.Add c.PaletteIndex
        End If 
    Next c
End Sub
Now when you process the input from the form, you just read in the current selection in the combo box, convert it into the palette color index and fill in the color object:

Code:
Sub OnSelectProperties()
    Dim c As New Color
    Dim Index As Long

    If MyComboBox.ListIndex = -1 Then
        MsgBox "Color not selected in the combobox", vbCritical
        Exit Sub
    End If

    Index = ColorIndex(MyComboBox.ListIndex + 1)
    c.FixedAssign cdrPANTONECoated, Index 
    ' Now you have your color object and you can apply it to a shape
    ' or use it the way you want
End Sub
If you use the code in a web environment (e.g. in an ASP page) then have the loop go through each color in the palette and generate HTML code for the combo box content with the proper color index as item values and color names as item captions. I hope you can figure this out by yourself.
Reply With Quote
  #5  
Old 13-01-2004, 10:39
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

Im' just stupid today. I finally got it to populate me drop-down. Now the problem is when I type in a number like 185, the list doesn't automatically set that color as active. I may not have worded that right. I have set the attrib MatchEntry to 1- fmMatchEntryComplete, but as I type nothing happens. I thought that maybe as the user typed a number it would automatically find that color in the list and make that the selection.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #6  
Old 13-01-2004, 10:44
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

No, you have to look it up yourself. Process the "Change" event from the combobox control which happens each time the textbox portion of the control is modified (e.g. the user types the name), then if that's a number, you need to look up a similarly named pantone color and select it in the list.

Of alternatively, you might populate the list with pantone numbers only instead of the full color name. To do this, you need to remove any text portion of the color name and leave the number only. Then add it to the combo box.
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
Font list combobox ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 17-02-2005 22:02
Population of Image Box ddonnahoe CorelDRAW/Corel DESIGNER VBA 10 10-02-2004 14:20


All times are GMT -5. The time now is 20:29.


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