Double-buffering and Remote Connections

From RAD Studio
Jump to: navigation, search

Go Up to Working with Controls Index


According to recommended best practices, applications should not use double-buffering when they are being run via a remote desktop connection, because that requires the entire off-memory bitmap to be transferred via the remote desktop connection.

For that reason, since RAD Studio 11.1, TApplication has two new public properties and a new public event to handle single and double-buffering when applications are run via a remote or local connection.

The OnRemoteSessionChanged event handler is triggered when the session changes from local to remote or vice versa, and it can override the default behavior of updating InRemoteSession through its InRemoteSession var parameter.

The property InRemoteSession returns a boolean. It returns True if the current session is remote (i.e. when running through RDP) and False if it is local, assuming the OnRemoteSessionChanged event handler has not overridden its default behavior.

Finally, the property SingleBufferingInRemoteSessions default value is True, which causes all un-themed VCL controls to ignore their DoubleBuffered property if running in a remote session. If set to False, then un-themed controls will continue using double buffering in remote sessions.

On startup (in Run), the TApplication object checks whether the current session is a local or a remote session. It also gets notified when the session changes from local to remote or vice versa during program execution. The behavior when the session type is set at startup, or when it changes at runtime, is the same:

  1. The OnRemoteSessionChanged event fires with the new session state passed in a var parameter, so the user code can stop the change from being noticed if needed.
  2. Assuming the change has not been ‘hidden’ by the event handler, InRemoteSession is set to indicate if the current session is remote or not, so this property can be used by user code.

If InRemoteSession and SingleBufferingInRemoteSessions are both True, then VCL un-themed controls will ignore their DoubleBufferered property and use single buffering.

For themed controls and style hooks, code should only use double buffering if this evaluates to True:

DoubleBuffered and (not InRemoteSession or not SingleBufferingInRemoteSessions)

In other words, the control is set to use double buffering whether you are running in a local session, or you are in a remote session but the application developer wants double-buffering regardless.

See Also