|
Thanks David, that sounds like the ideal method to use
|
|
|
|
|
The controls still flicker
my overall process is:
<br />
this->SetRedraw(FALSE);<br />
<br />
pDC = this->GetDC();<br />
targetDC.CreateCompatibleDC(pDC);<br />
pOldTargetBmp = targetDC.SelectObject(&m_BmpTarget);<br />
targetDC.PatBlt(X,Y,iWidth,iHeight,DSTINVERT);<br />
targetDC.SelectObject(pOldTargetBmp);<br />
targetDC.DeleteDC();<br />
ReleaseDC(pDC);<br />
m_DialogStaticImage.SetBitmap(HBITMAP(m_BmpTarget));<br />
<br />
m_staticText.RedrawWindow(NULL,NULL,RDW_UPDATENOW);<br />
m_editBox.RedrawWindow(NULL,NULL,RDW_FRAME+RDW_INVALIDATE+RDW_UPDATENOW);<br />
.<br />
. about 15 controls<br />
.<br />
<br />
this->SetRedraw(TRUE);<br />
<br />
this->Invalidate(FALSE);<br />
<br />
this->UpdateWindow();<br />
I was surprised that it would still flicker; I was hoping that all the graphics operations were done in memory, then simply shown when UpdateWindow was called - thus avoiding flicker.
|
|
|
|
|
I don't believe WM_SETREDRAW is supported by dialogs. You can try it on the individual controls though
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
abiemann wrote: I was surprised that it would still flicker; I was hoping that all the graphics operations were done in memory, then simply shown when UpdateWindow was called - thus avoiding flicker.
Nope. Looking more closely at your code, the only way you'll be able to prevent flicker
is to do the drawing offscreen yourself, then blt the whole thing to the dialog.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Indeed, I was hoping that SetRedraw would implement double-buffering easily... but I found a good CP link that I'm studying now:
http://www.codeproject.com/gdi/flicker_free_intro.asp
EDIT:
I've compiled the "flicker free" project under VS8 and I see that the "Draw Area" flickers.
|
|
|
|
|
abiemann wrote: //no need to erase background since SetBitmap covered everything up
this->Invalidate(FALSE);
You have a static control that is used to display a bitmap. Yes? Is it overlapping the other controls such that they are requiring this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, I have a static bitmap covering the entire Dialog window. Other controls (Buttons, Edit boxes) are ontop of this bitmap.
|
|
|
|
|
So are you rendering this image in the dialog's OnEraseBkgnd() method?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
no I haven't touched the OnEraseBkgnd() or OnPaint methods.
The code above is processed whenever the user presses a key or lets go of a key.
(I haven't worked much with MFC, so I'm still learning)
|
|
|
|
|
abiemann wrote: no I haven't touched the OnEraseBkgnd()...
Put your bitmap-rendering code in there and note the difference.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David,
I've made the change and the background bitmap doesn't flicker at all, however, the controls ontop of the bitmap still flicker.
This is the change I've made:
KeyHandler now triggers OnEraseBkgnd instead of performing PatBlt
When the user presses a key, the key's number is stored in a private member variable of the Dialog.
To subsequently make it update the background image, the Dialogs' key handler performs :
this->Invalidate(TRUE);<br />
this->UpdateWindow();
OnEraseBkgnd now does the PatBlt of the static image behind the controls
Next, OnEraseBkgnd(CDC* pDC) is processed.
this handler first checks that a key was pressed, if so, it performs the targetDC.PatBlt (I just use the pDC that's passed in) then it returns TRUE.
If no key was pressed then I let this handler perform the default CDialog::OnEraseBkgnd(pDC)
After this change I noticed that the individual controls no longer need their RedrawWindow() called, however, they still flicker (but the background static image doesn't flicker at all now).
I've also removed the SetRedraw() calls
-- modified at 19:14 Thursday 6th September, 2007
|
|
|
|
|
Did you try adding the WS_CLIPCHILDREN style to the dialog as suggested by WalderMort?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In other words, it works but it doesn't work.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Do you want to set some properties for a control?
|
|
|
|
|
No the properties won't change, but I'm calling quite a lot of RedrawWindow methods for the controls on the Dialog and I'm noticing that the bigger the controls, and the more there are, the more flicker I'm seeing.
|
|
|
|
|
did you try the WS_CLIP_CHILDREN flag? This alone would reduce a hell of a lot of flicker.
|
|
|
|
|
Good point! For whatever reason, when I see bitmap background code
I think skin, transparent controls, etc. For normal controls WS_CLIPCHILDREN
will work great!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've tried the following within ::OnInitDialog()
this->ModifyStyle(0, WS_CLIPCHILDREN);
but then nothing in the Dialog updates
|
|
|
|
|
Can someone tell me how to display the "inifinity symbol" inside of a listview item. For example, i was just using Azureus (bit torrent client) and noticed that they used this symbol under its ETA column. How do i do this?
Thanks
|
|
|
|
|
The string literal is:
"\xEC" (ASCII)
L"\x221E" (Unicode)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
There are two basic methods they might be using.
1. Font selection. They might have set the list ctrl font, or at least the font used when painting that part of the list ctrl, to a symbol font with an infinity symbol and then put ordinary text in the control corresponding to the charatcer number for the infinity symbol in the symbol font.
2. Overriding painting. They might have overriden aspects of the list control either using the custom draw, or owner draw approaches, probably custom draw and then be simply drawn the infinity symbol with a bit of GDI code, probably using a cached bitmap.
Search around for Custom Draw examples and Symbols fonts like WingDings. You'll have it cracked in no time.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Does anyone know where I can find a "Thumb Wheel" control?
It looks like a dial turned on its side with ridges on its edge (like a quarter) and it would be used like a slider to adjust a value.
A picture of a GUI that shows what I am looking for can be found here:
http://www.steptools.com/products/stviewer/images/st-viewer.gif[^]
Beth
-- modified at 10:31 Thursday 6th September, 2007
|
|
|
|
|
bscaer wrote: Does anyone know where I can find
You mean besides the internet?
|
|
|
|
|
In the documentation maybe ?
|
|
|
|
|
Did you see Button section on the codeproject?
|
|
|
|