was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

41 Visitors Online


 
... ein eigenes Pen Style kreieren?
Autor: Benjamin van Eck
[ Tip ausdrucken ]  

Tip Bewertung (27):  
     


{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I had to draw a dotted line on the printer canvas, but when I used the
standard penstyle psDot in Delphi the dots where 1 centimeter long.
So I had to figure out how to draw smaller dots on the printer canvas.

The Windows API provides a funtion: ExtCreatePen(...) to create your
own penstyle. So now, just specify how long the dots should be and the
white space between the dots and voila! you created your own style.

This is how it works:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{
 First:
 define your penstyle by creating a array of DWord. This array can be
 as long as you want to. Just remember to have an even count of
 objects of DWord in the array. Mine this on a printer with 600 dpi:
}
kleefPenStyle: array[1..2] of DWORD = (10, 10);

{I only had to define the first length of the dot and the first white
 space, but add more DWord objects as you like.}

{
 Secondly:
 define the look of you Pen, by setting the brush. I have created a
 variable:
}

logBrush: TLogBrush.
//Set the brush in your code:
logBrush.lbStyle := BS_SOLID;

logBrush.lbColor := Canvas.Pen.Color;

{
 Finally:
 make your penstyle known to the Pen:
}
Canvas.Pen.Handle := ExtCreatePen(PS_GEOMETRIC or PS_USERSTYLE,
                                  Canvas.Pen.Width,
                                  logBrush,
                                  Length(kleefPenStyle), @kleefPenStyle);
                                  
{By giving PS_USERSTYLE with the dwPenStyle parameter you let Windows
know you've created you own penstyle. The rest of the parameters must
be clear to you.

Benjamin}


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners