Author Topic: Lineweight ComboBox for AutoCAD 2010  (Read 2087 times)

0 Members and 1 Guest are viewing this topic.

mcarson

  • Guest
Lineweight ComboBox for AutoCAD 2010
« on: September 14, 2009, 05:29:33 AM »
Similar to my recent post re: Color ComboBox, I have been attempting to recreate the lineweight combo box.

Browsing through the AutoCAD 2010 API I came across a method that seems to return a pointer containing a
bitmap that represents a lineweight as shown in the AutoCAD combo box:

Code: [Select]
    public System.Drawing.Bitmap LineweightBitmap(AcadDb.LineWeight Lineweight)
    {
        IntPtr ptr = Autodesk.AutoCAD.Internal.Utils.DrawLineWeightSquare(Lineweight, 0, 0, 60, 22);
        Bitmap bit = Image.FromHbitmap(ptr);
        return bit;
    }

Again, similar to the colour combobox, I am inheriting from the standard combobox and performing custom
painting on the DrawItem event.

If I place a call to the LineweightBitmap method on every call to the DrawItem event, I receive the standard
Unhandled Access Violation with the usual crash.

I am considering loading all the required lineweight bitmaps into an ImageList at runtime to prevent all the calls
to the AutoCAD method, any idea how to do this?