4

One is supposed to use double buffering when running locally, but to not use double buffering when the window is on a remote session, if one wants to have the best performance of each mode.

The ListView control has an extended style, LVS_EX_DOUBLEBUFFER, which automatically double buffers the contents of the ListView.

Does one need to register to be notified on changes between local and remote sessions, and update this flag accordingly? Or does the ListView do this automatically?

Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
  • 1
    FWIW, the flag doesn't just change how the control is painted; it can change the behaviour as well. Some of the newer listview modes flat-out do not work without the flag (yet more bugs in the awful common controls code which Microsoft only seem to write/test for their own narrow uses). So unless you're seeing performance problems on remote desktop I would avoid changing the flag in different situations, just to reduce the chance of surprises. Just my 2 cents, though! – Leo Davidson Jan 03 '11 at 22:14
  • @Hans Passant: I just am trying to understand how a blog post that talks about general painting applies to a listview control, the painting of which I have no control over. If not knowing why/how that applies makes me obtuse than fine. For the record I had +1'd your answer. – Billy ONeal Jan 04 '11 at 02:01
  • Are you asking if the LVS_EX_DOUBLEBUFFER style is removed from the ListView when the app is run in a remote session? If so, you ought to be able to track this sort of thing. – Chris O Jan 06 '11 at 21:52
  • @Chris: No, I know the style isn't removed, because other things are turned on than just double buffering with that flag. But the drawing could be done without using double buffering on remote sessions implicitly by the control. – Billy ONeal Jan 06 '11 at 21:53

1 Answers1

5

The ListView does not automatically adjust itself to whether you're running remote or local. It respects the value of the extended style flags that you set when the control is created; if you set LVS_EX_DOUBLEBUFFER then the display will be double buffered, and if you don't it won't. I'm sure Raymond Chen would agree that any other behavior would be a bug.

You can change the state of the flag at any time with LVM_SETEXTENDEDLISTVIEWSTYLE:

SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER, isRemote ? 0 : LVS_EX_DOUBLEBUFFER);

Tthe next article after your linked one shows how to get notified when the display changes between local and remote: http://blogs.msdn.com/b/oldnewthing/archive/2006/01/04/509194.aspx

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622