IFEX D:\DEBUG_PECMD.LOG, LOGS **ln=1 * D:\DEBUG_PECMD.LOG 
TEAM ENVI^ EnviMode=1| ENVI^ ForceLocal=1
TEAM SET &SRC=

CALC TIMEMS=60000 * 30  // 30min
SET SRC=%CurDir% //默认配置 
//SET SRC=D:\TEST_PECMD0\WALL\Wallpaper3
FIND $%~1<>, SET SRC=%~1
SET  WM_SIZE=0x0005
SET SIZE_MAXHIDE=4
SET SIZE_MAXSHOW=3
SET SIZE_MAXIMIZED=2
SET SIZE_MINIMIZED=1
SET SIZE_RESTORED=0

SET  &WM_LBUTTONDOWN=0x0201
SET  &WM_LBUTTONUP=0x0202
SET  &WM_LBUTTONDBLCLK=0x0203
SET  &WM_RBUTTONDOWN=0x0204
SET  &WM_RBUTTONUP=0x0205

IFEX $%PeExe%=1,  LOAD "%CurFile%.ini" !  LOAD "%Myname%.ini"  //自定义配置 

SET &IMAG=IMAG
SET &I=1
FIND $%~1=-real, TEAM SET IMAG=IMAG -real| SET I=2
MSTR &af=<~%I%>%*
FIND $%af%<>, SET SRC=%af%

WIN1 

_SUB WIN1,W750H550,浏览图片 PECMD%PECMDVER%,,,,, -maxb -size 
    TEAM SET &I=1| SET &FS=| SET &NUM=1| SET &F=| SET &FN=| SET &W=730| SET &H=520 | SET &bs=1| SET &TT=0| SET &step=1| SET &y0=0| SET &x0=0
    ENVI @this.MSG=%&WM_SIZE%::&&wParm,&&lParm,CALL OnSize_WIN1 %&wParm%  %&lParm% 

    ENVI @this.POS=?x:y:w:h:x0:y0
    CALC #x0= %x0% + 2 + 2 + %x0% + 3
    CALC #y0= %y0% + 2 + 2 + 5  
    CALL OnSize_WIN1 %&SIZE_MAXSHOW% //校正大小 

    IFEX %SRC%,!!  IFEX %SRC%\,! SET FN=%SRC%

    %IMAG% -bupdate &IMAG1,L2T2W%w%H%h%,%FN%,,#0xFF00FF,2
    CALL  OnPic 1   //第一次 
    ENVI @this.MSG=%WM_LBUTTONUP%::&&wParm,&&lParm,  CALL OnPIC      
    ENVI @this.MSG=%WM_RBUTTONUP%::&&wParm,&&lParm,  CALL OnChange    
_END

_SUB OnShow  
    FIND $1=%bs%,!  EXIT
    ENVI @&IMAG1.update=%w%:%h%;%FN%  //更新
_END

_SUB  OnChange
    BROW &&dirp,*%&SRC%,请选择一个目录
    FIND $X=X%dirp%, EXIT 
    SET SRC=%dirp% 
    CALL OnPIC
_END

_SUB  OnPic
    EXEC* FS=!cmd /c dir /b  %SRC%  
    READ -*,-1,NUM,FS 
    IFEX $%NUM%<1, EXIT _SUB
    CALC #I=  %I% +  %step% + %NUM% - 1 
    CALC #I=  %I%  %  %NUM%  + 1  
    READ -*,%I%,F,FS
    SET FN=%SRC%\%F%
    CALL OnShow 
_END

_SUB OnSize_WIN1
   TEAM SET &sz=0 
   IFEX $%1 = %&SIZE_MAXIMIZED%, ENVI &sz=1
   IFEX $%1 = %&SIZE_MAXSHOW%, ENVI &sz=1
   IFEX $%1 = %&SIZE_RESTORED%, ENVI &sz=1
   IFEX $1=%&sz%,
   {
        ENVI @this.POS=?::&&w1:&&h1
        CALC #&w1= %&w1% - %x0%
        CALC #&h1= %&h1% - %y0% 
        IFEX $%w%=%w1%,!! IFEX $%h%=%h1%, exit  _SUB 
        SET w=%w1% 
        SET h=%h1%  
        ENVI @&IMAG1.update=%w%:%h%  //;%FN%  //更新大小
   }    
_END



