The continuation of the project began with:
How to automatically select / scale the width of DBGrid columns (or other similar ones) according to its contents?
How to calculate the "Left" property to center the text in a DBGrid cell?
When we call OnDrawColumnCell and use Canvas to write text instead of replacing the default mesh, how can we calculate the position of the text when we want to center it in the cell?
not to do. Draw the text DrawText / DrawTextEx and specify DT_CENTER in the format parameter. See Also Draw multi-line text in the center of the rectangle .
DrawText
DrawTextEx
DT_CENTER
Or, if you need or need to calculate it yourself:
procedure DrawCenteredText(Canvas: TCanvas; const S: String; R: TRect); var Left: Integer; begin Left := R.Left + (R.Right - R.Left - Canvas.TextWidth(S)) div 2;
An easier way with more features would be:
Canvas.TextRect(Rect,s,[tfCenter,tfVerticalCenter,tfSingleLine]);
Source: https://habr.com/ru/post/1444902/More articles:What is the reverse side of shlex.split? - pythonAccess auto-increment value when executing INSERT INTO - sqlrailing3 caching: expire fragment with extension - cachingHow to generate nodejs to express package.json dependencies - node.jsDifference between shared object and dll - c ++Access to ejb deployed in JBoss 7.0.1 from another client - jbossSQLite on Android and MongoDB with synchronization - androidEmberjs - How to wait for a template to be fully displayed before accessing its children - ember.jshttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1444906/where-systemconfigurationconfigurationmanager-points-to-when-there-is-no-configuration-file&usg=ALkJrhihjSlQdGFHmIweEwyQolIxe0S4EwOS X: Show Application Agent Interface (UIElement) - macosAll Articles