↑  ←  Описание функции


_WinAPI_CreatePen

Creates a logical pen that has the specified style, width, and color.

#include <WinAPI.au3>
_WinAPI_CreatePen($iPenStyle, $iWidth, $nColor)

Параметры

$iPenStyle Specifies the pen style. It can be any one of the following values.
    PS_SOLID - The pen is solid.
    PS_DASH - The pen is dashed. This style is valid only when the pen width is one or less in device units.
    PS_DOT - The pen is dotted. This style is valid only when the pen width is one or less in device units.
    PS_DASHDOT - The pen has alternating dashes and dots. This style is valid only when the pen width is one or less in device units.
    PS_DASHDOTDOT - The pen has alternating dashes and double dots. This style is valid only when the pen width is one or less in device units.
    PS_NULL - The pen is invisible.
    PS_INSIDEFRAME - The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the figure are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies only to geometric pens.
$iWidth Specifies the width of the pen, in logical units.
$nColor Specifies the color of the pen (BGR)

Возвращаемое значение

Успех:HPEN Value that identifies a logical pen
Ошибка:Возвращает 0

Примечания

The pen can subsequently be selected into a device context and used to draw lines and curves.
After an application creates a logical pen, it can select that pen into a device context by calling the SelectObject function. After a pen is selected into a device context, it can be used to draw lines and curves.
If the value specified by the nWidth parameter is zero, a line drawn with the created pen always is a single pixel wide regardless of the current transformation.
If the value specified by nWidth is greater than 1, the fnPenStyle parameter must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME.
When you no longer need the pen, call the DeleteObject function to delete it.

См. также

_WinAPI_MoveTo, _WinAPI_LineTo, _WinAPI_SelectObject, _WinAPI_DeleteObject, _WinAPI_DrawLine, _WinAPI_GetBkMode, _WinAPI_SetBkMode

См. также

Искать CreatePen в библиотеке MSDN

Пример

#include <WindowsConstants.au3>
#include <WinAPI.au3>

ShowCross(@desktopwidth / 2, @desktopheight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($start_x, $start_y, $length, $width, $color, $time)
    Local $hDC, $hPen, $obj_orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC всего экрана (рабочего стола)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $start_x - $length, $start_y, $start_x - 5, $start_y) ; горизонтальная слева
    _WinAPI_DrawLine($hDC, $start_x + $length, $start_y, $start_x + 5, $start_y) ; горизонтальная справа
    _WinAPI_DrawLine($hDC, $start_x, $start_y - $length, $start_x, $start_y - 5) ; Вертикальная сверху
    ;   _WinAPI_DrawLine($hDC, $start_x, $start_y + $length, $start_x, $start_y + 5) ; Вертикальная снизу
    _WinAPI_MoveTo($hDC, $start_x, $start_y + $length)
    _WinAPI_LineTo($hDC, $start_x, $start_y + 5)

    Sleep($time) ; Показать крестообразный прицел поверх экрана за счёт указанной задержки времени

    ; Обновить рабочий стол (очистить / удалить крестообразный прицел)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; Очистить ресурсы
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross