Hi guys,
does anyone know how do i insert another device context for the cube without flickering that much and to make it play more smooth ?
i tried many times to make another one even with PatBlt and doesn't work in any way..
thanks.
Hi R0ger,
I've no time to study your code right now: do you paint to a memory DC? I.e. double buffering etc?
i've painted the cube to the main device context (the hdc one from the WM_INITDIALOG).
I would double buffer everything.
- Paint background color
- Paint cube points for rotating cube
- Paint text at x position for scrolling text with specific font and color
- Then BitBlt that to the main dc
It is an ideal candidate for a custom control, so could create a custom control and have specific 'properties' to set, back color, text color, cube color, speed of animation, animation direction? speed of text scrolling, direction of text scroll: left to right (centered), down to up (centered), or possible others, etc.
Reading code, there is double buffering.
Perhaps must be invalidate instead of redraw?
Capture background erase?
invoke SetTimer, hWnd, 1, 10, NULL
invoke SetTimer, hWnd, 2, 15, NULL
So, every 30ms the window gets redrawn. 30ms, because of the
invoke Sleep, 20 in the WM_PAINT.
Maybe here is the root of the evil ... ?
Quote from: HSE on August 27, 2022, 09:04:03 AM
Capture background erase?
This could also be the cause (and more likely).
The Sleep 20 seems to be necessary to make the image rotate.
Yours are valid reasons, HSE & Greenhorn, but sometimes there is one more reason: painting is slow. Check the Coloured rounded buttons (http://masm32.com/board/index.php?topic=10292.msg112580#msg112580) example. It's double-buffered, but especially the controls on the left (using images) tend to flicker. And if you resize the whole thing, it becomes obvious that cpu and gpu have to work hard... if you have an example where a dialog with many controls can be flicker-free resized, I'd be curious to see it :cool:
Quote from: jj2007 on August 27, 2022, 06:42:50 PM
if you have an example where a dialog with many controls can be flicker-free resized
I normally would set wc.style to 0 or drop shadow style and make sure no CS_HREDRAW or CS_VREDRAW is used:
mov wc.style, CS_DROPSHADOW
And set WS_CLIPCHILDREN with the dialog style
That seems to allow flicker free resizing of dialog with child controls.
Quote from: fearless on August 27, 2022, 10:53:18 PMI normally would set wc.style to 0 or drop shadow style and make sure no CS_HREDRAW or CS_VREDRAW is used:
mov wc.style, CS_DROPSHADOW
And set WS_CLIPCHILDREN with the dialog style
That seems to allow flicker free resizing of dialog with child controls.
Sure. That's what I do. Show me a flicker-free example of a resizable dialog with many resizable controls. Seriously, I am curious - maybe I am really doing something wrong.
JJ,
style = CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW
and
mrm wc.hbrBackground, 0
Give it a whirl.
Roger,
I had a quick look at the code you posted and its a dialog, not a CreateWindowEx and I don't know if you can set the styles in a dialog as well as a full window. I would be inclined to set the display in a window where you have the WNDCLASSEX styles that you can set.
I have seen the code and I have not understand anything. It seems to be some kind of unassembly product.
Quote from: hutch-- on August 28, 2022, 12:47:14 AM
JJ,
style = CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW
and
mrm wc.hbrBackground, 0
Give it a whirl.
No difference. Btw and wc.hbrBackground, 0 is shorter ;-)
well i have reviewed all your answers.
tried removing the RedrawWindow and starts to overdraw all the cube lines. :P
my concept of this aboutbox is to create a text scroller to draw altogether with the cube animation without flickering or overdrawing on the black background.
well it seems like there is nothing to do with this cube. i've got to say that i will be giving up continuing to fix the Gdi problem. whenever i try to fix every device context value to this cube it kept getting worse for odd reasons.
Roger,
I suggested that you don't use a dialog but use a CreateWindowEx() as you have more adjustments with a proper window. A dialog is a limited class window for basically simple tasks. Anything serious is best done in a window.
(https://i.imgur.com/tvzx15u.png)
day 9000 of the cube effect - finally got the cube right and without flickering (not rly, but very very less now but it's acceptable) !
the solution was to create a device context for the static control i've inserted (GetDlgItem,xWnd,10), then create the bitmap for the cube, and then apply it with SelectObject.
what i forgot was that the ebp was saved to the rect variable so for that I have applied it with GetClientRect for the window handle to make the cube working without overdrawing.
at the moment i made the cube only if i want to insert it on the main form. i will see what i can do with the vertical scroller one as well.