From: AliR on
Hi Everyone,

I have found an intersting bug, and I am not sure where to look for a
solution. I have a form view with a list contrl that gets updated every 5
seconds or so using a Timer. In the code that updates the List control I
use LockWindowUpdate and UnlockWindowUpdate because the list control draws
very slowly.
Now if I minimize my application the desktop starts flashing!
To recreate the problem, I used a Dialog application, added a List control,
with the following code:

BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(100,1000,NULL);
return TRUE;
}

void CMyDialog::OnTimer(int nIDEvent)
{
if (nIDEvent == 100)
{
m_List.LockWindowUpdate();
m_List.UnlockWindowUpdate();
}
}

As soon a I minimize the dialog the desktop starts flashing. Has anyone run
into this before?

I have even tried it with an Edit control and the same thing happens.

I am not sure if it is my computer or it is a bug!

AliR.


From: Joseph M. Newcomer on
You should probably not be using LockWindowUpdate, but using SetRedraw(FALSE) and
SetRedraw(TRUE);

Use of #define is considered tasteful, instead of silly hardwired values like "100".
joe

On Thu, 24 Feb 2005 16:10:24 GMT, "AliR" <AliR(a)newsgroup.nospam> wrote:

>Hi Everyone,
>
>I have found an intersting bug, and I am not sure where to look for a
>solution. I have a form view with a list contrl that gets updated every 5
>seconds or so using a Timer. In the code that updates the List control I
>use LockWindowUpdate and UnlockWindowUpdate because the list control draws
>very slowly.
>Now if I minimize my application the desktop starts flashing!
>To recreate the problem, I used a Dialog application, added a List control,
>with the following code:
>
>BOOL CMyDlg::OnInitDialog()
>{
> CDialog::OnInitDialog();
> SetTimer(100,1000,NULL);
> return TRUE;
>}
>
>void CMyDialog::OnTimer(int nIDEvent)
>{
> if (nIDEvent == 100)
> {
> m_List.LockWindowUpdate();
> m_List.UnlockWindowUpdate();
> }
>}
>
>As soon a I minimize the dialog the desktop starts flashing. Has anyone run
>into this before?
>
>I have even tried it with an Edit control and the same thing happens.
>
>I am not sure if it is my computer or it is a bug!
>
>AliR.
>

Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: "CheckAbdoul" <checkabdoul at mvps dot on

"AliR" <AliR(a)newsgroup.nospam> wrote in message
news:Q%mTd.40923$wi2.16644(a)newssvr11.news.prodigy.com...
> Hi Everyone,
>
> I have found an intersting bug, and I am not sure where to look for a
> solution. I have a form view with a list contrl that gets updated every 5
> seconds or so using a Timer. In the code that updates the List control I
> use LockWindowUpdate and UnlockWindowUpdate because the list control draws
> very slowly.
> Now if I minimize my application the desktop starts flashing!
> To recreate the problem, I used a Dialog application, added a List
control,
> with the following code:
>
> BOOL CMyDlg::OnInitDialog()
> {
> CDialog::OnInitDialog();
> SetTimer(100,1000,NULL);
> return TRUE;
> }
>
> void CMyDialog::OnTimer(int nIDEvent)
> {
> if (nIDEvent == 100)
> {
> m_List.LockWindowUpdate();
> m_List.UnlockWindowUpdate();
> }
> }
>
> As soon a I minimize the dialog the desktop starts flashing. Has anyone
run
> into this before?
>
> I have even tried it with an Edit control and the same thing happens.
>
> I am not sure if it is my computer or it is a bug!
>
> AliR.
>
>

Not sure why the flickering occurs ( may be LockWindowUpdate() should be
used only for top level windows ?? ) , but how about the following change

if (nIDEvent == 100 && !IsIconic() )
{
m_List.LockWindowUpdate();
m_List.UnlockWindowUpdate();
}

--
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------


From: AliR on
The IsIconic would fix this example. But the real code is in a CFormView in
an MDI application. The view wouldn't know anything about the mainframe
being minimized. I switched to WM_SETREDRAW, and things are fine.
But I am just amazed that this bug even exists in the SDK.

AliR.

"CheckAbdoul" <checkabdoul at mvps dot org> wrote in message
news:%23nADHRqGFHA.3088(a)tk2msftngp13.phx.gbl...
>
> "AliR" <AliR(a)newsgroup.nospam> wrote in message
> news:Q%mTd.40923$wi2.16644(a)newssvr11.news.prodigy.com...
> > Hi Everyone,
> >
> > I have found an intersting bug, and I am not sure where to look for a
> > solution. I have a form view with a list contrl that gets updated every
5
> > seconds or so using a Timer. In the code that updates the List control
I
> > use LockWindowUpdate and UnlockWindowUpdate because the list control
draws
> > very slowly.
> > Now if I minimize my application the desktop starts flashing!
> > To recreate the problem, I used a Dialog application, added a List
> control,
> > with the following code:
> >
> > BOOL CMyDlg::OnInitDialog()
> > {
> > CDialog::OnInitDialog();
> > SetTimer(100,1000,NULL);
> > return TRUE;
> > }
> >
> > void CMyDialog::OnTimer(int nIDEvent)
> > {
> > if (nIDEvent == 100)
> > {
> > m_List.LockWindowUpdate();
> > m_List.UnlockWindowUpdate();
> > }
> > }
> >
> > As soon a I minimize the dialog the desktop starts flashing. Has anyone
> run
> > into this before?
> >
> > I have even tried it with an Edit control and the same thing happens.
> >
> > I am not sure if it is my computer or it is a bug!
> >
> > AliR.
> >
> >
>
> Not sure why the flickering occurs ( may be LockWindowUpdate() should be
> used only for top level windows ?? ) , but how about the following change
>
> if (nIDEvent == 100 && !IsIconic() )
> {
> m_List.LockWindowUpdate();
> m_List.UnlockWindowUpdate();
> }
>
> --
> Cheers
> Check Abdoul [VC++ MVP]
> -----------------------------------
>
>


From: AliR on
Relax Joe, I am not demonstrating code edicts. It's just an example, in case
someone at Microsoft wants to reproduce this bug and fix it.



But you are right SetRedraw() does not have the same side-effect as
LockWindowUpdate().



AliR.

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:ii6s11hm1lpt0rvk4oa8u02uie8mpoeo1t(a)4ax.com...
> You should probably not be using LockWindowUpdate, but using
SetRedraw(FALSE) and
> SetRedraw(TRUE);
>
> Use of #define is considered tasteful, instead of silly hardwired values
like "100".
> joe
>
> On Thu, 24 Feb 2005 16:10:24 GMT, "AliR" <AliR(a)newsgroup.nospam> wrote:
>
> >Hi Everyone,
> >
> >I have found an intersting bug, and I am not sure where to look for a
> >solution. I have a form view with a list contrl that gets updated every 5
> >seconds or so using a Timer. In the code that updates the List control I
> >use LockWindowUpdate and UnlockWindowUpdate because the list control
draws
> >very slowly.
> >Now if I minimize my application the desktop starts flashing!
> >To recreate the problem, I used a Dialog application, added a List
control,
> >with the following code:
> >
> >BOOL CMyDlg::OnInitDialog()
> >{
> > CDialog::OnInitDialog();
> > SetTimer(100,1000,NULL);
> > return TRUE;
> >}
> >
> >void CMyDialog::OnTimer(int nIDEvent)
> >{
> > if (nIDEvent == 100)
> > {
> > m_List.LockWindowUpdate();
> > m_List.UnlockWindowUpdate();
> > }
> >}
> >
> >As soon a I minimize the dialog the desktop starts flashing. Has anyone
run
> >into this before?
> >
> >I have even tried it with an Edit control and the same thing happens.
> >
> >I am not sure if it is my computer or it is a bug!
> >
> >AliR.
> >
>
> Joseph M. Newcomer [MVP]
> email: newcomer(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm