• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1030
  • Last Modified:

flicker free drawing & smooth scrolling!!!

hi friends! i wanna make an active-x control for drawing GANT charts,
so i want some good ideas from u to implement it. Can i use report style of ListView for it, if yes, how can i draw in it. If i dont use CListView & draw all colomns by my self by using 'LineTo' in OnDraw() function of View class, how can i produce FLICKER FREE DRAWING & SMOOTH SCROLLING.
i know a way of using MemoryDC & bit blitting but it make it very slow.
i hope u will tell me the way out.
thanks!!!!
0
HaroonSiddiqi
Asked:
HaroonSiddiqi
1 Solution
 
JPMartineauCommented:
You can either derive an object from CListCtrl and override its WM_PAINT message handler, or you can use the CListCtrl and respond to custom draw notifications. The difference between both is that owner-draw is handled by the control itself, while custom draw delegates the drawing to the parent window.

You can override the WM_EraseBackground so that the parent's implementation of it will not be called. This should be done whenever you do owner draw stuff, since you paint over the DC anyways. This will prevent some of the flicker. Whoever the only true way I achieved this is by using custom draw and a memory DC. I never experienced performance issues with this method...

If you produce flicker-free drawing, scrolling should be smooth, as it is a specific use of the drawing.

If you use custom Draw, you might also want to create these functions for the window that contains the list control to avoid modifying the contents of the window while the drawing occurs...

void CDialog::LockDraw()
{
      if(m_iLockDrawCount++ == 0)
            m_listCtrl.SetRedraw(FALSE);
}

void CDialog::UnlockDraw()
{
      if(--m_iLockDrawCount == 0)
            m_listCtrl.SetRedraw(TRUE);
}

ex:

LockDraw();
m_listCtrl.InsertItem(...);
UnlockDraw();

Hope this helps...

JPM
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now