Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [bug report]problem about processing WM_PAINT message
icon4.gif  [bug report]problem about processing WM_PAINT message [message #29734] Thu, 11 November 2010 07:59 Go to next message
jinshiyi11 is currently offline  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 Go to previous message
mirek is currently offline  mirek
Messages: 12049
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

Previous Topic: How to split a sentence into words
Next Topic: why not StaticText::SetData != StaticText::SetText
Goto Forum:
  


Current Time: Wed Oct 16 04:16:38 CEST 2019

Total time taken to generate the page: 0.01599 seconds