Hi all,
I need to center the screen on a given node say GraphMain.Objects[0] to simplify.
I am doing this
NodeRect := GraphMain.Objects[0].BoundsRect;
ancho := NodeRect.Right -NodeRect.Left ;
alto := NodeRect.Bottom -NodeRect.Top ;
NodeRect.Left := NodeRect.Left - (GraphMain.Width div 2) + (ancho div 2);
NodeRect.Top := NodeRect.Top - (GraphMain.Height div 2)+ (alto div 2);
NodeRect.Right := NodeRect.Right + (GraphMain.Width div 2) - (ancho div 2);
NodeRect.Bottom := NodeRect.Bottom + (GraphMain.Height div 2) - (alto div 2);
It is working well, but it does not work well with zoom , I suppose I have to convert the nodrect with ClientToGraph or GraphToClient but I don't find the solution, any help would be appreciated.
An other thing I must do is to center the screen where the mouse is when the user presses a key (it is something like the previous case but without an object). For example if the mouse is at the bottom right and the user press 'C' then the point where the mouse is should be now the center of the graph (and I must move the mouse position do) it is something very usual in cad programs.
Thanks
Sergi.