Color of a TMemo (Delphi 2009)

This may turn out to be elementary, but I'd welcome some help.

I have two TMemos in my application. Both of them, at various points, get populated with text from TStringLists, get their color changed, and get resized. One of them responds impeccably, but the other one doesn't. The rogue one is OK as far as text goes, and OK for resizing, but it won't change colour. It has two errant behaviours: (1) at start-up time, it shows its design-time colour over most of its area, but has a band of white across its top; (2) at colour-change time, which is only when it has text 
on it, it shows the new colour only on a one-pixel line round the edge, and a wider band across the bottom, while the text-populated area remains white.

I can't think what could cause this. The code is bog-standard:

CORRECTLY BEHAVED TMEMO:
    MemInstruc.Color := CEngineWhite; {Custom color - works fine}
    ...
{The next line calculates how wide a memo should be by examining the width of its proposed text (TStringList):}
    wl1Wd := FontMgr.FtMgr.GetMemoWidth('INST',FTesting,wl1TotHt,wl1LinHt);
    MemInstruc.ClientWidth := wl1Wd;
    MemInstruc.ClientHeight := wl1LinHt * 6;
    ...
    MemInstruc.Lines := FTesting;

ROGUE TMEMO:
{The next line calculates how wide a memo should be by examining the width of its proposed text (TStringList):}
    wl1Wd := FontMgr.FtMgr.GetMemoWidth('DATA',FUserMessage,wl1TotHt,wl1LinHt);
    MemUserMessage.ClientWidth := wl1Wd;
    MemUserMessage.ClientHeight := wl1TotHt;
    MemUserMessage.Left := (MainForm.ClientWidth - MemUserMessage.Width) div 2;
    MemUserMessage.Top := (MainForm.ClientHeight - MemUserMessage.Height) div 3;}
    MemUserMessage.Color := CEngineYellow; {Custom color - works fine elsewhere}
    MemUserMessage.Lines.Clear;
    MemUserMessage.Lines := FUserMessage;
    MemUserMessage.Visible := True;

I find this totally baffling. Where should I begin to look?

Derek Rogers
www.derek.co.uk
0
Derek
8/16/2009 11:02:17 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

5 Replies
695 Views

Similar Articles

[PageSpeed] 13

Derek Rogers wrote:

> This may turn out to be elementary, but I'd welcome some help.
> 
> I have two TMemos in my application. Both of them, at various points,
> get populated with text from TStringLists, get their color changed,
> and get resized. One of them responds impeccably, but the other one
> doesn't. The rogue one is OK as far as text goes, and OK for
> resizing, but it won't change colour. It has two errant behaviours:
> (1) at start-up time, it shows its design-time colour over most of
> its area, but has a band of white across its top; (2) at
> colour-change time, which is only when it has text on it, it shows
> the new colour only on a one-pixel line round the edge, and a wider
> band across the bottom, while the text-populated area remains white.
> 
> I can't think what could cause this. The code is bog-standard:
> 
> CORRECTLY BEHAVED TMEMO:
>     MemInstruc.Color := CEngineWhite; {Custom color - works fine}
>     ...
> {The next line calculates how wide a memo should be by examining the
> width of its proposed text (TStringList):}     wl1Wd :=
> FontMgr.FtMgr.GetMemoWidth('INST',FTesting,wl1TotHt,wl1LinHt);
> MemInstruc.ClientWidth := wl1Wd;     MemInstruc.ClientHeight :=
> wl1LinHt * 6;     ...
>     MemInstruc.Lines := FTesting;
> 
> ROGUE TMEMO:
> {The next line calculates how wide a memo should be by examining the
> width of its proposed text (TStringList):}     wl1Wd :=
> FontMgr.FtMgr.GetMemoWidth('DATA',FUserMessage,wl1TotHt,wl1LinHt);
> MemUserMessage.ClientWidth := wl1Wd;     MemUserMessage.ClientHeight
> := wl1TotHt;     MemUserMessage.Left := (MainForm.ClientWidth -
> MemUserMessage.Width) div 2;     MemUserMessage.Top :=
> (MainForm.ClientHeight - MemUserMessage.Height) div 3;}
> MemUserMessage.Color := CEngineYellow; {Custom color - works fine
> elsewhere}     MemUserMessage.Lines.Clear;     MemUserMessage.Lines
> := FUserMessage;     MemUserMessage.Visible := True;
> 
> I find this totally baffling. Where should I begin to look?

The main difference seems to be that you do most of the changes on the
second memo when it is not visible yet.

Try to add this:

   InvalidateRect(MemUserMessage.Handle, nil, true);

From some other problems posted in recent months (with other controls
like listboxes) I have to conclude that there is a problem with the
painting in the VCL: it does not request a background fill when
invalidating a controls client area in some situations where that is
required, e.g. when the repaint is due to a color change.

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
8/17/2009 5:59:09 PM
> {quote:title=Peter Below wrote:}{quote}
> Try to add this:
> 
>    InvalidateRect(MemUserMessage.Handle, nil, true);
> 
> From some other problems posted in recent months (with other controls
> like listboxes) I have to conclude that there is a problem with the
> painting in the VCL: it does not request a background fill when
> invalidating a controls client area in some situations where that is
> required, e.g. when the repaint is due to a color change.
> 
> -- 
> Peter Below (TeamB)  
> Don't be a vampire (http://slash7.com/pages/vampires), 
> use the newsgroup archives :
> http://codenewsfast.com
> http://groups.google.com

Makes no difference, I'm afraid. Even if it's visible the whole time, the colour (whether from design time or as changed by program) never gets into the text area. It has to be white or nothing.

Derek Rogers
www.derek.co.uk
0
Derek
8/17/2009 9:20:49 PM
Derek Rogers wrote:

> > Try to add this:
> > 
> >    InvalidateRect(MemUserMessage.Handle, nil, true);
> > 
> Makes no difference, I'm afraid. Even if it's visible the whole time,
> the colour (whether from design time or as changed by program) never
> gets into the text area. It has to be white or nothing.
> 

I have to confess that I am baffled as well. The worst I have yet see
with TMemo in D2009 is a thin "border" of the old color remaining
around the client area after a color change in code. It repaints
correctly if the whole window needs to refresh, e.g. after a
minimize/restore cycle or when another window covering it is closed.
Does that fix your problem, too?

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
8/18/2009 6:16:01 PM
Peter Below wrote:
> Derek Rogers wrote:
> 
>>> Try to add this:
>>>
>>>    InvalidateRect(MemUserMessage.Handle, nil, true);
>>>
>> Makes no difference, I'm afraid. Even if it's visible the whole time,
>> the colour (whether from design time or as changed by program) never
>> gets into the text area. It has to be white or nothing.
>>
> 
> I have to confess that I am baffled as well. The worst I have yet see
> with TMemo in D2009 is a thin "border" of the old color remaining
> around the client area after a color change in code. 

Is the "border" on the right and bottom edges or all the way around?

- Brian
0
Brian
8/18/2009 6:39:12 PM
Brian Cook wrote:

> Peter Below wrote:
> > Derek Rogers wrote:
> > 
> >>> Try to add this:
> > > > 
> >>>    InvalidateRect(MemUserMessage.Handle, nil, true);
> > > > 
> >> Makes no difference, I'm afraid. Even if it's visible the whole
> time, >> the colour (whether from design time or as changed by
> program) never >> gets into the text area. It has to be white or
> nothing.
> > > 
> > 
> > I have to confess that I am baffled as well. The worst I have yet
> > see with TMemo in D2009 is a thin "border" of the old color
> > remaining around the client area after a color change in code. 
> 
> Is the "border" on the right and bottom edges or all the way around?
> 

All the way around. 

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
8/18/2009 6:50:14 PM
Reply:

Similar Artilces:

Delphi 4 to Delphi 2009
Hello, Thanks to all who answered my previous question. That was a great help. And atlast our client agreed to upgrade our delphi version from 4 to Delphi 2009. *Sigh*. But before that, I need to give the estimation and cost regarding the migration to delphi 2009. Can anyone tell me is there any tool to migrate from delphi 4 to delphi 2009 or just I need to compile our Delphi 4 application in Delphi 2009. I have read from the delphi 2009 feature matrix that Delphi 1 through Delphi 2007 import is possible in delphi 2009. But i am not that sure considering the size of our application. ...

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

Upgrading to Delphi 2009 from Delphi 5
I've decided it's time to upgrade to Delphi 2009 Professional from my current Delphi 5 Professional which (according to the FAQ) makes me eligible for the upgrade pricing. However, I'd just like to clarify how this process works. My concern is that my Delphi 5 is not registered on the CodeGear site and this doesn't seem to be possible as far as I can tell. When installing the trial I noticed that Delphi 2009 registers itself with your CodeGear account so does this mean that the previous version must be registered there to verify you own a Professional edition? I plan to o...

Delphi 2007 to Delphi 2009 Conversion
CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; How to convert to Delphi 2009? Bill Bill Miller wrote: > CharArrayPtr = ^CharArray; > CharArray = array[0..MaxInt-1] of Char; > > How to convert to Delphi 2009? > > Bill it depends heavelly on how it is used fearther down in your project and what you want to convert it to. I you want to simple convert the declarations ignoring UNicode altogether then the only think you have to change is the CharArray declaratin from a Char to an AnsiChar eg CharArrayPtr = ^CharArray; CharArray =...

is there a Delphi 2007
Would be nice to have a bundle of the latest Delphi packages. Gilbert Padilla wrote: > Would be nice to have a bundle of the latest Delphi packages. > I expect Delphi 2007 will only be on sale until the full RAD Studio 2009 edition is published, including Delphi 2009.net. W ...

Delphi 2009 alongside Delphi 2007
Hi all, I am about to install Delphi 2009 on the same development system as Delphi 2007, before I embark is there anything I should be aware of so as to not break my Delphi 2007 installation and projects ? Thanks JT John Taylor wrote: > Hi all, > > I am about to install Delphi 2009 on the same development system > as Delphi 2007, before I embark is there anything I should be aware > of so as to not break my Delphi 2007 installation and projects ? As long as you install into a separate folder there is no problem with the two versions getting into each other...

Delphi 7 to Delphi 2009 conversion
Hello group, What do I need to do to comile the following code in D2009. Compiler error after the Else E2010: Incompatible Types 'AnsiChar' and 'Char' if isUnicode then SearchHandle := FindFirstFilew( PWideChar( fn ), FindDataW ) else SearchHandle := FindFirstFile( PAnsiChar( Ansistring( fn ) ), FindDataA ); <<<<<compiler error in the above line >>>>>>>>>>> Regards, Bryan > What do I need to do to comile the following code in D2009. > Compiler error after the Else > E2010: Incompati...

Can delphi 2009 and delphi 7 be on the same computer?
Can I install and run delphi 2009 and delphi 7 separately on the same computer or will they interfer with each other? I have delpi 7 already so do I need to choose a new folder (not c:\Borland) when installing 2009? Lorne Anderson wrote: > Can I install and run delphi 2009 and delphi 7 separately on the same > computer or will they interfer with each other? > > I have delpi 7 already so do I need to choose a new folder (not c:\Borland) > when installing 2009? It works fine. You usually want to install the older version first. As for folders, the root folde...

Code Porting
Hi people, Basically, I am moving an app from Delphi 5 to Delphi 2009 which is all great (yeah right!) and I am having a couple of issues with some thirdparty components that we have the source code for. Being that I wanted to make the task as easy as possible, I was able to download the component in Delphi 2007 format. I have now managed to port that to 2009 so it compiles only with warnings and no errors. So all is good at this moment. Now I am trying to install the component into the IDE by using the install menu option from the project manager. This is where I run into errors. ...

Why does this work fine in Delphi 2009, but not in Delphi 2010
I've been racking my head trying to figure this out and can't understand what is wrong, TFileStream.ReadComponentRes fails when I try to read a component containing a record, it works fine in Delphi 2009 and Delphi 2007, but fails with Delphi 2010 Here is the unit source and DFM *+//UnitSource+* unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TThresholdMode = (tm0,tm1,tm2,tm3,tm4,tm5); TThreshold = Record Mode:TThresholdMode; Filter,Start,Stop:Integer; end; ...

Question about Delphi 2009 vs Delphi 7
Hi, I was wondering if any of you can point me to a URLs that show the most important improvements between these versions of Delphi. The objective is convincing the powers-that-pay-the-bills that moving to D2009 (that we'd have to purchase) is a better idea than moving to D7 (for which we have licenses). Fire at will! -- Saluti, Alessandro Federici ------------------------------- "I have been through some terrible things in my life, some of which actually happened." (Mark Twain) Alessandro Federici wrote: > Hi, > I was wondering if any of yo...

ShareMem Delphi 6 --> Delphi 2009
I have just upgraded from Delphi 6 to Delphi 2009. My software uses about 20 files, plus literally dozens more plug-ins. Every project has ShareMem as its first unit and borlndmm.dll is distributed with the software. I am aware that the Borland Memory Manager was replaced to use FastMM quite some time ago. Will I have to rebuild every EXE and DLL in DElphi 2009 that uses ShareMem, or will supplying the new borlndmm.dll be enough? i.e. I would like to just update the main application EXEs and DLLs, but leave the plug-ins alone. Will this work? Thanks, Jason. -- Jason Sweby ...

Convert Delphi 7 to Delphi 2009 [Edit]
Hi! Please, I have a code done in Delphi 7... Now I want to convert Delphi 7 to Delphi 2009 but I'm having problems when compile the code. Error message: +[DCC Fatal Error] Far.dpr(9): F2063 Could not compile used unit 'System.pas'+ Please can somebody help me? Source Download (349KB): http://rapidshare.com/files/256191328/FileManager.rar.html Mirror Source Download: http://www.megaupload.com/?d=12GYLPT0 Password: delphi Thank u so much! (sorry for my bad english, it is not my native language) Edited by: loquax loquax on Jul 15, 2009 12:24 PM Sorry, bu...

ShareMem Delphi 6 --> Delphi 2009
I have just upgraded from Delphi 6 to Delphi 2009. My software uses about 20 files, plus literally dozens more plug-ins. Every project has ShareMem as its first unit and borlndmm.dll is distributed with the software. I am aware that the Borland Memory Manager was replaced to use FastMM quite some time ago. Will I have to rebuild every EXE and DLL in DElphi 2009 that uses ShareMem, or will supplying the new borlndmm.dll be enough? i.e. I would like to just update the main application EXEs and DLLs, but leave the plug-ins alone. Will this work? Thanks, Jason. -- Jason Sweby ...

Web resources about - Color of a TMemo (Delphi 2009) - embarcadero.delphi.general

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

Domestic firms eye Delphi
BizChina offers latest business and market information of China, online updates of 17 industries, investment guides, business events and industry ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

Official: Verizon's Vehicle Diagnostics by Delphi now on sale for $250
Filed under: Technology Partnering with Verizon Wireless, Delphi Automotive has released its Vehicle Diagnostics by Delphi product that allows ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 1/7/2016 3:40:05 PM