Board index » delphi » Windows Text Edit Controls

Windows Text Edit Controls

Hello ppl's

    I trying to work out how in windows using a multi-line edit control
to change the forground and background colours, similar to what you can
in a program like, mIRC...
Instead of the normal, plain, boring.. black & white... someway i can
change it freely...

Thanx
--
MZ

 

Re:Windows Text Edit Controls


Quote
Jared Withington wrote:
> Hello ppl's
>     I trying to work out how in windows using a multi-line edit control
> to change the forground and background colours, similar to what you can
> in a program like, mIRC...
> Instead of the normal, plain, boring.. black & white... someway i can
> change it freely...

Hi Jared!

Try this:

TAnyWindow = Object(TDialog)
   {...}
   Procedure WMCtlcolor(Var msg: TMessage); Virtual wm_First + WM_ctlcolor;
end;

Procedure TAnyWindow.WMCtlColor(var Msg: TMessage);
   var hdcChild  : HDC;
       hwndChild : HWnd;
       nCtlType  : Integer;
       aMode     : Integer;
       aBKColor  ,
       aTXColor  : TColorRef;
       aBrush    : THandle;
   begin
      DefWndProc(Msg);
      hdcChild := HDC(Msg.wParam);
      hwndChild:= HWnd(Msg.lParamLo);
      nCtlType := Integer(Msg.lParamHi);
      case nCtlType of

         CTLCOLOR_EDIT: begin {Changing edits to LtGray with red Text...}
            aMode   := OPAQUE;
            aBKColor:= $00FFFFFF;
            aTXColor:= $000000FF;
            aBrush  := LTGRAY_BRUSH;
         end;

         {ids for all DlgItems available}

         else begin {Default Black/White}
            aMode   := TRANSPARENT;
            aBKColor:= $00FFFFFF;
            aTXColor:= $00000000;
            aBrush  := WHITE_BRUSH;
         end;
      end;
      SetBkMode   (hdcChild,aMode);
      SetBkColor  (hdcChild,aBKColor);
      SetTextColor(hdcChild,aTXColor);
      Msg.Result:=GetStockObject(aBrush); {may be using 'CreateSolidBrush'}
   end;

bye, Martin

--         base your joy not upon the deeds of others        --
--           for what is given can be taken away...          --
-- Martin Kruk ----- Doubl...@gmx.net ----- ICQ-UIN: 8051275 --
-- Coder's Guild member: http://www.paracatz.com/codersguild --

Other Threads