Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

converting line draw code to annotation causes error
Started by JoeBussell at 06-16-2008 20:16. Topic has 8 replies.

Print Search « Previous Thread Next Thread »
  06-16-2008, 20:16
JoeBussell is not online. Last active: 8/26/2008 11:33:06 PM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 31
converting line draw code to annotation causes error
Reply Quote
Greetings Listers!
   I am using the ocx interface to LEAD on version 14.5.  I would offer code snippets, but the language I am coding in is just plain weird.  What I do have is working code that draws lines and stamps using the drawing code.  I also have been able to get the annotations to work nicely under very careful circumstances.  I need to bridge the gap however.
   I believe that I am up against some type of setup procedure or internal state keeping.  The clue that suggests this to me is that I am able to construct annotation objects nicely once my frame is visible and all the constructors are done.  Before the frame is actually visible, indeed, in my frame constructor, I am setting up the base bitmap and adding the data from my internal record set.  If I iterate over that data and call out myLeadObject.drawLine( x1, y1, x2, y2) I get visible results.  What I want is selectable line annotations though.  When I replace the above call with the associated call to add an annotation I get an error that I have passed a bad parameter.  The trouble is that the bad call is a call to myLeadObject.annCreate( ANNOBJECT_LINE, True, True ).  I double checked that my constant is indeed '8' and there is no clue as to what the bad parameter is.
   My guess is that there is a state setup that I need to make to get the annotation layer up and going.  If I limp over this error and allow the screen to come up and then change over to annotations it seems to work nicely.  I haven't been able to get that to work on the load though, which is killing my progress.
   I did set the annotation user mode to design.

   So to recap, I have tried several annotation types.  All produce the bad parameter error when I call annCreate.  If I just blit the line or a bitmap using the bitmap calls it shows up fine.

Thanks.

   Report 
  06-17-2008, 10:20
Qasem Lubani is not online. Last active: 8/27/2008 3:13:14 PM Qasem Lubani



Top 10 Posts
Joined on 08-13-2006
Posts 1,034
Re: converting line draw code to annotation causes error
Reply Quote

In order to create Ann objects, the Main OCX must have an image (Bitmap property not zero), and a container object (AnnContainer) must be created in it.

Here is a simple Visual Basic code that works from scratch (no previous image or objects created):

 

Dim hObjAnRect As Long

LEAD1.CreateBitmap 800, 600, 24

LEAD1.Fill RGB(255, 62, 191)

hObjAnRect = LEAD1.AnnCreate(ANNOBJECT_LINE, True, True)

LEAD1.AnnDefine hObjAnRect, 60, 70, ANNDEFINE_BEGINSET

LEAD1.AnnDefine hObjAnRect, 180, 180, ANNDEFINE_END

LEAD1.AnnUserMode = ANNUSERMODE_RUN

LEAD1.AnnSetForeColor hObjAnRect, RGB(20, 90, 20), False
Qasem Al-Lubani
LEAD Technical Support
www.leadtools.com
   Report 
  06-17-2008, 14:21
JoeBussell is not online. Last active: 8/26/2008 11:33:06 PM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 31
Re: converting line draw code to annotation causes error
Reply Quote
My vb code works well just like this.

By looking at the guts of the data structure I can see that the AnnAutomation property is 0 as is the AnnContainer.  I do not have explicit code to create the container.  It is the case that when it works I have a valid container, when it does not I do not have such a container. 

I do not know what I am supposed to do to get a container.


   Report 
  06-17-2008, 14:39
JoeBussell is not online. Last active: 8/26/2008 11:33:06 PM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 31
Re: converting line draw code to annotation causes error
Reply Quote
My OLE_HANDLE AnnAutomation is also 0 when it fails.


   Report 
  06-17-2008, 16:46
JoeBussell is not online. Last active: 8/26/2008 11:33:06 PM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 31
Re: converting line draw code to annotation causes error
Reply Quote
On further study of the docs, and more careful debugging, it appears that the container is NULL until the first annotation is added.  When my annotations are working I still get this NULL on the first call to add an annotation.  Red Herring, nothing to see here.

I still have not been able to deduce the differences in the ocx lib state between my successful run and the failed one.  I took the annotation load code out of my window initialization code, forced the lead frame to appear, then called a new function to load up the annotations.  I am still getting the same undescriptive error that I have somehow passed bad parameters. 

I dumped all the state variables for my failed and successful run.  There are only a few differences, though it definately seems uninitialized. 

Failed set:
extAnnAutoDialogFontSize =
extAnnAutomation = 0
extAnnContainer = 0
extAnnUndoDepth =
extAnnUndoEnable =
extAutoScroll = false

Working set:
extAnnAutoDialogFontSize = 8
extAnnAutomation = 16909284
extAnnContainer = 16917076
extAnnUndoDepth = 5
extAnnUndoEnable = true
extAutoScroll = true

   Report 
  06-18-2008, 12:46
Qasem Lubani is not online. Last active: 8/27/2008 3:13:14 PM Qasem Lubani



Top 10 Posts
Joined on 08-13-2006
Posts 1,034
Re: converting line draw code to annotation causes error
Reply Quote
But what about the Bitmap property? Do you load, paste, create or do anything to have a valid bitmap in the control before you try to add annotations?
Qasem Al-Lubani
LEAD Technical Support
www.leadtools.com
   Report 
  06-19-2008, 16:57
JoeBussell is not online. Last active: 8/26/2008 11:33:06 PM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 31
Re: converting line draw code to annotation causes error
Reply Quote
Yes, my bitmap is valid.  I verified that the bitmap container has a rational value, and also used that bitmap to blit out another control image just to be sure.  I am presently limping over this by refreshing after the construction of the visible frame that the lead object lives in.  This is an ugly process however as there is an obvious double load.

The curious part for me is still that the annotation automation object, which ostensibly links the raster with the annotation layer is NULL after the frame is rendered out, but before my first idle.

Thanks for your time on this.

   Report 
  06-22-2008, 6:43
Qasem Lubani is not online. Last active: 8/27/2008 3:13:14 PM Qasem Lubani



Top 10 Posts
Joined on 08-13-2006
Posts 1,034
Re: converting line draw code to annotation causes error
Reply Quote
The main suspect I'm thinking of (but have no sure way to prove it) is that the automation object is not being created with the bitmap. I could research it more if there is a way to reproduce it. Weren't you able to find a way to simulate this behavior in a small VB6 project?
Qasem Al-Lubani
LEAD Technical Support
www.leadtools.com
   Report 
  07-02-2008, 20:42
JoeBussell is not online. Last active: 8/26/2008 11:33:06 PM JoeBussell

Top 50 Posts
Joined on 06-17-2008
Eugene, OR
Posts 31
Re: converting line draw code to annotation causes error
Reply Quote
I have not managed to get this failure to present itself in VB. This is undoubtedly a mis-feature of the language I am tied to for this project.

To deal with other issues related to the need for basic types (as opposed to Variant) led me to wrap this control inside a control of my own which provides me with a simple interface to the annotation properties. This has provided me with the added benefit of eliminating this error. Given the short term nature of this project I will not be digging any further.

One other note for folks who follow this thread later, you need to unlock document support to allow for the use of automatic annotations. This requires a specific licence tied to a key that you obtain from Lead. There are dev keys and production keys that you will have to deal with to develop and distribute applications using automatic annotations.

Thanks for your time. Happy coding :-)
   Report 
Post
LEAD Support Fo... » Developer » Annotations » converting line draw code to annotation causes error

Powered by Community Server, by Telligent Systems