Solved

ClistCtrl Sorting Header Refresh

Posted on 1998-05-17
8
397 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

791 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