-
March 30th, 2015, 05:13 AM
#16
Re: [win32] - avoid flicker and do a correct redraw
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.
Best regards,
Igor
-
March 30th, 2015, 05:24 AM
#17
Re: [win32] - avoid flicker and do a correct redraw
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
-
March 30th, 2015, 05:48 AM
#18
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 30th, 2015, 05:52 AM
#19
Re: [win32] - avoid flicker and do a correct redraw
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.
-
March 30th, 2015, 06:07 AM
#20
Re: [win32] - avoid flicker and do a correct redraw
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 30th, 2015, 06:22 AM
#21
Re: [win32] - avoid flicker and do a correct redraw
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)
-
March 30th, 2015, 08:12 AM
#22
Re: [win32] - avoid flicker and do a correct redraw
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?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 30th, 2015, 08:57 AM
#23
Re: [win32] - avoid flicker and do a correct redraw
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?
-
March 30th, 2015, 09:41 AM
#24
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?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 30th, 2015, 09:45 AM
#25
Re: [win32] - avoid flicker and do a correct redraw
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)
-
March 30th, 2015, 09:56 AM
#26
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 30th, 2015, 10:00 AM
#27
Re: [win32] - avoid flicker and do a correct redraw
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
-
March 30th, 2015, 01:15 PM
#28
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.
-
March 31st, 2015, 06:54 AM
#29
Re: [win32] - avoid flicker and do a correct redraw
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 31st, 2015, 11:03 AM
#30
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|