Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB6 and CD9 palette problem

4 views
Skip to first unread message

Randy Nonay

unread,
Jan 18, 2001, 1:41:45 PM1/18/01
to
I'm writing a VB app that creates a document with some default objects on
it. One of the rectangles needs to have a specific (selected at runtime)
color assiged to it for the filluniform.color property.
To get this color, I search the open palettes to see if it exists and then
assign it to the rectangle. This works for the first document I create in a
session. As soon as I try to create a second document, it fails when trying
to access the application.activepalette (or even application.palettes).
Depending on how I do it, I get either a Dr Watson error (I'm using NT4sp6)
from CD9, or I get an error in VB (the palettes collection is empty...)

I can partially get around this problem by having the app and palette as
global variables so that they are obtained only once in a session. However,
if the VB app is exited and then run again (without exiting CD), the same
error occurs.

Thanks for any help...

Randy Nonay
randy...@anti-spam.net-linx.com
(just remove the obvious part...)

-------------------------------------------------------------------

Here is the code for the vb form (just has 2 buttons on the form):

Option Explicit
Option Compare Text

Private oPal As CorelDRAW.Palette
Private oApp As CorelDRAW.Application

Private Sub cmdBuildDoc_Click()
Dim oDoc As CorelDRAW.Document
Dim oPage As CorelDRAW.Page
Dim oShape As CorelDRAW.Shape
Dim oLayer As CorelDRAW.Layer
Dim oColor As CorelDRAW.Color
Dim sText As String

On Error GoTo errorhandler

oApp.Visible = True
Set oDoc = oApp.Create
Set oPage = oDoc.ActivePage
oDoc.Unit = cdrInch
oPage.SizeHeight = 1.5
oPage.SizeWidth = 1

sText = "Just some Text"

Dim nTop As Double
Dim nLeft As Double
Dim nBottom As Double
Dim nRight As Double

nTop = 1.5
nLeft = 0
nBottom = 0
nRight = 1

Set oLayer = oPage.ActiveLayer
'add background
Set oShape = oLayer.CreateRectangle(nLeft, nTop, nRight, nBottom)
oShape.Outline.Type = cdrOutline
oShape.Outline.Width = 1 / 72 '1 point


'get background color (I'll use light yellow "chalk", black outline)
For Each oColor In oPal.Colors

If oColor.Name = "chalk" Then
oShape.Fill.UniformColor = oColor
End If
If oColor.Name = "black" Then
oShape.Outline.Color = oColor
End If

Next
oShape.OrderToFront

Set oShape = oLayer.CreateArtisticText(nLeft, 0.25, sCustomer)

proc_exit:
Set oColor = Nothing
Set oShape = Nothing
Set oLayer = Nothing
Set oPage = Nothing
Set oDoc = Nothing
Exit Sub

errorhandler:
MsgBox Err.Number & " " & Err.Description
Resume proc_exit
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set oApp = CreateObject("CorelDraw.Application.9")
oApp.Visible = True
Set oPal = oApp.Palettes.Open("d:\mypal.cpl")
End Sub

Alex Vakulenko

unread,
Jan 18, 2001, 2:11:57 PM1/18/01
to
Hi Randy,

> I can partially get around this problem by having the app and palette
as
> global variables so that they are obtained only once in a session.
However,
> if the VB app is exited and then run again (without exiting CD), the same
> error occurs.

This is a known CD9 problem. I don't think there's a workaround for it. I'm
not sure if this helps, but the problem has been fixed in CD10... Also, in
Draw 9, ActivePalette always returns the first open palette, not the default
one. This works fine in Draw 10 though...


--
Alex


Randy Nonay

unread,
Jan 18, 2001, 3:15:50 PM1/18/01
to
Hi Alex,
I've figured out a better sort of work around (solves some of the
problems, but not all). I skip using the palette at all and just assign
colors using CMYKAssign. Lets me get the color I want (even if I can't get
the name set...).

Good to hear it is fixed in 10! We need to order one soon :-)

Thanks,
Randy Nonay


"Alex Vakulenko" <al...@vakcer.com> wrote in message news:3a673fc6@cnews...
> Hi Randy,

0 new messages