ColorDialog

ColorDialog

Anonymous
Not applicable
1,426 Views
10 Replies
Message 1 of 11

ColorDialog

Anonymous
Not applicable

when i use Autodesk.AutoCAD.Windows.ColorDialog from a modeless form, the colordialog doesn't get focus, so you have to click twice to pick the color (the first click only sets focus to the dialog)

 

when i put the same code in a command and run it from commandline, it gets focus

 

        Dim cd As New Autodesk.AutoCAD.Windows.ColorDialog
        If cd.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub

 

0 Likes
Accepted solutions (1)
1,427 Views
10 Replies
Replies (10)
Message 2 of 11

augusto.goncalves
Alumni
Alumni

Hi, which version of AutoCAD are you using? I cannot see this behavior on 2012/Win7

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 3 of 11

Anonymous
Not applicable

Try this

 

        myPalette.KeepFocus = False

        Dim cd As New Autodesk.AutoCAD.Windows.ColorDialog

        Dim dr as DialogResult = cd.ShowDialog

        MyPalette.KeepFocus = True
        If dr <> Windows.Forms.DialogResult.OK Then Exit Sub

 

Hav'nt done any palette programming lately, but last time I did, you needed to manage the focus yourself for the palette. Should be plenty of examples, just search on the 'KeepFocus'.'

 

 

HomeBoy Out

0 Likes
Message 4 of 11

Anonymous
Not applicable

I

 have the exact same problem.  I am running Autocad 2011

0 Likes
Message 5 of 11

Anonymous
Not applicable

to augusto: I'm using AutoCAD 2011, i will try it in 2012, but i don't have it installed here

 

to HomeBoy: I'm not opening the ColorDialog from palette, but from the Windows.Form

0 Likes
Message 6 of 11

augusto.goncalves
Alumni
Alumni

hi,

 

I could not repro this here...I tried with modeless form using Application.ShowModelessDialog and Form.ShowDialog, but the ColorDialog is always working fine....if you manage to have a sample uploaded, I can take a look.

 

HomeBoy: I believe the issue you´re talking is related to combo boxes on palettes, not the case here. Or do you have something different?

 

Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 7 of 11

Anonymous
Not applicable

Augusto, are you trying to reproduce it on AutoCAD 2011?

 

i will extract the code from my project, so i can upload it

0 Likes
Message 8 of 11

Anonymous
Not applicable

i found out, that it works fine, when i open the ColorDialog d\from button.click event, but wrong, when i open it from imagebox.click event

 

you can test it from the attached project

0 Likes
Message 9 of 11

augusto.goncalves
Alumni
Alumni
Accepted solution

I can see it now...

 

Apparently there is a limitation with PictureBox: it cannot receive focus. It seems that this is causing the problem we see here, so I would suggest you use a flat button with no border, which is visually equal a picturebox, but can receive focus and work in this case.

 

How that sounds?

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 10 of 11

Anonymous
Not applicable

thank you, it works perfect

0 Likes
Message 11 of 11

Anonymous
Not applicable

****,

That won't help me, as I have 450 picture boxes calling a color pallete.

Thanks as well any way for the help!

0 Likes