GoView center on zoom when doc is small

When the document is smaller than the view I would like that the
document to be centered on the view (now is on the top/left). This is
especially important when the zoom function is involved.

I tried to set the DocPosition to negative values but it doesn’t seem to work.

Any clue will be greately apreaciated.

A GoDocument has a notion of its own bounds, as described by its GoDocument.TopLeft and .Size properties.
Each GoView has its own notion of its document’s bounds, the GoView.DocumentTopLeft and .DocumentSize properties. The view uses its own .DocumentTopLeft and .DocumentSize properties to decide what to show and where. This is needed, for example, to implement the GoView.ShowNegativeCoordinates property.
It might be possible to do what you want by adjusting the GoDocument’s TopLeft and Size properties to be the way you want.
But more generally, you can override the GoView.DocumentTopLeft and GoView.DocumentSize properties to behave the way you want.

We resolved this issue by overriding GoView.DocumentTopLeft and growing the size of the document like in Visio.
Thanks for your help

bloomfield, i need sample from you.

Actualy it didn’t worked very well and we discard the solution. There
were some unwanted side effects generated probably by our lack of
knowledge in the library (the view changed the position some time - it
was an ugly jump effect). So I do not have the sample code any more and
I do not recomand this aproach if you are not realy sure you know what
you are doing.

In the end we enlarged the document to be 3x the real size of the
object bounds and zoom directly to the point where the mouse pointer is
(or to the last such point if exists - like in visio). This is working
preaty well with one side efect: the scrollbar are 3x larger then they
should be.

For mouse wheel code see

Northwoods Software =wheel