网上看的不知道case scl and (WS_HSCROLL or WS_VSCROLL) of
怎么解呢?在这里有and 和 or 跟 if语句一样吗?
请各位指点.
case scl and (WS_HSCROLL or WS_VSCROLL) of
// 0: // showmessage('ssNone');
WS_HSCROLL: // showmessage('ssHorz');
WS_VSCROLL:
else begin // showmessage('ssBoth');
end;
怎么解呢?在这里有and 和 or 跟 if语句一样吗?
请各位指点.
case scl and (WS_HSCROLL or WS_VSCROLL) of
// 0: // showmessage('ssNone');
WS_HSCROLL: // showmessage('ssHorz');
WS_VSCROLL:
else begin // showmessage('ssBoth');
end;
当scl是WS_HSCROLL或者WS_VSCROLL时
等价于
A:=scl and (WS_HSCROLL or WS_VSCROLL)case A ofA不是0就是1
WS_VSCROLL = $200000;
化为二进制计算
0001 0000 0000 0000 0000 0000
or 0010 0000 0000 0000 0000 0000
-----------
0011 0000 0000 0000 0000 0000
再化为16进制 $300000
然后再 AND scl
计算出一个16进制数, 然后有对应的参数 然后就是普通的CASE OF了
// 0: // showmessage('ssNone');
WS_HSCROLL: // showmessage('ssHorz');
WS_VSCROLL:
else begin // showmessage('ssBoth');
end;
BTW,代码中的这个And运算是画蛇添足的多此一举。