标题:drawfocusrect 用法存疑,
只看楼主
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
clea
form1=CREATEOBJECT("form1")
form1.show()
read even
retu

DEFINE CLASS form1 AS form
    Top = 0
    Left = -1
    Height = 650
    Width = 1000
    DoCreate = .T.
    BorderStyle = 3
    Caption = "Form1"
    MaxButton = .F.
    Name = "Form1"

    ADD OBJECT container1 AS container WITH ;
        Top = 0, ;
        Left = 0, ;
        Width = 1000, ;
        Height = 650, ;
        SpecialEffect = 1, ;
        BackColor = RGB(255,255,255), ;
        Name = "Container1"

    ADD OBJECT timer1 AS timer WITH ;
        Top = 10, ;
        Left = 10, ;
        Height = 23, ;
        Width = 23, ;
        Name = "Timer1"

    PROCEDURE Resize
    this.container1.Width=this.Width-1
    this.container1.Height=this.Height-1
    ENDPROC

    PROCEDURE container1.MouseMove
    LPARAMETERS nButton, nShift, nXCoord, nYCoord
    this.tox=nxcoord
    this.toy=nycoord
    ENDPROC

    PROCEDURE container1.MouseDown
    LPARAMETERS nButton, nShift, nXCoord, nYCoord
    IF nbutton=1 &&mouse left
        WITH this
            .draw()
            .x=nxcoord
            .y=nycoord
            .oldx=nxcoord
            .oldy=nycoord
        endwith
        thisform.timer1.Interval=100
    ENDIF
    ENDPROC

    PROCEDURE container1.Init
    this.AddProperty("X",0)
    this.AddProperty("Y",0)
    this.AddProperty("toX",0)
    this.AddProperty("toY",0)
    this.AddProperty("oldX",0)
    this.AddProperty("oldY",0)
    STORE 1 TO this.Top,this.left
    this.Height=thisform.Height-1
    this.Width=thisform.Width-1
    ENDPROC

    PROCEDURE container1.draw
    WITH this
        IF .x#.oldx or .y#.oldy
            lcrect=bintoc(MIN(.x,.oldx),"4rs")+bintoc(MIN(.y,.oldy),"4rs")+bintoc(MAX(.x,.oldx),"4rs")+bintoc(MAX(.y,.oldy),"4rs")
            DrawFocusRect(getdc(thisform.hwnd),lcrect)
        endif
    ENDWITH
    ENDPROC
   
    PROCEDURE container1.MouseUp
    LPARAMETERS nButton, nShift, nXCoord, nYCoord
    thisform.timer1.Interval=0
    ENDPROC

    PROCEDURE timer1.Init
    DECLARE Integer DrawFocusRect IN WIN32API ;
        Integer hdc , ;
        String lpRect
    DECLARE Integer GetDC IN WIN32API ;
        Integer hwnd
    DECLARE integer ReleaseDC IN WIN32API integer hwnd,integer hdc
    ENDPROC

    PROCEDURE timer1.Timer
    WITH thisform.container1
        IF .tox#.oldx or .toy#.oldy
            .draw()
            .oldx=.tox
            .oldy=.toy
            .Draw()
        ENDIF
    endwith
    ENDPROC

    PROCEDURE unload
    CLEAR EVENTS
    ENDPROC
ENDDEFINE
2022-09-20 15:47
schtg
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:https://t.me/pump_upp
等 级:贵宾
威 望:67
帖 子:1355
专家分:2534
注 册:2012-2-29
得分:0 
学习啦,谢谢!
2022-09-20 18:41
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
修改后,可以上下左右拖动画框
2022-09-20 20:37
sam_jiang
Rank: 8Rank: 8
等 级:贵宾
威 望:10
帖 子:542
专家分:781
注 册:2021-10-13
得分:0 
回复 13楼 sych
哈哈,厉害,还出升级版的了。。。
2022-09-21 18:53
sam_jiang
Rank: 8Rank: 8
等 级:贵宾
威 望:10
帖 子:542
专家分:781
注 册:2021-10-13
得分:0 
回复 11楼 sych
学习你的代码,好像可以不用timer,直接用mousemove也可以实现啊。
2022-09-30 17:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510093-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015562 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved