Quantcast
Channel: TextOut wierd behavior
Viewing all articles
Browse latest Browse all 6

TextOut wierd behavior

$
0
0

I got 2 windows, one main and other child. Here is child WndProc relevant pieces:

case WM_MOUSEMOVE:
    {
    mousePos.x = LOWORD(lParam);
    mousePos.y = HIWORD(lParam);

    SendMessage(hWnd, WM_PAINT, 0, 0);

    return 0;
  }break;case WM_PAINT:
    {
      PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);

            ...//here i draw some fancy regions// and on top draw some text
            LPTSTR buff0 = new TCHAR[32];
      _itot_s(mousePos.x, buff0, 32, 10);
      COLORREF oldCol = SetTextColor(hdc, RGB(50, 70, 50));
      tstring str = TEXT("Output Window");
      str += TEXT(", pt(");
      str += buff0;
      str += TEXT(", ");
      _itot_s(mousePos.y, buff0, 32, 10);
      str += buff0;
      str += TEXT(").");if(0 == TextOut(hdc, 8, 4, str.c_str(), str.size()))
      {// It never enters here, so i assume it works
        MessageBox(0, TEXT("TextOut FAILED!"), TEXT("ERROR"), 0);
      }
      SetWindowText(mainWnd->GetHandle(), str.c_str());// set caption text for parent wnddelete buff0;
            ...//here i delete brushes, fonts etc...
            EndPaint(hWnd, &ps);return 0;
    }break;


mousepos is POINT member variable of application class that also contains this 2 windows, tstring is typedef for std::basic_string<TCHAR>, but that is not a problem.
The text caption for main/parent window is updating constantly as i move my mouse over child window (and this is a sign that it is in childs WM_PAINT message), but text drawn with TextOut on child window is not changing at all, it just stays as it is for the first run:

Output Window, pt(0, 0).


Values in braces stays always at 0 while on main window its changing constantly. Don't know *** is going on? I don't see any reason why this shouldn't work.


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images