#!pecmd
#code=936T950

ENVI^ EnviMode=1  //避免意外错误，空变量，外部变量，
ENVI^ FORCELOCAL=1  //可以处理大变量. 不影响外部变量
SET  ::WM_MOUSEENTER                   =0x1000
SET  ::WM_MOUSEHOVER                   =0x02A1
SET  ::WM_MOUSELEAVE                   =0x02A3
SET  ::WM_LBUTTONDOWN=0x0201
SET  ::WM_LBUTTONUP=0x0202
SET  ::WM_LBUTTONDBLCLK=0x0203
SET  ::WM_MOUSEMOVE=0x0200
SET  ::MK_LBUTTON=0x0001
SET  ::WM_DROPFILES=0x0233
SET  ::WM_SIZE=0x0005
SET  ::SIZE_MAXHIDE=4
SET  ::SIZE_MAXSHOW=3
SET  ::SIZE_MAXIMIZED=2
SET  ::SIZE_MINIMIZED=1
SET  ::SIZE_RESTORED=0




CALL @WIN1 %* 


_SUB WIN1,W780H479,拖动控件
    ENVI @this.POS=?::&&W00:&&H00:&&X0:&&Y0::::&&CW0:&&CH0  //查询
    SET &idMove=
    SET &bDirty=0
    @TEAM SET &XMIN=20| CALC #&&XMAX=%CW0% - 60
    @TEAM SET &YMIN=20| CALC #&&YMAX=%CH0% - 60
 
    ENVI @this.MSG=%&WM_LBUTTONUP%: @FIND $%idMove%<>, TEAM ENVI @this.MouseCapture=0|SET idMove=| IFEX $%bDirty%>0, ENVI @this.InvalidateRect=| SET bDirty=0
    ENVI @this.MSG=_%WM_MOUSEMOVE%::&&wParm,&&lParm, @FIND $%idMove%<>, OnMOUSEMOVE %&wParm%  %&lParm%

    CALC #&&MyCtr01HCut=24/2   //高度一半.简单算法
    CALC #&&MyCtr01XCut=38/2   //宽度一半.简单算法


    LABE+ -vcenter MyCtr01,L17T163W38H24,B01,*,
    ENVI @MyCtr01.MSG=_%WM_LBUTTONDOWN%::&&wParm,&&lParm, TEAM ENVI @this.MouseCapture=1| OnMOUSEBegin %&wParm%  %&lParm%  MyCtr01

    LABE+ -vcenter MyCtr02,L67T163W38H24,B02,*,
    ENVI @MyCtr02.MSG=_%WM_LBUTTONDOWN%::&&wParm,&&lParm, TEAM ENVI @this.MouseCapture=1| OnMOUSEBegin %&wParm%  %&lParm%  MyCtr02
_END

_SUB OnMOUSEBegin
    SET idMove=%~3
_END

_SUB OnMOUSEMOVE
    @CALC -base=16 #&&lb=%MK_LBUTTON% & %&wParm%
    @IFEX $%lb%=0, @EXIT _SUB
    @ENVI @this.Cur=?&&X;&&Y;&&CX;&&CY

    CALC #&&y=%CY% - %MyCtr01HCut%
    CALC #&&x=%CX% - %MyCtr01XCut%

    @IFEX $[ %y%<%YMIN% | %y%>%YMAX% ], @EXIT _SUB
    @IFEX $[ %x%<%XMIN% | %x%>%XMAX% ], @EXIT _SUB

    ENVI @%idMove%.POS=%x%:%y%
    SET bDirty=1
_END




