while (Cmd = EmptyCommand) do Cmd := GetClickedCommand; if (Cmd = btnOK) then ... if (Cmd = btnBACK) then ...