| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 426 人关注过本帖, 1 人收藏
标题:容器控件拦截容器内控件的方法---去bug版来了
只看楼主 加入收藏
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:789
专家分:1165
注 册:2021-10-13
结帖率:96.72%
收藏(1)
 问题点数:0 回复次数:1 
容器控件拦截容器内控件的方法---去bug版来了
疫情在家,就把这个东东再拿出来看看,原来是代码的逻辑问题,现修改了发上来,其实挺简单。
首先,mousedwon时设置mousepointer为9,(左右调整模式);
其次,mouseup时将mousepointer设置为默认0,箭头;
最后鼠标移动时,设置为mousepointer为9时,才可以调整控件大小。
控件的mousemove事件冒泡传递给form,非常有效!

附上代码:
程序代码:
**************************************************
*-- Form:         form1 (d:\documents\visual foxpro 项目\bubbledevent.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   12/28/22 10:40:06 PM
*
DEFINE CLASS form1 AS form


    Height = 750
    Width = 1057
    DoCreate = .T.
    AutoCenter = .T.
    Caption = "Form1"
    WindowState = 0
    oldx = 0
    Name = "Form1"


    ADD OBJECT olecontrol1 AS olecontrol WITH ;
        Top = 35, ;
        Left = 1, ;
        Height = 24, ;
        Width = 280, ;
        Anchor = 0, ;
        Name = "Olecontrol1"


    ADD OBJECT olecontrol3 AS olecontrol WITH ;
        Top = 61, ;
        Left = 1, ;
        Height = 688, ;
        Width = 280, ;
        Anchor = (64+2+1), ;
        Name = "Olecontrol3"


    ADD OBJECT edit1 AS editbox WITH ;
        Anchor = (64+8+2+1), ;
        Height = 714, ;
        Left = 284, ;
        Top = 35, ;
        Width = 771, ;
        Name = "Edit1"


    ADD OBJECT commandgroup1 AS commandgroup WITH ;
        ButtonCount = 6, ;
        Value = 1, ;
        Height = 30, ;
        Left = 1, ;
        Top = 2, ;
        Width = 154, ;
        Name = "Commandgroup1", ;
        Command1.Top = 2, ;
        Command1.Left = 3, ;
        Command1.Height = 25, ;
        Command1.Width = 25, ;
        Command1.Picture = "graphics\bitmaps\offctlbr\small\color\new.bmp", ;
        Command1.Caption = "", ;
        Command1.StatusBarText = "新建一个文件!", ;
        Command1.Alignment = 2, ;
        Command1.Name = "Command1", ;
        Command2.Top = 2, ;
        Command2.Left = 28, ;
        Command2.Height = 25, ;
        Command2.Width = 25, ;
        Command2.Picture = "graphics\bitmaps\offctlbr\small\color\open.bmp", ;
        Command2.Caption = "", ;
        Command2.StatusBarText = "打开一个文件!", ;
        Command2.Alignment = 2, ;
        Command2.Name = "Command2", ;
        Command3.Top = 2, ;
        Command3.Left = 53, ;
        Command3.Height = 25, ;
        Command3.Width = 25, ;
        Command3.Picture = "graphics\bitmaps\offctlbr\small\color\save.bmp", ;
        Command3.Caption = "", ;
        Command3.StatusBarText = "保存文件", ;
        Command3.Alignment = 2, ;
        Command3.Name = "Command3", ;
        Command4.Top = 2, ;
        Command4.Left = 78, ;
        Command4.Height = 25, ;
        Command4.Width = 25, ;
        Command4.Picture = "graphics\bitmaps\offctlbr\small\color\copy.bmp", ;
        Command4.Caption = "", ;
        Command4.StatusBarText = "复制选择的文字", ;
        Command4.Alignment = 2, ;
        Command4.Name = "Command4", ;
        Command5.Top = 2, ;
        Command5.Left = 103, ;
        Command5.Height = 25, ;
        Command5.Width = 25, ;
        Command5.Picture = "graphics\bitmaps\offctlbr\small\color\print.bmp", ;
        Command5.Caption = "", ;
        Command5.StatusBarText = "打印", ;
        Command5.Alignment = 2, ;
        Command5.Name = "Command5", ;
        Command6.Top = 2, ;
        Command6.Left = 128, ;
        Command6.Height = 25, ;
        Command6.Width = 25, ;
        Command6.Picture = "graphics\bitmaps\tlbr_w95\delete.bmp", ;
        Command6.Caption = "", ;
        Command6.StatusBarText = "删除当前文件", ;
        Command6.Name = "Command6"


    ADD OBJECT line1 AS line WITH ;
        Anchor = 10, ;
        Height = 0, ;
        Left = 1, ;
        Top = 32, ;
        Width = 1054, ;
        Name = "Line1"


    ADD OBJECT line2 AS line WITH ;
        Anchor = 10, ;
        Height = 0, ;
        Left = 1, ;
        Top = 33, ;
        Width = 1054, ;
        BorderColor = RGB(255,255,255), ;
        Name = "Line2"


    PROCEDURE LostFocus
        this.MousePointer=0
    ENDPROC


    PROCEDURE MouseUp
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        this.MousePointer= 0 
    ENDPROC


    PROCEDURE MouseDown
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        this.MousePointer= 9 
    ENDPROC


    PROCEDURE MouseMove
        LPARAMETERS nButton, nShift, nXCoord, nYCoord

        IF    this.MousePointer=9 &&AND MDOWN()=.t.
            this.olecontrol3.Width=nxcoord-this.olecontrol3.left
            this.olecontrol1.Width=this.olecontrol3.width
            x=this.edit1.left
            nwidth=this.edit1.width 
            this.edit1.Left=this.olecontrol3.left+this.olecontrol3.width+3
            this.edit1.Width=nwidth+x-nxcoord-3
        ENDIF 
    ENDPROC


    PROCEDURE Resize
        this.olecontrol1.Width=this.olecontrol3.Width
    ENDPROC


    PROCEDURE olecontrol1.Refresh
        *** ActiveX 控件方法程序 ***
    ENDPROC


    PROCEDURE olecontrol1.Change
        *** ActiveX 控件事件 ***
    ENDPROC


    PROCEDURE olecontrol1.Init
    ENDPROC


    PROCEDURE olecontrol1.GetFirstVisible
        *** ActiveX 控件方法程序 ***
    ENDPROC


    PROCEDURE olecontrol3.MouseMove
        *** ActiveX 控件事件 ***
        LPARAMETERS nbutton, nshift, nxcoord, nycoord

        thisform.MouseMove(nbutton,nshift,nxcoord,nycoord)
    ENDPROC


    PROCEDURE olecontrol3.DblClick
        *** ActiveX 控件事件 ***
    ENDPROC


    PROCEDURE olecontrol3.Init
        this.Nodes.Add(,,"Root","我的电脑",,)
        DECLARE integer GetLogicalDriveStrings IN WIN32API integer,string@
        cstr=REPLICATE(CHR(0),40)
        n=getlogicaldrivestrings(40,@cstr)
        FOR i=1 TO n STEP 4
            this.nodes.Add(1,4,,SUBSTR(cstr,i,2),,)
        ENDFOR
        this.Nodes.Item(1).Expanded=.t.
    ENDPROC


    PROCEDURE olecontrol3.HitTest
        *** ActiveX 控件方法程序 ***
        LPARAMETERS x, y
    ENDPROC


    PROCEDURE edit1.MouseMove
        LPARAMETERS nButton, nShift, nXCoord, nYCoord

        thisform.MouseMove(nbutton,nshift,nxcoord,nycoord)
    ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
搜索更多相关主题的帖子: Name Left this 控件 PROCEDURE 
2022-12-28 22:46
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:789
专家分:1165
注 册:2021-10-13
收藏
得分:0 
可以在mousedwon里给鼠标指针显示的范围做个限定,如:
IF nxcoord<this.edit1.Left+3 AND nxcoord>this.edit1.Left-8 &&只限定了左右,没有限定上下
    this.MousePointer= 9
ENDIF
2022-12-28 23:15
快速回复:容器控件拦截容器内控件的方法---去bug版来了
数据加载中...
 
   



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

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