Discussion:
mediaplayer generate WM_SYNCPAINT by every picture change - my programm flickers
(too old to reply)
fiversen
2013-07-16 08:28:44 UTC
Permalink
Hello,
there is a playlist with only pictures.
I play this playlist with MediaPlayer 12 on Windows 7.

My program flickers by every picture change - with Spy I found 'WM_SYNCPAINT'
receive my program.

I generate an example with 'MS Visual Studio 2008' MDI with standard settings.
Then I have side bars and so on.
Also this test program and the 'MS Visual Studio 2008' itself flickers.

But the 'IE' and 'Explorer' does not flicker !

--
Frank Iversen
Stephen Wolstenholme
2013-07-16 09:57:52 UTC
Permalink
On Tue, 16 Jul 2013 01:28:44 -0700 (PDT), fiversen
Post by fiversen
Hello,
there is a playlist with only pictures.
I play this playlist with MediaPlayer 12 on Windows 7.
My program flickers by every picture change - with Spy I found 'WM_SYNCPAINT'
receive my program.
I generate an example with 'MS Visual Studio 2008' MDI with standard settings.
Then I have side bars and so on.
Also this test program and the 'MS Visual Studio 2008' itself flickers.
But the 'IE' and 'Explorer' does not flicker !
Have a look at using CMemDC pDC(dc) in your OnDraw.

Steve
--
EasyNN-plus. Neural Networks plus. http://www.easynn.com
SwingNN. Forecast with Neural Networks. http://www.swingnn.com
JustNN. Just Neural Networks. http://www.justnn.com
fiversen
2013-07-17 13:54:09 UTC
Permalink
Post by Stephen Wolstenholme
Have a look at using CMemDC pDC(dc) in your OnDraw.
Steve
Hello Steve,

Do you have experiences with CMemDC ?

I our project we use VC7 (Visual Studio 2003) -
so I have to take CMemDC from 'Codeproject' or copy the code from VC9 ?

I have my own grafic-lib, MFC-based, in our project.

In some special cases I already use painting into a memory-dc, for example
to display dibs.

But I have to use this CMemDC in every Window in my hierachy of Windows/Controls ?
Then I have a good chance that flickering is gone.
---
Frank Iversen
Stephen Wolstenholme
2013-07-17 16:31:10 UTC
Permalink
On Wed, 17 Jul 2013 06:54:09 -0700 (PDT), fiversen
Post by fiversen
Post by Stephen Wolstenholme
Have a look at using CMemDC pDC(dc) in your OnDraw.
Steve
Hello Steve,
Do you have experiences with CMemDC ?
Yes.
Post by fiversen
I our project we use VC7 (Visual Studio 2003) -
so I have to take CMemDC from 'Codeproject' or copy the code from VC9 ?
I have my own grafic-lib, MFC-based, in our project.
See http://msdn.microsoft.com/en-us/library/cc308997(v=vs.90).aspx

Here's the code

void CEasyNNView::OnDraw(CDC* dc)
{
// To avoid flicker
CMemDC pDC(dc);
Post by fiversen
In some special cases I already use painting into a memory-dc, for example
to display dibs.
But I have to use this CMemDC in every Window in my hierachy of Windows/Controls ?
Then I have a good chance that flickering is gone.
My EasyNN-plus is a typical Doc/View project. All the Draw functions
are in CEasyNNView and so I only need CMemDC once in the main OnDraw
so it works everywhere as everything is in the View.

All my other projects use the same method.

Steve
--
EasyNN-plus. Neural Networks plus. http://www.easynn.com
SwingNN. Forecast with Neural Networks. http://www.swingnn.com
JustNN. Just Neural Networks. http://www.justnn.com
fiversen
2013-07-18 06:41:10 UTC
Permalink
Hello Steve,

I make a try with the example program 'ParticleTest' from codeproject - which use CMemDC.
I add an own control class to the project - and this class flickers.


I add an new Button class:
----------------------------------------
// CMyBut
class CMyBut : public CButton
{
DECLARE_DYNAMIC(CMyBut)
public:
CMyBut();
virtual ~CMyBut();
void DrawItem(LPDRAWITEMSTRUCT lpDIS);
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};

...
BEGIN_MESSAGE_MAP(CMyBut, CButton)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()



// CMyBut message handlers
void CMyBut::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC *pDC_ = CDC::FromHandle(lpDIS->hDC);
CMemDC pDC(pDC_);
CString s = "hallo";
RECT rClient = lpDIS->rcItem;
pDC->DrawText(s, &rClient, DT_CENTER);
}

BOOL CMyBut::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return FALSE;
}
----------------------------------------

I put one button in the view.
----
but1 = new CMyBut();
RECT rect = {80,0,180,40};
but1->Create(TEXT("HH"),WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, rect, this, 112233);
----

And the button flickers - what is wrong ?

The programm without the button - does not flicker in the view.
The menubar and the toolbar flickers - but that is OK for me and my program.

But the flickering from my own control 'CMyBut' is the problem.
---
Frank Iversen
fiversen
2013-07-22 07:40:43 UTC
Permalink
Post by fiversen
Hello Steve,
I make a try with the example program 'ParticleTest' from codeproject - which use CMemDC.
I add an own control class to the project - and this class flickers.
----------------------------------------
// CMyBut
class CMyBut : public CButton
{
DECLARE_DYNAMIC(CMyBut)
CMyBut();
virtual ~CMyBut();
void DrawItem(LPDRAWITEMSTRUCT lpDIS);
DECLARE_MESSAGE_MAP()
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
...
BEGIN_MESSAGE_MAP(CMyBut, CButton)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
// CMyBut message handlers
void CMyBut::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC *pDC_ = CDC::FromHandle(lpDIS->hDC);
CMemDC pDC(pDC_);
CString s = "hallo";
RECT rClient = lpDIS->rcItem;
pDC->DrawText(s, &rClient, DT_CENTER);
}
BOOL CMyBut::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return FALSE;
}
----------------------------------------
I put one button in the view.
----
but1 = new CMyBut();
RECT rect = {80,0,180,40};
but1->Create(TEXT("HH"),WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, rect, this, 112233);
----
And the button flickers - what is wrong ?
The programm without the button - does not flicker in the view.
The menubar and the toolbar flickers - but that is OK for me and my program.
But the flickering from my own control 'CMyBut' is the problem.
---
Frank Iversen
I download now 'Visual Studio 2012' - generate an program - and everything is
fine. No flickering.
But with my 'Visual Studio 2003' - I have these problems.
And I could not change - because, my program has to run also on WinNT computer.
--
Frank Iversen

Loading...