TextOut and WM_PAINT
- From: Robert <Robert@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 6 Oct 2006 00:21:01 -0700
I update the window A from other one (B), by sending SendMessage(WM_PAINT...
This window A receives that message and should check the lparam and wparam..
where wparam is handle to window B and lparam - int value.
What I need is to display that int value.
I do the necessary calculations to get new winsizes (A) and draw the wchar
converted value.
so the changing is non-stop, wm_paint is sending constantly from B and I can
see in file, that the value is receive correctly. (see the code) not just
non-stop, but periodically non-stop.
Say, I begin, then stop, then begin again.. let me call it a "seance".
first message of the seance received and I can see the right value, then the
same value is shown all the time, in spite of the int and buffer values are
changed.
then I stop the seance.
when I beging the next seance I can see again the new changed value, and
after the same changed value. no changes.
I checked out the file tracer.txt :- everything received correctly, the
value is getting changed..
seems like somthing wrong with text output.
cause once, I just boldly converted the int value into char* and converted
the char* to LPWSTR.
And I saw the value had been changing constantly, as it suppose to be.
I use UNICODE mode..
Any clue, please, unless you can't understand me.
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
RECT rcW, rcP;
SIZE mySize;
ZeroMemory(&mySize, sizeof(mySize));
wchar_t buffer[15] = {0};
_itow((int) lParam, buffer, 10);
int sizeStr = wcslen( buffer );
GetTextExtentPoint32( hdc, buffer, sizeStr, &mySize);
GetWindowRect((HWND)wParam, &rcW);
GetWindowRect(GetParent((HWND)wParam), &rcP);
int yPoz = rcP.top + (rcW.bottom - rcP.top);
int x = rcP.left + (rcW.left - rcP.left);
SetWindowPos(hWnd, NULL, x, yPoz, mySize.cx, mySize.cy,
SWP_NOZORDER);
SetTextColor(hdc, RGB(255,0,0));
TextOut(hdc, 0, 0, buffer, sizeStr);
Beep(600,20);
// Просто в файл сбрасываю параметр и в
файле все корректно
FILE* fl;
fl = _wfopen( _T("c:\\tracer.txt"), _T("a") );
fwrite( buffer, 2*sizeStr, 1, fl );
fwrite(_T("\n"), 1, 1, fl );
fclose( fl );
EndPaint(hWnd, &ps);
.
- Follow-Ups:
- Re: TextOut and WM_PAINT
- From: DHarray
- Re: TextOut and WM_PAINT
- Prev by Date: Re: why is 'this' in ctor != 'this' in OnInitDialog() ?
- Next by Date: Re: can I use a CArchive with a CSocket to read regular text?
- Previous by thread: Doc/View background
- Next by thread: Re: TextOut and WM_PAINT
- Index(es):
Relevant Pages
|
|