views:

160

answers:

4

Hi,

I got an old application which was written in a C++. I have 0 experience with it but I am suppose to make some changes in app. One of them is to change some text. Problem is that part of updated text needs to be bold, but i have no idea how to do that. I googled but with no much success. Only think I now is to go to new line with \nand new tab with \t.

Any clever advise?

EDIT:
Example of code:

BEGIN
    STRING1                              "First Example"
    STRING2                              "Second Example"

And 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

+9  A: 

There is no concept of bold text in C++, there may be in a particular device that displays character text, for example rich-text-format or HTML tagging or a terminal screen. The latter usually involves sending some "escape sequence" relevant to that particular terminal.

CashCow
+3  A: 

OK, I've knocked up some code that should give an overview of what you're after, I've not managed to compile it as I'd need to write a lot more to test, but it should point you in the right direction:

// 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);

I hope this helps.

JLWarlow
The thing is I need only part of string to be bold. For example: First <b>Example</b> (this is how it would look like in HTML). Thank you!
ile
Ah ok, not sure how or if you can do that with a static control. You could do something like that with a read-only rich text control, maybe.
JLWarlow
+1, rich text is the correct solution then. A normal static label is intended for simple cases.
MSalters
A: 

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

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

Raghuram Reddy N
Which WM_PAINT? `"STATIC"` is a built-in windows class with its own WndProc.
MSalters
A: 

Please go through the below link for help http://msdn.microsoft.com/en-us/library/dd162499(VS.85).aspx

Yes, you have to override WM_PAINT in your dialog class and call drawtext function.

Raghuram Reddy N