Board index » delphi » Second request: Re: Setting incoming color of TColorDialog

Second request: Re: Setting incoming color of TColorDialog

I saw your post before and meant to answer it but forgot. Sorry about that.

I don't what goes wrong in your program, it work's fine when I try it.
The color dialog shows exactly the color I expect and the crosshair and
luminosity indicator where I expect it to be shown.

Can you post small test app with source in the .attachment group so I can
try your app?

Oh, and you might want to change your code to this:
  ColorDialog1.Color := Panel1.Color;
  if ColorDialog1.Execute then  // only change color if user clicks OK
    Panel1.Color := ColorDialog1.Color;
--
Finn Tolderlund

"Karl Perry" <kpe...@animalintelligence.com> skrev i en meddelelse
news:3db02ba0$1@newsgroups.borland.com...

Quote
> Would someone please point me towards an NG where I might get a response
to
> this question?

> TIA,

> Karl Perry

> "Karl Perry" <kpe...@animalintelligence.com> wrote in message
> news:3dac8314$1@newsgroups.borland.com...
> > Using D5.01

> > I'm having trouble figuring out what setting the Color property of a
> > TColorDialog does for me.

> > Let's say I have a TPanel whose Color property currently contains the
> value
> > 48595072 (or whatever).  I can see the panel: it's "smoky purple."  I've
> > dropped a TColorDialog component on the screen, and I display the dialog
> on
> > a button click:

> > procedure TForm1.Button1Click(Sender: TObject);
> > begin
> >   ColorDialog1.Color := Panel1.Color;
> >   ColorDialog1.Execute;
> >   Panel1.Color := ColorDialog1.Color;
> > end;

> > I would expect to see somewhere in the ColorDialog, an indicator of my
> > panel's color, since that is the color I set the color dialog to.
> Instead,
> > the highlight is on the lower-right cell of the "basic colors" area, the
> > crosshair in the custom color display is 1/4 the way from the right,
> smashed
> > at the bottom, the luminosity indicator is all the way to the top of the
> > scale (white), and the ColorSolid display is white.

> > Is this intended behavior, or is TColorDialog broke, or did I not do
> > something right yet?

> > TIA,

> > --
> > Karl Perry
> > Please - no e-mail replies unless requested.
> > Learn how to ask effective NG questions here:
> > http://www.tuxedo.org/~esr/faqs/smart-questions.html

 

Re:Second request: Re: Setting incoming color of TColorDialog


Quote
"Finn Tolderlund" <n...@spam.dk> wrote in message

news:3db032ec@newsgroups.borland.com...

Quote
> I saw your post before and meant to answer it but forgot. Sorry about
that.

> I don't what goes wrong in your program, it work's fine when I try it.
> The color dialog shows exactly the color I expect and the crosshair and
> luminosity indicator where I expect it to be shown.

Finn,

I figured out the problem.  In my test app, I typed in Red, Blue, and Green
integers, then converted them to a color integer:

var Red, Grn, Blu, ClrToSet: Integer;
Red := StrToInt(edtRed.Text);
Grn := StrToInt(edtGrn.Text) shl 8;
Blu := StrToInt(edtBlu.Text) shl 16;
ClrToSet := $02000000 or Red or Grn or Blu;
Panel1.Color := ClrToSet;

This set the color for a panel.  However, TColorDialog would not init
correctly when I clicked my 'ColorDialog' button.

I changed the ClrToSet line to:

ClrToSet := $00000000 or Red or Grn or Blu;

and this worked.  It seems I must use the system palette, not the logical
palette of the current device context.

Thanks,

Karl Perry

Other Threads