Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
Cambalinho
why isn't transparent?
Who knows? You are expected to erase or not to erase. And return non-zero in first case, and 0 in the second case. You want Windows to erase for you, you just return 0, and not fidgeting with DefWindowProc. You want to call DefWindowProc yourself, you are to return what it returns. You do nothing similar, but something chaotic.
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
Igor Vartanov
Who knows? You are expected to erase or not to erase. And return non-zero in first case, and 0 in the second case. You want Windows to erase for you, you just return 0, and not fidgeting with DefWindowProc. You want to call DefWindowProc yourself, you are to return what it returns. You do nothing similar, but something chaotic.
i'm confused :(
Re: [win32] - avoid flicker and do a correct redraw
If you want the default window erase process then you don't process WM_ERASEBKGND and just let DefWindowProc() do its thing. This assumes that the hbrBackground member of the WNDCLASS structure is defined and non-null.
If you want to yourself process the background within WM_ERASEBKGND, then process the background as required within WM_ERASEBKGND and return a non-zero value.
If you want to yourself process the background in WM_PAINT, then within WM_ERASEBKGND just return 0. Within the PAINTSTRUCT struct passed to WM_PAINT then the fErase member will be TRUE.
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
2kaud
If you want the default window erase process then you don't process WM_ERASEBKGND and just let DefWindowProc() do its thing. This assumes that the hbrBackground member of the WNDCLASS structure is defined and non-null.
If you want to yourself process the background within WM_ERASEBKGND, then process the background as required within WM_ERASEBKGND and return a non-zero value.
If you want to yourself process the background in WM_PAINT, then within WM_ERASEBKGND just return 0. Within the PAINTSTRUCT struct passed to WM_PAINT then the fErase member will be TRUE.
i need the control been complety clear and then:
- if is transparent, don't show the brush color;
- if isn't transparent, draw the brush color.
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
Cambalinho
i'm doing it:
Code:
case WM_ERASEBKGND:
{
if(inst->blnTransparent==true)
{
SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND,(LONG_PTR)GetStockObject(NULL_BRUSH));
}
else
{
SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND,(LONG_PTR)CreateSolidBrush(inst->clrBackColor));
}
DefWindowProc(hwnd, msg, wParam, lParam);
}
break;
but i'm doing 1 error. why isn't transparent?
You are creating a new solid brush every time blnTransparent is not true but are not deleting it - so you have a resource leak.
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
2kaud
You are creating a new solid brush every time blnTransparent is not true but are not deleting it - so you have a resource leak.
that's true:
Code:
case WM_ERASEBKGND:
{
HBRUSH bkBrush;
if(inst->blnTransparent==true)
{
bkBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND,NULL);
}
else
{
bkBrush=CreateSolidBrush(inst->clrBackColor);
SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND,(LONG_PTR)bkBrush);
}
DeleteBrush(bkBrush);
DefWindowProc(hwnd, msg, wParam, lParam);
}
break;
but why the 1st brush isn't transparent?
(i must clear the control and show a transparent brush)
Re: [win32] - avoid flicker and do a correct redraw
Quote:
if is transparent, don't show the brush color;
Then don't erase the background. You can't erase the background to transparent - nor set a solid brush as transparent. What have you got set as the background?
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
2kaud
Then don't erase the background. You can't erase the background to transparent - nor set a solid brush as transparent. What have you got set as the background?
in these case i'm doing wrong :(
why WS_CLIPCHILDREN style on parent window(is what avoid the flicker), don't let the child control been clear?
Re: [win32] - avoid flicker and do a correct redraw
Unless you are using custom child controls, the extended windows style WS_EX_TRANSPARENT should deal with siblings standard controls. In WM_PAINT, SetBkMode() is used to set transparency for text, hatched brushes and pen styles that are not solid lines.
Transparency just means that the background shows through rather than being the usual opaque. So what background do you want?
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
2kaud
Unless you are using custom child controls, the extended windows style WS_EX_TRANSPARENT should deal with siblings standard controls. In WM_PAINT, SetBkMode() is used to set transparency for text, hatched brushes and pen styles that are not solid lines.
Transparency just means that the background shows through rather than being the usual opaque. So what background do you want?
depending the blnTransparent been true or false, i need show it transparent or with a brush with clrBackcolor(respectible)
Re: [win32] - avoid flicker and do a correct redraw
You can't show a background as 'transparent'. You either set a background or you leave the existing background. Transparency is simply setting a main background then first painting the window siblings (without changing the background) then that window (without changing the background). The window appears transparent because the bits of underlying sibling windows have already been painted.
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
2kaud
You can't show a background as 'transparent'. You either set a background or you leave the existing background. Transparency is simply setting a main background then first painting the window siblings (without changing the background) then that window (without changing the background). The window appears transparent because the bits of underlying sibling windows have already been painted.
i can make it transparent, but without the WS_CLIPCHILDREN. without it, i have flickers :(
Re: [win32] - avoid flicker and do a correct redraw
resolving flickering
and transparency are totally unrelated issues.
if you want to solve flickering
- disable the WM_ERASEBKGND (check, you're doing this)
- in WM_PAINT, draw both the background and the foreground in such a way that you never erase what was there before. This is typically, but not necessarily achieved by painting background and foreground to a bitmap, and then blitting the resultant bitmap as a single operation to the screen DC.
But there are... MANY... MANY... other ways to achieve the desired effect by other means, all depending on what exactly you are painting on top of what.
Re: [win32] - avoid flicker and do a correct redraw
Quote:
Originally Posted by
Cambalinho
i can make it transparent, but without the WS_CLIPCHILDREN. without it, i have flickers :(
WS_CLIPCHILDREN excludes the area occupied by child windows when drawing occurs within the parent window. As you have discovered - and we all now know - this has an impact upon transparency using WS_EX_TRANSPARENT. Oh the joys of Windows APIs! :rolleyes:
Back to the drawing board! :cry:
Re: [win32] - avoid flicker and do a correct redraw
let me ask 1 thing: using the WS_CLIPCHILDREN, why the control ins't clean before use the WM_PAINT?(i'm testing these too)