例如:
var
Msg: Cardinal;
case Msg of
WM_CHAR:
WM_KEYDOWN:
WM_KEYUP:
begin
// Do something
end;
end;
使用逗号分隔标签:
var
Msg: Cardinal;
...
case Msg of
WM_CHAR,
WM_KEYDOWN,
WM_KEYUP:
begin
// Do something
end;
end;
正如@SertacAkyuz所提到的,如果值是连续的,你可以这样做:
case Msg of
WM_KEYDOWN .. WM_CHAR: // range
begin
// Do something
end;
end;
假设您希望在所有三种情况下都执行“Do Something”,则必须使用逗号分隔案例标签:
var
Msg: Cardinal;
case Msg of
WM_CHAR,
WM_KEYDOWN,
WM_KEYUP:
begin
// Do something
end;
end;