Solved

ClistCtrl Sorting Header Refresh

Posted on 1998-05-17
8
375 Views
Last Modified: 2013-11-20
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
Comment
Question by:tal031697
  • 5
  • 3
8 Comments
 
LVL 4

Accepted Solution

by:
piano_boxer earned 200 total points
Comment Utility
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
 
LVL 4

Expert Comment

by:piano_boxer
Comment Utility
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
 

Author Comment

by:tal031697
Comment Utility
Thanks.

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


0
 
LVL 4

Expert Comment

by:piano_boxer
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:tal031697
Comment Utility
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
 
LVL 4

Expert Comment

by:piano_boxer
Comment Utility
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
 

Author Comment

by:tal031697
Comment Utility
Nop!, it didn't work.

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

... 8-(
0
 
LVL 4

Expert Comment

by:piano_boxer
Comment Utility
Could you post the code for 'delete sorting headers' and 'put new sorting headers' so that I can try some solutions?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now