_Lexa98_ сказал(а):
#Include <APIConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>
Global Const $STM_SETIMAGE = 0x0172
Global Const $STM_GETIMAGE = 0x0173
Global Const $Pi = 4 * ATan(1)
Global $Prev = -1, $Start = 1
$hForm = GUICreate('MyGUI', 301, 301)
$Pic = GUICtrlCreatePic('', 50, 50, 201, 201)
GUISetBkColor(0xFFFFFF)
While 1
$tPoint = _WinAPI_CreatePoint(150, 150)
_WinAPI_ClientToScreen($hForm, $tPoint)
$X = DllStructGetData($tPoint, 'X')
$Y = DllStructGetData($tPoint, 'Y')
$Pos = MouseGetPos()
If ($Pos[0] <> $X) Or ($Pos[1] <> $Y) Then
$Angle = ($Pos[1] > $Y) * 180 - ATan(($X - $Pos[0]) / ($Y - $Pos[1])) * 180 / $Pi
If $Angle <> $Prev Then
_Draw($Angle)
$Prev = $Angle
EndIf
EndIf
If $Start Then
GUISetState()
$Start = 0
EndIf
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Func _Draw($iAngle)
Local $hWnd, $hDC, $hMemDC, $hSv1, $hSv2, $hPen, $hBitmap, $hObj
$hWnd = GUICtrlGetHandle($Pic)
$hDC = _WinAPI_GetDC($hWnd)
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 201, 201, 0xFFFFFF)
$hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap)
$hPen = _WinAPI_CreatePen($PS_SOLID, 7, 0x0000FF)
$hSv2 = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 100, 100, 100 + 96 * Sin($iAngle * $Pi / 180), 100 - 96 * Cos($iAngle * $Pi / 180))
_WinAPI_ReleaseDC($hWnd, $hDC)
_WinAPI_SelectObject($hMemDC, $hSv1)
_WinAPI_SelectObject($hMemDC, $hSv2)
_WinAPI_DeleteObject($hPen)
_WinAPI_DeleteDC($hMemDC)
$hObj = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
If $hObj Then
_WinAPI_DeleteObject($hObj)
EndIf
$hObj = _SendMessage($hWnd, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
EndFunc ;==>_Draw
ОК"UP" можно делать только через 24 часа. OK?
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
Global Const $iPi = ACos(-1)
Global Const $iDegToRad = $iPi / 180
Global $iR = 100, $iAngleOld = -1, $iWp = 200, $iHp = 200, $iWm = 500, $iHm = 400
$hGUI = GUICreate('Test', $iWm, $iHm)
GUISetBkColor(0xF0F0F0)
$nButton = GUICtrlCreateButton('Exit', 50, 10, 100, 30)
$hGUI_Parent = GUICreate('', $iWp, $iHp, ($iWm - $iWp) / 2, ($iHm - $iHp) / 2, $WS_POPUP)
GUISetBkColor(0xF0F0F0)
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_Parent)
_WinAPI_SetParent($hGUI_Parent, $hGUI)
_GDIPlus_Startup()
$hPen = _GDIPlus_PenCreate(0xFFFF0000, 3)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI_Parent)
While 1
$aWinPos = WinGetPos($hGUI_Parent)
$iAngle = _Angle(MouseGetPos(0), MouseGetPos(1), $aWinPos[0] + $iWp / 2, $aWinPos[1] + $iHp / 2)
If Not @error Then
If $iAngleOld <> $iAngle Then
$iAngleOld = $iAngle
_GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0)
$iX = $aWinPos[0] + $iWp / 2 - $iR * Cos($iAngle * $iDegToRad) - $aWinPos[0]
$iY = $aWinPos[1] + $iHp / 2 - $iR * Sin($iAngle * $iDegToRad) - $aWinPos[1]
_GDIPlus_GraphicsDrawLine($hGraphic, $iWp / 2, $iHp / 2, $iX, $iY, $hPen)
EndIf
EndIf
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $nButton
_Exit()
EndSwitch
WEnd
Func _Angle($i_X, $i_Y, $i_Xcenter, $i_Ycenter)
;Yashied, http://autoit-script.ru/index.php/topic,333.0.html
Local $i_Grad
If ($i_X = $i_Xcenter) And ($i_Y = $i_Ycenter) Then
Return SetError(1, 0, -1)
EndIf
$i_Grad = ($i_Y > $i_Ycenter) * 180 - ATan(($i_Xcenter - $i_X) / ($i_Ycenter - $i_Y)) * 180 / $iPi + 90
If $i_Grad = 360 Then
$i_Grad = 0
EndIf
Return $i_Grad
EndFunc ;==>_Angle
Func _Exit()
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
$hPen = _WinAPI_CreatePen($PS_SOLID, "Вот это число", 0x000000)
$hPen = _WinAPI_CreatePen($PS_SOLID, 11, "Вот это значение")
$hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 201, 201, "Вот это значение")