Delphi Gebruikersgroep

 

Home    Up

3D tekst middels TextOut

Hallo, 
ik liep tegen een stukje code aan om '3D' tekst te plaatsen op het scherm. Het idee lijkt simpel genoeg, echter helaas
wordt de text (middels textout op het canvas geplaatst) voorzien van een rechthoek met een witte achtergrond. 
Kennelijk heb ik iets over het hoofd gezien. Wie weet raad ??? 
Hieronder de betreffende code : 


Procedure TextOut3Dim(Canvas:TCanvas;x,y:integer;Text:String;Extrude:Boolean); 
var 
OrigColor:TColor; 
begin 
with Canvas do begin 
OrigColor := Canvas.Font.Color; // save for later 
// because we are going to change it 
if Extrude then // set the correct color 
Font.Color := clBtnHighlight 
else Font.Color := clBtnShadow; 
TextOut(x-4, y-4, Text); // top left wall - 1 
if Extrude then // set the correct color 
Font.Color := clBtnShadow 
else Font.Color := clBtnHighlight; 
TextOut(x+4, y+4, Text); // bottom right + 1 
Font.Color := OrigColor; 
TextOut(x, y, Text); // draw the body of the text 
application.processmessages; 
end; 
end; 

procedure TForm1.TekstButtonclik(Sender: TObject); 
begin 
canvas.font.size := 24; 
canvas.font.color := clNavy; 

TextOut3Dim(Canvas,16,164,'tweede tekst',true); 
TextOut3Dim(Canvas,16,116,'eerste tekst',false); 
end; 


Alvast bedankt voor het meedenken, 

Hans 

--

Ja hoor, ik heb het onder controle. 
Het bleek nodig de brush van het canvas aan te passen, waarna het netjes werkte. 

brush.style := bsclear; 

Nog even de hele code : 

Procedure TextOut3Dim(Canvas:TCanvas;x,y:integer;Text:String;Extrude:Boolean); 
var 
OrigColor:TColor; 
begin 
with Canvas do begin 
brush.style := bsclear; 

OrigColor := Canvas.Font.Color; // save for later 
// because we are going to change it 
if Extrude then // set the correct color 
Font.Color := clBtnHighlight 
else Font.Color := clBtnShadow; 
TextOut(x-1, y-1, Text); // top left wall - 1 
if Extrude then // set the correct color 
Font.Color := clBtnShadow 
else Font.Color := clBtnHighlight; 
TextOut(x+1, y+1, Text); // bottom right + 1 
Font.Color := OrigColor; 
TextOut(x, y, Text); // draw the body of the text 
end; 
end; 

Al weer opgelost...........