?
Solved

ClistCtrl Sorting Header Refresh

Posted on 1998-05-17
8
Medium Priority
?
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 4

Accepted Solution

by:
piano_boxer earned 600 total points
ID: 1311659
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
ID: 1311660
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
ID: 1311661
Thanks.

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


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:piano_boxer
ID: 1311662
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
 

Author Comment

by:tal031697
ID: 1311663
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
ID: 1311664
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
ID: 1311665
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
ID: 1311666
Could you post the code for 'delete sorting headers' and 'put new sorting headers' so that I can try some solutions?
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

764 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