Win32 API: How to define line spacing in a static text

Pablo Glomby 181 Reputation points
2020-09-24T18:06:01.857+00:00

Hi!
I have a C++ Win32 application where I use a standard form and a static text inside it. I need to extend the line spacing (space between lines) and I did not find any way to do it. I know I can change the font of the control but the line spacing is not a font attribute. Is there any way to define the line spacing using Win32?
Thanks

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,354 questions
{count} votes

Accepted answer
  1. Castorix31 80,906 Reputation points
    2020-09-24T19:22:00.533+00:00

    You can use a Read Only RichEdit control with EM_SETPARAFORMAT and PFM_LINESPACING flag

    A test with bLineSpacingRule = 4
    and dyLineSpacing = 100 or dyLineSpacing = 400 : Rich-Edit-Line-Spacing.jpg


2 additional answers

Sort by: Most helpful
  1. RLWA32 38,856 Reputation points
    2020-09-24T19:20:40.483+00:00

    You could use a read-only rich edit control where you can specify line spacing instead of a static control.

    0 comments No comments

  2. Darran Rowe 561 Reputation points
    2020-09-24T22:28:16.14+00:00

    To directly answer your question.
    You have to understand that the static control is meant to be simple. For the static text control, it is designed specifically for a dialog box type window and usually used as a label. This means there is no way to set the static text control's line spacing.

    0 comments No comments