Buildings have swayed in Bangkok and startled residents have poured into the streets as a strong 7.7 magnitude earthquake struck the Thai capital.