I mean, when i use CControl to add some button in my program, and i insert my code (time) in somewhere, the button doesn't works.
Because it's seems the code of button (Ccontol) never be executed. I have no idea how to solve it.

The problem is that you have two event loops: messageloop() and realtime(), and realtime() never exits since b will never equal 5. You should only be using messageloop() if you want your CControls UI to function.