| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1318 人关注过本帖, 1 人收藏
标题:drawfocusrect 用法存疑,
只看楼主 加入收藏
sych
Rank: 6Rank: 6
等 级:侠之大者
威 望:7
帖 子:317
专家分:448
注 册: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: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1730
专家分:3324
注 册:2012-2-29
收藏
得分:0 
学习啦,谢谢!
2022-09-20 18:41
sych
Rank: 6Rank: 6
等 级:侠之大者
威 望:7
帖 子:317
专家分:448
注 册:2019-10-11
收藏
得分:0 
修改后,可以上下左右拖动画框
2022-09-20 20:37
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:789
专家分:1165
注 册:2021-10-13
收藏
得分:0 
回复 13楼 sych
哈哈,厉害,还出升级版的了。。。
2022-09-21 18:53
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:789
专家分:1165
注 册:2021-10-13
收藏
得分:0 
回复 11楼 sych
学习你的代码,好像可以不用timer,直接用mousemove也可以实现啊。
2022-09-30 17:47
快速回复:drawfocusrect 用法存疑,
数据加载中...
 
   



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

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