notepad paints it one pixel lower than lazarus
You picture is not themed? Why, we were looking at code for themed only until now. Un-themed is handled elsewhere.
As for themed, on my PC notepad and Lazarus are identical. At least placement wise. Notepad paints a 1pixel white border on the left, Lazarus does not.
Anyway differences in Y placement may be explicable, *IF* may observation/assumption on squeezing into a fixed height is correct. IF so, there would have to be a special rule on Y placement.
X placement appears fine though.
As it is now I have no idea what I'm looking for and why.
Does
GetThemeTextExtent(Theme, DC, MENU_BARITEM, 0, PWideChar(W), Length(W),
DT_SINGLELINE or DT_LEFT or DT_EXPANDTABS, nil, TextRect);
return the correct Value.
E.g
- Say that returns left=0 (left is always 0) and right=20; which means a width of 20 pixels.
- Then you snapshot the menu, zoom and count the amount of visible pixels of that menu caption.
Now if you can see 20 pixels, and the 21st is missing, then painting is fine, and calculation in the code that we looked at is also fine. It means that measuring goes wrong.
How can I test for subpixel? I'm assuming here but I would say that all program that use GDI+ instead of GDI do subpixel.
Sorry no idea. Not exactly the area of my expertise.
But, if your systems says that the text "File" is 20.4 pixel width, and Lazarus measures with a method tha gets full pixel only, then what will Lazarus receive?
But again this is speculation. I do not know this part of windows in that much detail..
----------------------
It might help to add DT_NOCLIP to TextFlags to disable clipping for drawing the text in DrawVistaMenuBar:
Yes, but that is, IF the error is in the drawing part of the code.
If the error is some place else, we should fix it some place else. Only if we exhausted all roads and have not found the place, then may we thing about adding a workaround in the "wrong" place.