Mantis #3983

Fixed potential  division by zero exceptions when calculating number of pages for various controls. Checked every call before SetRange() calls. In addition adjusted SetRange to make sure that end >= start.