|
Greetings, I'm trying to add a feature to my project's toolbars to allow them to "float"; this is, at user request, the ToolStrip object is removed from its ToolStripContainer, added to a new, empty Form with Text equal to the strip's Text and with FormBorderStyle=FormBorderStyle.SizableToolWindow, then show the form. The problem I'm facing is to figure out the right value for that form's Location. My goal is to have the strip itself to be exactly where it was before "floating" it; but I can't define directly the strip's location, I need to compute a location for the form such as, after drawing borders and title-bar, the strip ends up in the desired position. I have tried several combinations of calls to PointToClient and PointToScreen from the ToolStripContainer, the ToolStrip, and the form itself, taking the strip's Location as my starting point, but I haven't managed to get the form appear anywhere close to where I'm trying. To put the question more explicitly: having a Point p that represents a screen coordinate, how should I compute the Location for a Form so the top-left corner of the form's client rectangle matches p ? Thanks in advance for any answer and/or suggestions. Regards, herenvardo |