Put sendmessage in a class