Transparent memo: Can't change font color

Hi All,
I have the following component which works fine but I have got a small problem with it.
My problem is with changing the font colour.
When I add this memo into my form: I can change the font type and style but font colour doesn't change no matter what colour I put it is always keeping the default colour which is black.

Any ideas how this can be be done?

Here is the Transparent memo component:
{code}
unit TransparentMemo;

{$R-}

interface

uses
  Windows, Messages, SysUtils, Classes, Vcl.Controls, Vcl.StdCtrls;

const
  TMWM_SpecialInvalidate = WM_USER + 1111;

type
  TTransparentMemo = class(TMemo)

  private
    procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
    procedure SpecialInvalidate(var Message: TMessage);
      message TMWM_SpecialInvalidate;
    procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
    procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
    procedure WMSetText(var Message: TWMSetText); message WM_SETTEXT;
    procedure CNCTLCOLOREDIT(var Message: TWMCTLCOLOREDIT);
      message CN_CTLCOLOREDIT;
    procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

procedure Register;

implementation


{ TTransparentMemo }

procedure TTransparentMemo.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  inherited;
  if Msg.Result = HTTRANSPARENT  then Msg.Result := HTCLIENT;
end;

procedure TTransparentMemo.WMHScroll(var Message: TWMHScroll);
begin
  inherited;
  PostMessage(Handle, TMWM_SpecialInvalidate, 0, 0);
end;

procedure TTransparentMemo.WMVScroll(var Message: TWMVScroll);
begin
  SendMessage(Handle, TMWM_SpecialInvalidate, 0, 0);
  inherited;
  PostMessage(Handle, TMWM_SpecialInvalidate, 0, 0);
end;

procedure TTransparentMemo.CNCTLCOLOREDIT(var Message: TWMCTLCOLOREDIT);
begin
  with Message do
  begin
    SetBkMode(ChildDC, TRANSPARENT);
    Result := GetStockObject(HOLLOW_BRUSH);
  end;
end;

procedure TTransparentMemo.WMSetText(var Message: TWMSetText);
begin
  inherited;
  if not(csDesigning in ComponentState) then
    PostMessage(Handle, TMWM_SpecialInvalidate, 0, 0)
end;

procedure TTransparentMemo.SpecialInvalidate(var Message: TMessage);
var
  r: TRect;
begin
  if Parent <> nil then
  begin
    r := ClientRect;
    r.TopLeft := Parent.ScreenToClient(ClientToScreen(r.TopLeft));
    r.BottomRight := Parent.ScreenToClient(ClientToScreen(r.BottomRight));
    InvalidateRect(Parent.Handle, @r, true);
    RedrawWindow(Handle, nil, 0, RDW_FRAME + RDW_INVALIDATE)
  end;
end;

procedure TTransparentMemo.WMKeyDown(var Message: TWMKeyDown);
begin
  SendMessage(Handle, TMWM_SpecialInvalidate, 0, 0);
  inherited;
  PostMessage(Handle, TMWM_SpecialInvalidate, 0, 0);
end;

procedure TTransparentMemo.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  Message.Result := 1
end;

constructor TTransparentMemo.Create(AOwner: TComponent);
begin
  inherited;
  ControlStyle := [csCaptureMouse, csDesignInteractive, csClickEvents,
    csSetCaption, csOpaque, csDoubleClicks, csReplicatable, csNoStdEvents];
end;

procedure TTransparentMemo.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
  begin
    ExStyle := ExStyle or WS_EX_TRANSPARENT and not WS_EX_WINDOWEDGE and
      not WS_EX_STATICEDGE and not WS_EX_DLGMODALFRAME and not WS_EX_CLIENTEDGE;
  end;
end;

procedure Register;
begin
  RegisterComponents('Custom Components', [TTransparentMemo]);
end;

end.
{code}
0
daniel
2/23/2014 3:26:28 PM
public.delphi.vcl.writing 510 articles. 0 followers. Follow

3 Replies
874 Views

Similar Articles

[PageSpeed] 17

daniel Legrand wrote:

> Hi All,
> I have the following component which works fine but I have got a
> small problem with it.  My problem is with changing the font colour.
> When I add this memo into my form: I can change the font type and
> style but font colour doesn't change no matter what colour I put it
> is always keeping the default colour which is black.
> 

You should set the font color in the CNCTLCOLOREDIT method:


{code}
procedure TTransparentMemo.CNCTLCOLOREDIT(var Message: TWMCTLCOLOREDIT);
begin
  with Message do
  begin
    SetTextColor(ChildDC, Font.Color);
    SetBkMode(ChildDC, TRANSPARENT);
    Result := GetStockObject(HOLLOW_BRUSH);
  end;
end;
{code}
0
Lajos
2/25/2014 6:25:50 PM
> {quote:title=Lajos Juhasz wrote:}{quote}
> daniel Legrand wrote:
> 
> > Hi All,
> > I have the following component which works fine but I have got a
> > small problem with it.  My problem is with changing the font colour.
> > When I add this memo into my form: I can change the font type and
> > style but font colour doesn't change no matter what colour I put it
> > is always keeping the default colour which is black.
> > 
> 
> You should set the font color in the CNCTLCOLOREDIT method:
> 
> 
> {code}
> procedure TTransparentMemo.CNCTLCOLOREDIT(var Message: TWMCTLCOLOREDIT);
> begin
>   with Message do
>   begin
>     SetTextColor(ChildDC, Font.Color);
>     SetBkMode(ChildDC, TRANSPARENT);
>     Result := GetStockObject(HOLLOW_BRUSH);
>   end;
> end;
> {code}

Hi Lajos,
I don't really know how to thank you!
It works like charm, and I hope someone else also who need similar kind of memo will get the benefit of this.
Thank you very much!, i do very much appreciate this :)

best regards
-daniel
0
daniel
2/26/2014 11:13:03 AM
daniel Legrand wrote:

> > {quote:title=Lajos Juhasz wrote:}{quote}
> > daniel Legrand wrote:
> > 
> > > Hi All,
> > > I have the following component which works fine but I have got a
> > > small problem with it.  My problem is with changing the font
> > > colour.  When I add this memo into my form: I can change the font
> > > type and style but font colour doesn't change no matter what
> > > colour I put it is always keeping the default colour which is
> > > black.
> > > 
> > 
> > You should set the font color in the CNCTLCOLOREDIT method:
> > 
> > 
> > {code}
> > procedure TTransparentMemo.CNCTLCOLOREDIT(var Message:
> > TWMCTLCOLOREDIT); begin
> >   with Message do
> >   begin
> >     SetTextColor(ChildDC, Font.Color);
> >     SetBkMode(ChildDC, TRANSPARENT);
> >     Result := GetStockObject(HOLLOW_BRUSH);
> >   end;
> > end;
> > {code}
> 
> Hi Lajos,
> I don't really know how to thank you!
> It works like charm, and I hope someone else also who need similar
> kind of memo will get the benefit of this.  Thank you very much!, i
> do very much appreciate this :)
> 
> best regards
> -daniel

You're welcome. I used this problem to run away from my problems.
Luckily today I was able to solve my backlog.
0
Lajos
2/26/2014 5:21:37 PM
Reply:

Similar Artilces:

I can't get no cache, I can't get no cache. 'Cause I try and I try and I try and, I can't get no, I can't get no cache.
I have fiddled out for days tinkering with the setting in about:config trying to get FireFox 12 to use the disk cache. I have NOT found the trick. This One Trick Pony ain't doing it like it used to up until recently. Pray tell anyone, What information can I share that will point a knowledgeable person to aid me in getting FF to disk.cache? I have also tried restarting FF with add-ons disabled, (There were NOT too many to do this to, so it was quick and easy) Here is my stab at trying to convey the information that MIGHT govern matters Using about:cache Informatio...

Re: I can't get no cache, I can't get no cache. ' Cause I try and I try and I try and, I can't get no, I can't get no cache.
<div>please com e see me about htis<br /> <br /> ------- Original Message f= rom the Global Relay Archive -------<br /> From: Hp &lt;ferd@farkel.net&gt;= <br /> To: "support-firefox@lists.mozilla.org" &lt;support-firefox@lists.mo= zilla.org&gt;<br /> Sent: Sun, 27 May 2012 18:30:18 -0700<br /> Subject: I = can't get no cache, I can't get no cache. 'Cause I try and I try and I try = and, I can't get no, I can't get no cache.<br /> <br /></div> <pre class=3D"gr-maex-body-pre&qu...

2010: Can't register - can't download the software - can't register until I have the software
I have active maintenance on Rad Studio: From: Vicky Rassmisaengthong [mailto:Vicky.Rassmisaengthong@EMBARCADERO.COM] Sent: Wednesday, February 25, 2009 1:58 PM To: rgrossman Cc: amer.supportadmin@codegear.com; Ashley Cosentino Subject: Software Assurance Support for Tech III Inc PO# Credit Card Dear Embarcadero Technologies Support Customer, Welcome! You have been registered as the primary contact on support account number AM####### Herewith we confirm your Embarcadero Technologies support agreement covering: Qty 1 RAD Studio Enterprise Named User licens...

Can't post, can't change skin.
Hi there, I installed .Text and get it up running without any problem, I could get to main page at http://localhost/DottextWeb/default.aspx as well as the admin page http://localhost/DottextWeb/admin/EditPosts.aspx Then, I tried to write a post and change the skin. The admin showed everything worked. But, the main page doesn't show any difference. It's just the same default blue skin with "A .Text Community" on the top, with "latest post" empty. I tried to debug the program, but so far I haven't seen where it loads the skins. Could someone help please. Tha...

can't send email or write, reply or forward...incoming is all blurred & can't read it
Name: Ellen Wood Email: sienna8841at1gotodotcom Product: Thunderbird Summary: can't send email or write, reply or forward...incoming is all blurred & can't read it Comments: Please send me back some info. to help me get back on my thunderbird...I can only receive mail, but can't even see it to read it. Browser Details: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8 ...

Can't change font, font size FIrefox 3.6.8
I have a problem. I can't change fonts in Firefox preferences (Content). Anybody has a similar or same problem? My OS is openSUSE 11.3, KDE 4.4.4. release 8. Any type and size of font I use, nothing happens. It's still same font which I choose for the first time I've started Firefox afer installing openSUSE 11.3. -- Recoba20 ------------------------------------------------------------------------ So go to Menu / Personnel Settings / Application Appearance / GTK Styles and Fonts. Once you select the font for KDE, use the GTK setting to use the same sett...

if Thunderbird can't download picture (little transparent gif or 1pix for example) I can't sent letter.
Name: Igor Email: igordeatmaildotru Product: Thunderbird Summary: if Thunderbird can't download picture (little transparent gif or 1pix for example) I can't sent letter. Comments: I can't send HTML letters if I copy and paste from brouser until Thunderbird download picture from inet. And if Thunderbird can't download picture (little transparent gif or 1pix for example) I can't sent letter. MS OE don't have this problem. Browser Details: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)...

Two things,Why do I keep getting emails that I don't want. can't get rid of them? Why can't I get my email when I am out of town? Or can I?
Name: Ed Leech Email: ELCraftatzoominternetdotnet Product: Thunderbird Summary: Two things,Why do I keep getting emails that I don't want. can't get rid of them? Why can't I get my email when I am out of town? Or can I? Comments: I am getting frusted with all the emails coming in that I do not want, I am using the tools to get thme out but they keep coming. They just use different names or whatever. I have been thinking of just switching to something else but my business intrusts know this email and it is tooo confusing to change. Every time I go out of town on bu...

Why can't change transaction object property 'Autocommit' to 'true'
I create a component in Jaguar CTS 3.5 the component create a datastore, and connect using transaction object, but I have to change the transaction object property 'autocommit' from "false" to "true", but it doesn't work......the property is still "false", can anybody tell me why? thanks a lot! Because you should never touch this. Since EAS is likely starting a transaction it is resetting this. You should look into the documentation on how EAS manages transactions. Dave Wolf Internet Applications Division "michael" ...

Can't base report on stored procedure--'Can't create Datawindow'
I installed IM65 today to give it a try. I made a db config to our local ASE 11.9.2 engine via Sybase' odbc driver that came with 11.9.2. I start a new report, tell it to be tabular and to get data from a SP. It asks which SP and I tell it. The result is an odbc error: Cannot create DataWindow Intersolv SQL ODBC driver: Incorrect syntax near '='. 1 execute dbo.sp_si_addressbest_;0 RETURN_VALUE = :RETURN_VALUE' I can execute the SP fine from SQL Advantage or from Crytal Reports. Thanks. -- Frank Burleigh Indiana University School of Law Bloomi...

Archive Bit won't reset / can't be changed
Hello, We have a Compaq Proliant ML370 running NetWare 6 SP3. We have a problem on the NSS Volume we want to backup, the archive bits won't reset, nore can they be changed manually. This is of course a major problem when backing up data because the amount of data backed up every day is huge. Does anyone know what the problem may be ? May it come from a Compaq PSM ? Thanks PS : We already tried the sms patch tsa5up13.exe, but it wouldn't help How about nw6nss3c? -- Andrew C Taubman Novell Support Connection Volunteer SysOp http://support.novell.com/foru...

I can read from a XML file on my ASP.NET 2.0 page, but I can't write to it
Hello, this is the code I'm using.  I got it from a tutorial website but I can't remember.  Anyway, it reads the XML file just fine, but XMLTextWriter reports the following exception: "Access to the path 'C:\inetpub\wwwroot\wikicde\applicant.xml' is denied."=== Start of Code === <script language="VB" runat="server" ID=Script1>    Sub btnReadXML_OnClick(sender As Object, e As EventArgs)  'Read and display existing file   ReadXML(Server.MapPath("menu.xml"))End SubSub btnWriteXML_OnClick(se...

Can't change default GUI (rather don't know how)
Hey all, So I just switched from KDE to Gnome and after a successful install upon logout I went to the panel that allows one to choose an application (KDE, Gnome, Windowmaker etc). Gnome worked like a dream. "I don't remember installing any other applications," I says to myself "Why would they be listed there? I'll try booting into one of them." At random I chose a new xWindow and hit enter... blackness. So like any linux user I created /etc/sysconfig/desktop with DESKTOP="GNOME" and DISPLAYMANAGER="GNOME" parameters to forc...

Web resources about - Transparent memo: Can't change font color - public.delphi.vcl.writing

Almost Transparent Blue - Wikipedia, the free encyclopedia
Narrated by the main character Ryū, the novel focuses on his small group of young friends in the mid-1970s. Living in a Japanese town with an ...

Should EU Governments Be More Transparent, Flexible When Requesting Facebook User Data?
Facebook received about 8,500 requests for user data from governments of countries in the European Union during the first six months of 2013, ...

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

CutOut Studio - Background Eraser, Cut Out Photo : Chop photo and Erase the background to be transparent ...
Get CutOut Studio - Background Eraser, Cut Out Photo : Chop photo and Erase the background to be transparent on the App Store. See screenshots ...

Transparent Computer Monitors [explore #38]
Follow Me: Facebook - Twitter - Louish·com (Photography Tutorials & More) Two Dell 30" Computer Monitor Screens with transparency Another pic ...

CES 2012: The Transparent, Touch-Reactive Samsung LCD Display - YouTube
We check out Samsung's transparent display, a 46-inch, 9mm-thick TFT LCD display that reacts to your touch.

Father's transparent obituary about daughter Molly Parks and her heroin addiction hits nerve
There were promising signs, her family says, that Molly Parks had begun to reclaim her life.

Expect a budget full of transparent fudging - Business Spectator
There is just as much massaging of the numbers in Joe Hockey’s recent comments as in any of the budgets that Labor claimed were a 'pathway to ...

Labor vows to block less-transparent government tendering and credit card proposals
Tens of millions of dollars in govt contracts would escape public scrutiny under changes sought by Finance Minister Mathias Cormann.

Transparent house - Real Estate - Property and Real Estate - - Perth Now
IT&#8217;s not the type of house where you can do a quick nude rush from the bedroom to the bathroom, in fact it&#8217;s not the kind of house ...

Resources last updated: 12/23/2015 10:00:31 AM