Solved

ClistCtrl Sorting Header Refresh

Posted on 1998-05-17
8
394 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven archtype selection in eclipse 1 57
noX challenge 17 117
How to convert MFC::CString to UTF8 wchar_t* 10 211
x-bar in Google Sheets 2 55
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

809 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