例如:
var
Msg: Cardinal;
case Msg of
WM_CHAR:
WM_KEYDOWN:
WM_KEYUP:
begin
// Do something
end;
end;
答案 0 :(得分:6)
使用逗号分隔标签:
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;
答案 1 :(得分:0)
假设您希望在所有三种情况下都执行“做某事”,则必须用逗号分隔个案标签:
var
Msg: Cardinal;
case Msg of
WM_CHAR,
WM_KEYDOWN,
WM_KEYUP:
begin
// Do something
end;
end;