Draw line with style different that solid and width different that 0 (Second request)

Draw line with style different that solid and width different that 0 (Second request)

Post by PSINE » Wed, 29 Jul 1998 04:00:00



I looking for a method or function to draw line with style other than solid
and Width other than 0 or 1
In fact, the std api function CreatePen doesn't support these options
Anybody has a solution ?

ex: CreatePen(PS_DASH, 10, RGB(0,0,0)), That doesn't work
A other API function exist ?

Hi,

P.Bawin

 
 
 

Draw line with style different that solid and width different that 0 (Second request)

Post by Lars Egga » Thu, 06 Aug 1998 04:00:00


Use ExtCreatePen for WIN32 applications.
In Windows NT you can draw line with style other than solid
Quote:>and Width other than 0 or 1, but not in Windows 95.

I am using this.
Example:
#ifdef WIN32
tPen = NULL;

// ExtCreatePen is very timeconsuming, so don't use it if not necesary.
if ( (B0GisPen.PenStyle & (PS_JOIN_MASK | PS_ENDCAP_MASK)) ==
(PS_ENDCAP_ROUND | PS_JOIN_ROUND) )
         bDefaultPenStyle = TRUE; // Default pen style

// xWinSize is width of pen

if ( xWinSize > 1 &&
           !(B0GisPen.CurrPen == PS_SOLID && bDefaultPenStyle) &&
           (B0GisPen.CurrPen != PS_NULL && B0GisPen.CurrPen !=
PS_INSIDEFRAME) )
{
   // Create a pen that handles:
   // - wide lines w/ dashed lines ( not solid lines )
   // - vary End cap & Line join
   DWORD dwPenStyle = PS_GEOMETRIC | B0GisPen.CurrPen |   B0GisPen.PenStyle;
   LOGBRUSH lBrush;
   lBrush.lbStyle = BS_SOLID;
   lBrush.lbColor = dwColor;
   lBrush.lbHatch = 0;

   tPen = (HANDLE) ExtCreatePen(
             (DWORD) dwPenStyle, // pen style
             (DWORD)  xWinSize,  // pen width
             &lBrush,            // address of structure for brush
attributes
             0,       // length of array containing custom style bits
             NULL     // optional array of custom style bits
            );

Quote:}

#endif // WIN32

if ( tPen == NULL ) // WIn32s does not support ExtCreatePen, so have extra
check.
{
   // Windows95 does not handle it properly neither.
   // NB! Take care so it works on both WIN32 & WIN16
   tPen  = (HANDLE ) CreatePen( B0GisPen.CurrPen, xWinSize,
                                  dwColor);

Quote:}

Lars Eggan

>I looking for a method or function to draw line with style other than solid
>and Width other than 0 or 1
>In fact, the std api function CreatePen doesn't support these options
>Anybody has a solution ?

>ex: CreatePen(PS_DASH, 10, RGB(0,0,0)), That doesn't work
>A other API function exist ?

>Hi,

>P.Bawin