ToolTipsFactory

Object Model - Common Methods and Functions - RestoreOriginalLayout

This method resets the tooltip component layout to the state before the last layout-override occurred.

[Visual Basic]
Public Sub RestoreOriginalLayout()
[C#]
public void RestoreOriginalLayout();

Parameters

none

Description

RestoreOriginalLayout() resets the tooltip component layout to the state before the last layout-override occurred. The use of this method makes only sense, if ApplyOverrides() has been called before for the specific component (see the corresponding section in "Component-specific members"). It is ApplyOverrides() which saves the current layout for the component before the override-values are applied. This saved layout is later restored by a call to RestoreOriginalLayout(). Without a previously occurred call to ApplyOverrides() the restored layout could be somehow random.

This ApplyOverrides()-RestoreOriginalLayout()-cycle happens automatically for the override-values defined through the Override-property of a control (see Provided Properties). Whenever the cursor enters (MouseEnter-event) the client-area of a control which has properties provided by a tooltip component, a call to ApplyOverrides() occurs, but only if there are applicable override-values present. As soon as the cursor leaves (MouseLeave-event) the client-area of the control, RestoreOriginalLayout() will be called and the previously saved default layout for the component is restored. 

This shows, how tightly the ApplyOverrides()- and RestoreOriginalLayout()-methods are coupled to the MouseEnter- and MouseLeave-events of the controls for which the tooltip components provide the tooltip-properties. Therefore, if these two methods are to be used in an application, great care has to be taken in order to not interfere with this sequence. Nested calls of ApplyOverrides()- and RestoreOriginalLayout()-methods will not throw any exceptions, but the tooltip-appearance on a form could quickly turn into a random mess, especially when many controls on the form operate with differing override-layouts.

Example

The following code saves the override-layout defined for the Ok-button (cmdOk) into a standard ToolTipsFactory tooltip layout-file. Because the Override-objects do not provide such an option, we have to use a work-around which makes use of the possibilities provided by the methods discussed above. Before we can save the override-layout of cmdOk to file, we have to apply it first to the tooltip-component that provides the tooltips. Only then we can save the component's layout to file. Now, in order to get back the default layout for the tooltip component, we just have to call RestoreOriginalLayout()

Private Sub Button1_Click(ByVal sender As System.Object, _

                          ByVal e As System.EventArgs) Handles Button1.Click

'We assign the override-object to a variable

'to make the code more readable...

Dim myOverrides As MultiLineTTOverride

myOverrides = Me.MultiLine1.GetMultiLineToolTip(Me.cmdOk).Override

 

'Apply the Override-layout to the component...

Me.MultiLine1.ApplyOverrides(myOverrides)

'Save the (overridden) layout into a file....

Me.MultiLine1.SaveLayout("C:\Temp\OkButtonTTOverride.mtt")

'This restores the previously active layout...

Me.MultiLine1.RestoreOriginalLayout()

End Sub

In order to make this code work correctly, it is important that there are no override-values defined for Button1, because moving the mouse over Button1 to click on it, would apply this override-values first, what would lead exactly to the implicitly nested execution of the ApplyOverrides()- and RestoreOriginalLayout()-methods which should be avoided.