Tu problema no es la optimización del codigo, sino que tu código es propenso a errores inesperados, porque si el objeto pasado como sender no es un TMenuItem o un TdxWinXPBarItem, seguramente tendras un error bastante feo.
Código Delphi
[-]
if (Sender is TMenuItem) then
with TMenuItem(Sender) do
begin
H := Hint;
Cap := Caption;
end
else if (Sender is TdxWinXPBarItem) Then
with TdxWinXPBarItem(Sender) do
begin
H := Hint;
Cap := Caption;
end
else
raise....