_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.См. также
_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