找回密码
 加入
搜索
查看: 3095|回复: 2

[图形处理] 怎么实现象‘画图’(Mspaint.exe)那样画椭圆?[已解决]

[复制链接]
发表于 2011-6-26 07:56:07 | 显示全部楼层 |阅读模式
本帖最后由 happytc 于 2011-8-25 23:50 编辑

就是按住左键不放,移动鼠标,那个椭圆也跟着光标动

不行了,通宵了,下面的代码,我怎么也想不到实现那种效果了

#Include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Global Const $CursorID = MouseGetCursor()
Global $hGUI, $hpen, $hGraphicBg

WhiteBoard()

Func WhiteBoard()
        Local $HBITMAP, $hBmp, $PenSize, $ColorValue
        Opt("GUIOnEventMode", 1)

        _GDIPlus_Startup()

        $HBITMAP = _ScreenCapture_Capture("", 0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0)
        $hGUI = GUICreate("WhiteBoard-LiveCapture", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)

        GUISetState(@SW_SHOW, $hGUI)
        $hGraphicBg = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
        _GDIPlus_GraphicsDrawImage($hGraphicBg, $hBmp, 0, 0)
        _WinAPI_DeleteObject($HBITMAP)

        $PenSize = 8
        $hPen = _GDIPlus_PenCreate(0xA0FFFF00, $PenSize)

        GUISetOnEvent(-3, "_Exit")
        OnAutoItExitRegister("_Exit")
        GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Draw", $hGUI)

        

        While True
                Sleep(2000)
        WEnd
EndFunc




Func Draw()
    Local $MousePos, $MouseXOri, $MouseYOri
        GUISetCursor(0, 1, $hGUI)
    $MousePos = GUIGetCursorInfo($hGUI)
        $MouseXOri = $MousePos[0]
        $MouseYOri = $MousePos[1]
    Sleep(50)
    Do
        
        
        $MousePos = GUIGetCursorInfo($hGUI)
        If $MouseXOri <> $MousePos[0] Or $MouseYOri <> $MousePos[1] Then
            ;_GDIPlus_GraphicsDrawLine($hGraphicBg, $MousePos[0], $MousePos[1], $MouseXOri, $MouseYOri, $hPen)
                        _GDIPlus_GraphicsDrawEllipse($hGraphicBg, $MousePos[0], $MousePos[1],$MouseXOri, $MouseYOri, $hPen)
            ;$MouseXOri = $MousePos[0]
            ;$MouseYOri = $MousePos[1]
        EndIf
    Until Not $MousePos[2]
EndFunc

Func _Exit()
    GUISetCursor($CursorID, 1, $hGUI)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphicBg)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc
 楼主| 发表于 2011-6-26 07:59:22 | 显示全部楼层
还有就是上面的代码在画椭圆时,怎么有时背景图一下就没有了呢?而画直线时(注释掉画椭圆那行,反注释那三行),背景图就一直在,为什么?
发表于 2011-6-26 14:16:39 | 显示全部楼层
这个要请教GDI高手啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 21:59 , Processed in 0.081539 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表