[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Problem setting StringGrid Color

Posted on 1997-04-08
7
Medium Priority
?
381 Views
Last Modified: 2012-05-04
I'm having a prboblem setting StringGrid's color to anything but one of the solid system colors, clAqua thru clYellow.  My  video is set for 256 colors and works fine.
There is no problem setting all 256 colors in other components including DrawGrid and DBGrid. What's different about the StringGrid component? Does it use a different pallette or limit the system  pallette?

I'm attempting to use the color dialog to set the color. It should work since its color property is of type TColor which is the same as stringgrid's color property. (When I set my video driver to 16-bit color, stringgrid color work ok).

Thanks,
Jerry G.
0
Comment
Question by:jgrant101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:javiertb
ID: 1335247
How do you select your DBGrid among 256 colors?
0
 

Author Comment

by:jgrant101
ID: 1335248
Edited text of question
0
 

Author Comment

by:jgrant101
ID: 1335249
javiertb,
You asked how I change the DBGrid's color to one of 256. (Admittedly, I did not check all 256 colors).I use a color dialog control and select a color which I then use to set the DBGrid's color property.  It seems that the stringgrid control either uses a different pallette or limits the system pallette.

Thanks for your help
Jerry G.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
javiertb earned 300 total points
ID: 1335250
If you want to get 256 colors to chose from for your component, you'll have to deal with the API functions related to palette creation, manipulation and so on.
0
 

Author Comment

by:jgrant101
ID: 1335251
"If you want to get 256 colors to chose from for your component, you'll have to deal with the API functions related to palette creation, manipulation and so on."

I don't agree with this. Why can I set the color of a DBGrid or a DrawGrid to pastel yellow (color := $A8FFFF) for example, but not the StringGrid?  What's different about the stringgrid? I looked at the VCL souce code but could not find the difference.

Thanks for your help,
Jerry G.
0
 
LVL 2

Expert Comment

by:javiertb
ID: 1335252
Here you have the answer, hope this help:

TCustomGrid defines the FixedColor property and assumes that any code draws the fixed areas will use this propery. TDrawGrid and TStringGrid does this. However, TDBGrid (TCustomDBGrid, actually) defines another property called TitleColor and uses this when drawing. Unfortunately this property is defined as protected making it unavailable for component users at both design and run-time.

The solution is to derive your own component and use this instead of TDBGrid.The following unit does this:


unit Dbgridfx;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Grids, DBGrids;

type
  TDBGridFix = class(TDBGrid)
  private
    { Private declarations }
    procedure SetFixedFixedColor(Value: TColor);
    function  GetFixedFixedColor: TColor;
  published
    { Published declarations }
    property FixedColor: TColor read GetFixedFixedColor write SetFixedFixedColor default clBtnFace;
  end;

procedure Register;

implementation

procedure TDBGridFix.SetFixedFixedColor(Value: TColor);
begin
  inherited TitleColor := Value;
  inherited FixedColor := Value; { Not really needed, just to be on the safe side }
end;

function TDBGridFix.GetFixedFixedColor: TColor;
begin
  Result := inherited TitleColor;
end;

procedure Register;
begin
  RegisterComponents('Data Access', [TDBGridFix]);
end;

end.

Regards,
Javi
0
 

Author Comment

by:jgrant101
ID: 1335253
You are missing my point. I'm having trouble setting StringGrid's colors. DBGrid and DrawGrid colors can be set as expected.  Your response was to create a new component based on TDBGrid.

Moreover, the problem exists with any row or cell, not just the fixed areas.

Any other suggestions?


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question