How to print a bold line in C ++?

I have an old application written in C ++. I have 0 experience with it, but I suppose to make some changes to the application. One of them is to change the text. The problem is that part of the updated text should be bold, but I have no idea how to do this. I googled but without much success. Just think that now I have to go to a new line with \nand a new tab with \t.

Any smart tips?

EDIT:
Code Example:

BEGIN
    STRING1                              "First Example"
    STRING2                              "Second Example"

And the place where STRING1 is used:

// WelcomeTip ---------------------------------------------//
    LPSTR idsWelcomeTip = (LPSTR)GlobalAlloc(GPTR, sizeof(CHAR) * 4098 );
    LoadString( waveInDlg->hInstance, STRING1, idsWelcomeTip, 4098 );
    waveInDlg->hwndWelcomeTip = CreateWindow(
        "STATIC",
        idsWelcomeTip,
        WS_CHILD | WS_VISIBLE | SS_LEFT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        waveInDlg->hwnd,
        NULL,
        waveInDlg->hInstance,
        NULL
    );
    SetWindowLongPtr(waveInDlg->hwndWelcomeTip, GWLP_USERDATA ,(LONG)waveInDlg );
    SendMessage(waveInDlg->hwndWelcomeTip, WM_SETFONT , (WPARAM)waveInDlg->hFontDefault , TRUE );
    ShowWindow(waveInDlg->hwndWelcomeTip, SW_HIDE);
    GlobalFree( (HGLOBAL)idsWelcomeTip );

Thanks,
Ile

+3
source share
4 answers

++ , , , , rich-text HTML, . "escape-", .

+10

, , , , , , , :

// Create the font you need
LOGFONT lf;
zeromemory(&lf, sizeof(LOGFONT))
lf.lfHeight = 20; // 20 pixel high font
lf.lfWeight = FW_BOLD;
strcpy(lf.lfFaceName, "Arial");
HFONT hFont = ::CreateFondIndirect(&lf);

// Set the control to use this font
SendMessage(waveInDlg->hwndWelcomeTip, WM_SETFONT, (WPARAM)hFont, NULL);

, .

+3

Use the DrwaText API in the WM_PAINT message handler. dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER); use the DrawTextEx method. For more information, click on the following link.

ms help: //MS.MSDNQTR.v90.en/gdi/fontext_4pbs.htm

-1
source

Source: https://habr.com/ru/post/1771451/


All Articles