Color Dialogbox

Discussion in 'AutoCAD' started by flash, Nov 8, 2004.

  1. flash

    flash Guest

    Anyone know how to invoke the dialogbox. I need to allow the user to select any color that Acad has but can't find a way to access the thing.

    TIA,
    Mike
     
    flash, Nov 8, 2004
    #1
  2. flash

    Jürg Menzi Guest

    Hi Mike

    Code:
    Private Declare Function acedSetColorDialog Lib "acad.exe" (Color As Long, _
    ByVal bAllowMetaColor As Boolean, ByVal nCurLayerColor As Long) As Boolean
    '----------------------------------------------------------------------------
    Public Function MeGetAcadColor(DefCol As Long, MtaCol As Boolean, _
    LayCol As Long) As Long
    
    MeGetAcadColor = -1
    
    On Error Resume Next
    
    If acedSetColorDialog(DefCol, MtaCol, LayCol) Then
    MeGetAcadColor = DefCol
    End If
    
    End Function
    
    Cheers
     
    Jürg Menzi, Nov 8, 2004
    #2
  3. flash

    flash Guest

    Kewl!

    Thanks Juerg!

    Mike
     
    flash, Nov 8, 2004
    #3
  4. flash

    Jürg Menzi Guest

    Hi Mike

    Welcome...¦-)

    Cheers
     
    Jürg Menzi, Nov 8, 2004
    #4
  5. flash

    flash Guest

    Juerg, took a look at your website, very nice work! I notice you a lot of code for lsp but nothing for vba. Just wondering why.

    Mike
     
    flash, Nov 8, 2004
    #5
  6. flash

    John Holmes Guest

    I've been using this, one question though. Anyway to get the true color tab?

    Thanks

    John Holmes
     
    John Holmes, Nov 9, 2004
    #6
  7. flash

    Jürg Menzi Guest

    Hi Mike
    I'm writing my programs mostly in (Visual)Lisp. I use the VBA interface only
    as replacement for DCL, WinAPI access or for time critical functions.
    That's why I don't publish VBA code on my website.

    Cheers
     
    Jürg Menzi, Nov 9, 2004
    #7
  8. flash

    Jürg Menzi Guest

    Hi John
    There is another API:
    Code:
    acedSetColorDialogTrueColor(
    AcCmColor& color,
    Adesk::Boolean bAllowMetaColor,
    const AcCmColor& curLayerColor,
    AcCm::DialogTabs tabs = (AcCm::DialogTabs)(AcCm::kACITab | AcCm::kTrueColorTab
    | AcCm::kColorBookTab));
    
    Because I've not a clue how to translate the API from C++ to VB, I can't
    help...>:-(
    If somebody has the knowledge how to implement this API in VBA ,any help
    would be appreciated.

    Cheers
     
    Jürg Menzi, Nov 9, 2004
    #8
  9. flash

    AKS Guest

    Thanks, this will be very useful. How do the second and third arguments come into play? bAllowMetaColor (MtaCol)and nCurLayerColor (LayCol) seem to have no effect and are not returned from the function any different than what they were as they went in.
     
    AKS, Nov 9, 2004
    #9
  10. flash

    Jürg Menzi Guest

    Hi AKS

    - Color:
    colorIndex to use as the default color. Returns with the colorIndex of the
    color chosed in the dialog
    - bAllowMetaColor:
    Boolean indicating if BYLAYER and BYBLOCK colors are allowed
    - nCurLayerColor:
    color of current layer

    Cheers
     
    Jürg Menzi, Nov 9, 2004
    #10
  11. flash

    AKS Guest

    Thanks, that is what I thought, but I do not see that when
    trying to test it this way. The allow meta and current layer
    color seems to do nothing nor are they changed by the
    function.

    Private Declare ....etc.
    End Function

    Sub ctest()
    Dim z As Long
    Dim dc As Long
    Dim mtac As Boolean
    Dim lc As Long
    dc = 15
    mtac = False
    'mtac = True
    'lc = 23
    z = MeGetAcadColor(dc, mtac, lc)
    MsgBox (CStr(z) & " " & CStr(dc) & " " & CStr(mtac) & " " _
    & CStr(lc))
    End Sub
     
    AKS, Nov 10, 2004
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.