Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

?? Painting Child Windows ??

0 views
Skip to first unread message

smanders

unread,
Jan 8, 2003, 2:18:16 AM1/8/03
to
Hello all,
I really need some help. I have been going crazy over this for the last
couple of days. I have little experience with "visual" programming. Any
help would be greatly appreciated.

I have task that is constantly reading info from a serial port. That works
fine. The task places the data into a global variable string. I also have
a typical mainWindow. It has a child window of "static" classname with
WS_CHILD | WS_VISIBLE | WS_BORDER attributes. So its basically a box. I
want to display the global string in that box every time the serial port is
read.

So in that task, after updating the global sting variable, I call the
following sequence where "g_hWnd" is the mainWindow handle:
while (1)
{
// Read serial port and update the global string----that works.

// Generate notification to PAINT that window
GetWindowRect(g_hWnd,&rect);
InvalidateRect(g_hWnd,&rect,FALSE);
UpdateWindow(g_hWnd);
}
I also tried this with the "static" classname's window handle as well which
would be ideal but I not sure how that would work since I don't get to
register a call back for a WM_PAINT message to be processed when using the
"static" class. I was hoping this code would send a WM_PAINT message to the
mainWindow proc so I could update the text. The only way I can get any text
to be displayed in those boxes, is to go to a completely different screen or
press start twice so that it has to update that region of the window. Then
and only then does it update the box with the string. I want it to update
automatically with no user intervention. I also have defined the WM_PAINT
case as follows for my mainWindow routine:

case WM_PAINT:
// This sets the background
hDC = BeginPaint(g_hWnd, &ps);
GetClientRect(g_hWnd, &rect);
FillRect(hDC, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
SetBkColor (hDC, RGB(0xff, 0xff, 0xff));
EndPaint (g_hWnd, &ps);

// Update String Display
GetClientRect(g_hStringBoxWnd, &rect);
hDC = BeginPaint(g_hStringBoxWnd, &ps);
FillRect(hDC, &rect, (HBRSH)GetStockObject(WHITE_BRUSH));
SelectObject(hDC, g_hFont);
SetTextColor (hDC, RGB(0xff, 0, 0));
SetBkColor (hDC, RGB(0xff, 0xff, 0xff));
if (g_StringDisplayEnabled == TRUE)
{
ExtTextOut(hDC, 10, 25, ETO_OPAQUE, &rect, g_String, _tcslen(g_String),
NULL);
}
break;

I just don't quite know who should be updating the screen and how to invoke
that with no user input. Maybe just an explanation on how the screen update
mechanisms work may put me on the right track.

Thanks for any help,
smanders


Larry Bank

unread,
Jan 9, 2003, 9:59:28 AM1/9/03
to
You should use an ownerdraw button instead.

>.
>

smanders

unread,
Jan 10, 2003, 4:11:36 AM1/10/03
to
I was thinking that in the back of my mind but before I did all the work I
wanted to run it past the forum. Well I did the work and it works
beautifully.....Thanks so much for your help.

smanders

"Larry Bank" <bitbank@hotmail_spamcatcher_.com> wrote in message
news:1e6f01c2b7ef$b55fb3d0$d3f82ecf@TK2MSFTNGXA10...

smanders

unread,
Jan 10, 2003, 4:12:07 AM1/10/03
to
I was thinking that in the back of my mind but before I did all the work I
wanted to run it past the forum. Well I did the work and it works
beautifully.....Thanks so much for your help.

smanders

"Larry Bank" <bitbank@hotmail_spamcatcher_.com> wrote in message
news:1e6f01c2b7ef$b55fb3d0$d3f82ecf@TK2MSFTNGXA10...

0 new messages