Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

Graphics in dbGrid Title

6 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Graham Falkenberg

ungelesen,
02.04.2000, 04:00:0002.04.00
an
I want to draw a bitmap into one of the title cells of a dbGrid.
The title cell to contain the bitmap is determined at run time.
(It's a 'sort order' indicator)

I can draw bitmaps into the data cells using OnDrawColumnCell, but
haven't been able to draw into the title cells.

The help for TCustomDBGrid.OnDrawColumnCell says:
'The State parameter indicates whether the cell has input focus, whether
the cell is selected, and whether the cell is a fixed (non-data) cell
such as a column header.'

This would be fine, except that OnDrawColumnCell only seems to be
drawing the data cells.

How can I intercept the drawing of the title cells?

Thanks,
Graham

Robert Cerny

ungelesen,
02.04.2000, 04:00:0002.04.00
an
You have to override the DrawCell method and from there call event
DrawFixedCell. You have to add that event too:

inherited DrawCell(ACol, ARow, ARect, AState );
if (gdFixed in AState) and Assigned(fOnDrawFixedCell) then
fOnDrawFixedCell(Self, ACol, ARow, ARect, AState );


--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.
Graham Falkenberg wrote in message <38E6A46D...@senet.com.au>...

Paul Ferrara

ungelesen,
02.04.2000, 04:00:0002.04.00
an
The problem is that the VCL code that draws the title never calls the
OnDrawColumnCell or OnDrawDataCell so those methods never get called when
state is gdFixed. I reported as a bug a few weeks ago but haven't heard
anything on it.

I worked around it but doing my drawing when the grid's first row was
getting drawn. Probably a little inefficient but it's not noticible
visually. The way I determine it's the first row is when Rect.Top is at
it's lowest value (about 17 in my case).

Paul / ColumbuSoft
www.columbusoft.com

Graham Falkenberg <gfalk...@senet.com.au> wrote in message
news:38E6A46D...@senet.com.au...

Paul Ferrara

ungelesen,
03.04.2000, 03:00:0003.04.00
an
This sounds like a much better solution than the one I came up with but I
can't get it to compile. Delphi complains about 'undeclared identifier:
DrawCell'


Paul / ColumbuSoft
www.columbusoft.com


Robert Cerny <robert.q...@neosys.xrs.qwe.si> wrote in message
news:8c8ms7...@neosys.xrs.si...

Robert Cerny

ungelesen,
03.04.2000, 03:00:0003.04.00
an
It's not a bug. You may call it "missing functionality", but not a bug. This
behaviour is documented.
OnDrawColumnCell event made OnDrawDataCell obsolete, but they do the same
thing.

See my other post for solution.

--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Paul Ferrara wrote in message <8c8imp$ja...@bornews.borland.com>...

Graham Falkenberg

ungelesen,
03.04.2000, 03:00:0003.04.00
an
Sounds promising.
Sorry to be a nuisance here but...
Being a novice at such things, I need a little (OK a lot of) help to
incorporate your
suggestion into my program.
So far I'm able to override methods that belong to the main form, but, short
of defining a
custom dbgrid component (seems a bit drastic), I can't see a way of
overriding a method belonging to a dbgrid
control on the form.

Any help with this is greatly appreciated.
Thanks,
Graham


Robert Cerny wrote:

> You have to override the DrawCell method and from there call event
> DrawFixedCell. You have to add that event too:
>
> inherited DrawCell(ACol, ARow, ARect, AState );
> if (gdFixed in AState) and Assigned(fOnDrawFixedCell) then
> fOnDrawFixedCell(Self, ACol, ARow, ARect, AState );
>

> --
> ----------------------
> Regards
> Robert Cerny
> Remove both qwe when replying
> email: robert.q...@neosys.xrs.qwe.si
>
> No questions via email, unless explicitly invited.

> Graham Falkenberg wrote in message <38E6A46D...@senet.com.au>...

Robert Cerny

ungelesen,
03.04.2000, 03:00:0003.04.00
an
DrawCell is protected method of dbgrid. To use it, you create a descendent
and override this method:
procedure DrawCell(ACol, ARow: Longint; ARect: TRect;
AState: TGridDrawState); override;

The rest of code goes into implementation of this method.

--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Paul Ferrara wrote in message <8ca2lr$7f...@bornews.borland.com>...


>This sounds like a much better solution than the one I came up with but I
>can't get it to compile. Delphi complains about 'undeclared identifier:
>DrawCell'
>
>
>Paul / ColumbuSoft
>www.columbusoft.com
>
>
>Robert Cerny <robert.q...@neosys.xrs.qwe.si> wrote in message
>news:8c8ms7...@neosys.xrs.si...

Robert Cerny

ungelesen,
04.04.2000, 03:00:0004.04.00
an
Start a new component: File|New.... click "component"
Select TDBGrid as ancestor and you have it. After that add my code into that
unit (also any other code you want) and compile the package (default
DCLUSRxx). After installing the package just use it as any other component.

TForm is a class like any other, so overriding methods goes in the same
fashion for any class/component/control.

BTW, don't overquote.


--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Graham Falkenberg wrote in message <38E89D12...@senet.com.au>...

dmor...@my-deja.com

ungelesen,
11.04.2000, 03:00:0011.04.00
an
I beg to differ -- it does seem to be a bug. I'm
having the same trouble in BCB4. The
documentation states that the OnDrawColumnCell
and OnDrawDataCell events report the gdFixed
state for title rows, but I can't make it happen
for the life of me. I set breakpoints but State
NEVER contains gdFixed. I've tried BOTH events
in a TDBGrid and a TRxDBGrid, with DefaultDrawing
both true and false, with no luck. Since the
docs clearly states it should work this way but
it doesn't, I'd call it a bug.

But one thing amazes me: I'm finding tons of
sample code for these events where it's checking
the gdFixed state. How are they doing it !!!!
If there's something I can set or hack without
subclassing the control, I'd love to hear it!

David

In article <8caaqb...@neosys.xrs.si>,
"Robert Cerny"


<robert.q...@neosys.xrs.qwe.si> wrote:
> It's not a bug. You may call it "missing
functionality", but not a bug. This
> behaviour is documented.
> OnDrawColumnCell event made OnDrawDataCell
obsolete, but they do the same
> thing.
>
> See my other post for solution.
>

> --
> ----------------------
> Regards
> Robert Cerny
> Remove both qwe when replying
> email: robert.q...@neosys.xrs.qwe.si
>
> No questions via email, unless explicitly
invited.

> Paul Ferrara wrote in message

<8c8imp$ja...@bornews.borland.com>...
> >The problem is that the VCL code that draws
the title never calls the
> >OnDrawColumnCell or OnDrawDataCell so those
methods never get called when
> >state is gdFixed. I reported as a bug a few
weeks ago but haven't heard
> >anything on it.
> >
> >I worked around it but doing my drawing when
the grid's first row was
> >getting drawn. Probably a little inefficient
but it's not noticible
> >visually. The way I determine it's the first
row is when Rect.Top is at
> >it's lowest value (about 17 in my case).
> >
> >Paul / ColumbuSoft
> >www.columbusoft.com
> >
> >
>
>

Sent via Deja.com http://www.deja.com/
Before you buy.

0 neue Nachrichten