I wanted to create a gui that worked as a canvas for free drawing lines with the mouse and with option of erasing...
anyone can help me?
The simplest solution is to look at how other people have implemented this. For example, searching for freehand on the File Exchange brings up this freehand drawing function.
As a basic idea, you'll want to either regularly capture the mouse position, or to evaluate a callback on mouse movement.