 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alex Ivlev Guest
|
Posted: Fri Nov 28, 2003 10:48 pm Post subject: OLE container background color |
|
|
TOleContainer ignores its Color property. If I load a Word or Excel document
using CreateObjectFromFile, the contents are displayed on a gray background.
Is there a way to change the background color?
|
|
| Back to top |
|
 |
Alex Ivlev Guest
|
Posted: Sun Nov 30, 2003 9:45 pm Post subject: Re: OLE container background color |
|
|
"Alex Ivlev" <aivlev (AT) cox (DOT) net> wrote
| Quote: | TOleContainer ignores its Color property. If I load a Word or Excel
document
using CreateObjectFromFile, the contents are displayed on a gray
background.
Is there a way to change the background color?
|
I found the answer on my own. There is a bug in Delphi, I think somewhere in
Graphics.pas (I didn't want to spent time tracking it down to the line). It
affects the behaviour of TOleContainer. If you look into the code of
TOleContainer.Paint (in olectnrs.pas), there it is:
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := Color;
DrawEdge(Canvas.Handle, CR, EDGE_SUNKEN, Flags or BF_MIDDLE);
The BF_MIDDLE flag is supposed to cause the interior of the rectangle to be
filled using the brush that was just set. However, by some reason (bug in
Graphics.pas) that new brush is not set, and the default brush is used to
fill the rectangle - that's where the gray color comes from. The subsequent
rendering of the contents of the OLE object is transparent, so it's not an
OLE problem at all. The solution is simple: just remove the BF_MIDDLE flag:
DrawEdge(Canvas.Handle, CR, EDGE_SUNKEN, Flags);
Not filling the interior of the rectangle in this particular place doesn't
seem to cause any problems. The whole container is Invalidate'd anyway, and
its background is painted elsewhere.
I'm reporting this bug via QualityControl.
|
|
| Back to top |
|
 |
Alex Ivlev Guest
|
Posted: Sun Nov 30, 2003 10:07 pm Post subject: Re: OLE container background color |
|
|
| Quote: | The BF_MIDDLE flag is supposed to cause the interior of the rectangle to
be
filled using the brush that was just set. However, by some reason (bug in
Graphics.pas) that new brush is not set, and the default brush is used to
fill the rectangle - that's where the gray color comes from.
|
Then again, maybe BF_MIDDLE was always supposed to fill the rectangle using
the default system color and not the brush associated with the canvas. MS
documentation simply says that this flag causes the interior to be filled.
In any event, removing the BF_MIDDLE flag makes the container use its Color
property.
|
|
| Back to top |
|
 |
Alton Newman Guest
|
Posted: Mon Dec 15, 2003 6:55 pm Post subject: Re: OLE container background color |
|
|
So what was your solution to the gray background color?
----------------------------------
Alton Newman
[email]anewman (AT) texaspepper (DOT) com[/email]
"Alex Ivlev" <aivlev (AT) cox (DOT) net> wrote
| Quote: | The BF_MIDDLE flag is supposed to cause the interior of the rectangle to
be
filled using the brush that was just set. However, by some reason (bug
in
Graphics.pas) that new brush is not set, and the default brush is used
to
fill the rectangle - that's where the gray color comes from.
Then again, maybe BF_MIDDLE was always supposed to fill the rectangle
using
the default system color and not the brush associated with the canvas. MS
documentation simply says that this flag causes the interior to be filled.
In any event, removing the BF_MIDDLE flag makes the container use its
Color
property.
|
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.542 / Virus Database: 336 - Release Date: 11/18/2003
|
|
| Back to top |
|
 |
Alex Ivlev Guest
|
Posted: Wed Jan 07, 2004 4:00 pm Post subject: Re: OLE container background color |
|
|
My solution was what I posted below: remove the BF_MIDDLE flag. Or, to be
precise, in OleCtnrs.pas, find the following line:
DrawEdge(Canvas.Handle, CR, EDGE_SUNKEN, Flags or BF_MIDDLE);
and replace it with
DrawEdge(Canvas.Handle, CR, EDGE_SUNKEN, Flags);
After that the background color works.
"Alton Newman" <anewman (AT) texaspepper (DOT) com> wrote
| Quote: | So what was your solution to the gray background color?
----------------------------------
Alton Newman
[email]anewman (AT) texaspepper (DOT) com[/email]
"Alex Ivlev" <aivlev (AT) cox (DOT) net> wrote in message
news:3fca6a08 (AT) newsgroups (DOT) borland.com...
The BF_MIDDLE flag is supposed to cause the interior of the rectangle
to
be
filled using the brush that was just set. However, by some reason (bug
in
Graphics.pas) that new brush is not set, and the default brush is used
to
fill the rectangle - that's where the gray color comes from.
Then again, maybe BF_MIDDLE was always supposed to fill the rectangle
using
the default system color and not the brush associated with the canvas.
MS
documentation simply says that this flag causes the interior to be
filled.
In any event, removing the BF_MIDDLE flag makes the container use its
Color
property.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.542 / Virus Database: 336 - Release Date: 11/18/2003
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|