Re: Screen Pixels and Document Points Conversion
Oh dear, this is getting too complicated.
I tweaked Chip Pearsons demonstration workbook to be modeless (to make it more interactive) and also to move the formatting toolbar to the same position as the userform, along the lines that Barry suggested.
What more have I learnt? Or think I’ve learnt?
1. The following all affect the conversion from pixels to points when using the builtin PointsToScreenPixelsX and PointsToScreenPixelsY methods.
-rowheadings
-number of toolbar rows in the docking area and
-the zoom factor
2. The datum for position properties returned as pixels is the top left of the screen.
The datum for position properties returned as points, when converted to pixels, is the VIRTUAL top left corner of the document. (ie if you’re looking at cell IV65536 then the datum is several metres up and too the left) but when its initially returned in points it’s the top left of the application window.
3. Chip’s workbook seems to work very well most but certainly not all of the time, and somehow he’s done it all without using the PointsToScreenPixels conversions. His method still gives the apparent result that pixels for commandbars and for userforms are different sizes. Ie Plot them at 0,0 and they both coincide at top left of screen (OK) Plot them near a cell midscreen and they do not conincide.
4. Zoom factor affects the size of this discrepancy, both with Chip’s method, and using the PointsToScreenPixels methods. So, there is probably a simple scale factor that depends on the zoom factor.
All I have been aiming for is to have a Commandbar or userform display near the top right hand side (probably just outside if there’s room) of the active document window, (and possibly both, to give the appearance that they are attached to each other) Chip’s approach comes close to this, and could be modified, but is still far too loose. (That doesn’t mean to say that I’m not very impressed with the effort he went to.)
Unless anyone has some inspiration I’m going to abandon this as too time consuming.