0

I am trying to render some text on screen. I am using GDI, C++ and trying to use DrawText and TextOut functions to render my text. My text only appears when program starts, and then text immediatily disappear. Am i able to use it with GDI and if i am, then how?

HDC         hDC;
PAINTSTRUCT Ps;
HFONT       font;
LOGFONT LogFont;

...

hDC = BeginPaint(hWnd, &Ps);

GDI render code

    LogFont.lfStrikeOut = 0;
    LogFont.lfUnderline = 0;
    LogFont.lfHeight = 42;
    LogFont.lfEscapement = 0;
    LogFont.lfItalic = TRUE;

    font = CreateFontIndirect(&LogFont);
    SelectObject(hDC, font);
    TextOut(hDC, 20, 18, "Some text", 14);

    DeleteObject(font);

EndPaint(hWnd, &Ps);

Using code from this lesson.

Peter Kostov
  • 941
  • 1
  • 6
  • 15
Doubstract
  • 1
  • 1
  • 5
  • `My text only appears when program starts, and then text immediatily disappear` This usually happens when drawing is done not in WM_PAINT message handler. – Alex F Oct 22 '14 at 13:44
  • I am calling function onPaint() in VM_PAINT message handler and doing all drawing in onPaint() function. This could be problem? – Doubstract Oct 22 '14 at 13:50
  • Thanks you so much Alex Farber! I wish i could accept your answer, but you just commented. – Doubstract Oct 22 '14 at 13:58

1 Answers1

0

My text only appears when program starts, and then text immediately disappear This usually happens when drawing is done not in WM_PAINT message handler.

Alex F
  • 42,307
  • 41
  • 144
  • 212