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

ClistCtrl Sorting Header Refresh

I need to change ClistCtrl sorting headers from time to time
I tried to:

1. SetRedraw(FALSE)
2. delete sorting headers
3. put new sorting headers
3. SetRedraw(TRUE)

Problem: I allways see headers being deleted
and drawn back again, How to hide these refresh????

but I still see
0
tal031697
Asked:
tal031697
  • 5
  • 3
1 Solution
 
piano_boxerCommented:
When you use the SetRedraw() function, you supresses drawing when the windows receives a WM_PAINT message, and it does not redraw what needs to be drawn after a SetRedraw(TRUE). Normaly you have to invalidate the client area after the SetRedraw() i order to see changes in a control.

I'll suggest that you try using the LockWindowUpdate()/UnlockWindowsUpdate() pair instead. When you call UnlockWindowUpdate(), windows will send the needed WM_PAINT messages to the windows automaticly.

If you still have the problem of seeing headers being deleted, try moving the UnlockWindowUpdate() call into a private message handler, so you can delay the update until all messages currently in the queue has been handled.

#define WM_MY_MESSAGE WM_APP+1

MyDrawFunction()
{
    ...
    LockWindowUpdate();
    // delete sorting headers etc.
    PostMessage(WM_MY_MESSAGE);
}

LRESULT CMyClass::MyHandler(WPARAM, LPARAM)
{
    UnlockWindowUpdate();
    return 0;
}
0
 
piano_boxerCommented:
I forgot this:
In order to handle the WM_MY_MESSAGE message, and this line just above END_MESSAGE_MAP() in the .cpp file:

    ON_MESSAGE(WM_MY_MESSAGE, MyHandler)

and, add the declaration of the function to the class header

class MyClass...
{
    ...
    LRESULT MyHandler(WPARAM, LPARAM);
    ....
};
0
 
tal031697Author Commented:
Thanks.

LockWindowUpdate() did work!.
(I don't know why SetRedraw() didn't).


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
piano_boxerCommented:
One reason my be that SetRedraw() is supposed to be handled by the control by it self, and LockWindowUpdate() is handled internally by windows. (Windows queues up the WM_PAINT messages and sends them to the control when UnlockWindowUpdate() is called).
0
 
tal031697Author Commented:
Well...
After I swapped SetRedraw() with LockWindowUpdate()
I remembered why I did try this once back, but Abandoned this
approach.

!!!CALLING UnlockWindowUpdate() REFRESHES THE WHOLE DESKTOP!!!!

so right now I'm back with SetRedraw() again.

I still need help,any other suggestions....?
0
 
piano_boxerCommented:
Hmmm, yes I'v seen this as well.

Here is a possible other solution:

Subclass the CListCtrl add a handler for the WM_PAINT message. Add a flag that determines if WM_PAINT messages are to be handled. Set this flag to false when you update the listctrl, and to true when done and call Invalidate() on the entire ListCtrl.


void CMyListCtrl::OnPaint(CDC* pDC)
{
     if(m_bDoDraw)
     {
         CListCtrl::OnPaint(pDC);
     }
}
0
 
tal031697Author Commented:
Nop!, it didn't work.

even with the 'bDoDraw' flag I can sea the headers
being deleted and added.

... 8-(
0
 
piano_boxerCommented:
Could you post the code for 'delete sorting headers' and 'put new sorting headers' so that I can try some solutions?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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