Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [bug report]problem about processing WM_PAINT message
[bug report]problem about processing WM_PAINT message [message #29734] |
Thu, 11 November 2010 07:59 |
jinshiyi11
Messages: 7 Registered: October 2010 Location: CHINA
|
Promising Member |
|
|
I think the processing about WM_PAINT message in Ctrl::WindowProc(...) has some issue.
Location at the "CtrlCore\Win32Proc.cpp" file(Ctrl::WindowProc)
LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
...
case WM_PAINT:
ASSERT(hwnd);
if(IsVisible() && hwnd) {
//drawing code
}
return 0L;
....
}
If ctrl is not visible,then drawing code will not be executed and just return 0L.At this scenario£¬WM_PAINT will not be removed from message queue.Then Ctrl::ProcessEvent(...) will process with WM_PAINT message again and again.
The Windows documentation notes that you can't use PeekMessage to remove WM_PAINT messages from the message queue.
The only way to remove a WM_PAINT message from the queue is to validate the invalid regions of the window's client area, which you can do with ValidateRect, ValidateRgn, or a BeginPaint and EndPaint pair.
I encounter this problem when I use ToolTip ctrl.The tooltip window received WM_PAINT message but it is unvisible sometimes.I don't konw why.
[Updated on: Thu, 11 November 2010 08:10] Report message to a moderator
|
|
|
Re: [bug report]problem about processing WM_PAINT message [message #29789 is a reply to message #29734] |
Wed, 17 November 2010 10:55 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Interesting. I have not encountered a problem there during all these years with U++, but I guess there is no reason not to fix this.
Does this:
case WM_PAINT:
ASSERT(hwnd);
if(hwnd) {
PAINTSTRUCT ps;
if(IsVisible())
SyncScroll();
HDC dc = BeginPaint(hwnd, &ps);
fullrefresh = false;
if(IsVisible()) {
SystemDraw draw(dc);
#ifndef PLATFORM_WINCE
HPALETTE hOldPal;
if(draw.PaletteMode() && SystemDraw::AutoPalette()) {
hOldPal = SelectPalette(dc, GetQlibPalette(), TRUE);
int n = RealizePalette(dc);
LLOG("In paint realized " << n << " colors");
}
#endif
painting = true;
UpdateArea(draw, Rect(ps.rcPaint));
painting = false;
#ifndef PLATFORM_WINCE
if(draw.PaletteMode() && SystemDraw::AutoPalette())
SelectPalette(dc, hOldPal, TRUE);
#endif
}
EndPaint(hwnd, &ps);
}
return 0L;
seem like appropriate fix?
Mirek
[Updated on: Wed, 17 November 2010 10:57] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Apr 18 03:29:33 CEST 2024
Total time taken to generate the page: 0.01409 seconds
|