Professional Documents
Culture Documents
Ebook Visual Studio Add Ins Succinctly 1St Edition Joe Booth Online PDF All Chapter
Ebook Visual Studio Add Ins Succinctly 1St Edition Joe Booth Online PDF All Chapter
https://ebookmeta.com/product/visual-studio-code-succinctly-1st-
edition-alessandro-del-sole/
https://ebookmeta.com/product/visual-studio-2015-succinctly-1st-
edition-alessandro-del-sole/
https://ebookmeta.com/product/visual-studio-2019-succinctly-1st-
edition-alessandro-del-sole/
https://ebookmeta.com/product/visual-studio-2022-succinctly-1st-
edition-alessandro-del-sole/
Visual Studio 2017 Succinctly 1st Edition Alessandro
Del Sole
https://ebookmeta.com/product/visual-studio-2017-succinctly-1st-
edition-alessandro-del-sole/
https://ebookmeta.com/product/visual-studio-2013-succinctly-1st-
edition-alessandro-del-sole/
https://ebookmeta.com/product/visual-studio-for-mac-succinctly-
alessandro-del-sole/
https://ebookmeta.com/product/visual-studio-for-mac-
succinctly-1st-edition-alessandro-del-sole/
https://ebookmeta.com/product/database-design-succinctly-joseph-
d-booth/
Copyright © 2013 by Syncfusion Inc.
2501 Aerial Center Parkway
Suite 200
Morrisville, NC 27560
USA
All rights reserved.
Free forever
Syncfusion will be working to produce books on several topics. The
books will always be free. Any updates we publish will also be free.
Tools needed
In order to be able to follow along with all of the examples in this
book, you will need Microsoft Visual Studio 2010 or Visual Studio
2012.
Many of the examples may work in older versions of Visual Studio as
well. The extensibility features have been in the IDE since Visual
Studio release in 1997. Note, however, that add-in modules are not
supported in Express editions of Visual Studio.
Formatting
Throughout the book, I have used several formatting conventions.
Note: Ideas and notes about the current topic.
{ handled = false;
IDTExtensibility2 Interface
This interface from the Extensibility namespace is used to hook your
add-in into the Visual Studio IDE. Although you will need to create
method implementations for each of the interface events, only the
OnConnection method is needed to get your add-in loaded into the
IDE.
IDTCommandTarget Interface
This interface from the EnvDTE namespace is used to process a
request from the IDE to run your add-in. The first parameter to both
methods is the command name, so your add-in code knows which (of
possibly multiple) commands Visual Studio is asking about.
Assemblies
When implementing an add-in module, the following assemblies need
to be included in the project:
Extensibility
EnvDTE
There are later versions of the EnvDTE assembly, which add on
additional classes, enums, and interfaces. If you choose to implement
an add-in that interacts with some of the later versions of Visual
Studio, you may need to include these assemblies in your project as
well:
EnvDTE: All versions of Visual Studio.
EnvDTE80: VS 2005 and above, interfaces typically ending with
2, e.g., EnvDTE2.
EnvDTE90: VS 2008 and above, interfaces ending with 3, e.g.,
HTMLWindow3.
EnvDTE100: VS 2010 and above.
When you create an add-in module using the Add-in Wizard, EnvDTE
and EnvDTE80 are typically included for you.
Wizard
Visual Studio’s New Project menu includes a wizard that will
generate most of the code you need to integrate your add-in into the
IDE. It will also generate the XML configuration file to allow the IDE
to find and load your add-in program. In the next chapter, we will use
this wizard to create the famous “Hello World” programming
example.
Chapter 2 Add-in “Hello
World”
Ever since the classic example in the book The C Programming
Language, the Hello World program has been the starting point for
new example programs. In this chapter, we will use the project
wizard to create a Visual Studio add-in version of this classic
example.
Note: All of the add-in modules we create in this book will start with
the wizard screen, so you will use it quite a bit. It is definitely a
time-saver compared to creating the implementation class code and
XML files manually.
Application hosts
The application hosts selection screen lets you indicate which host
applications can run your add-in. The options are:
Visual Studio
Visual Studio Macros
You can select either or both options. For the examples in this book,
we only need to select Visual Studio. The add-in XML file will contain
a <HostApplication> entry for each option selected. Most add-ins in
this book will have a UI component, so you shouldn't need to select
Visual Studio Macros.
Note: When using Visual Studio macros, interactive commands such
as LaunchWizard, OpenFile, etc. are not available. Other commands,
such as Quit, behave differently. For example, the Quit command
closes the Macros IDE and returns to Visual Studio, rather than
shutting down Visual Studio itself.
Add-in options
The add-in options screen helps control the generated code for your
add-in. In our examples, we are going to hook our class into the
Tools menu, so we select the first option to generate code on the
Connection method to load our add-in.
Figure 3: Add-in options
For debugging purposes, do not select the Load Add-in check box
when the host application starts. Ignoring this option will make
debugging easier. When you are ready to deploy your application, it is
an easy update to have your add-in load at start-up time.
About information
The About Information option lets you specify text to display in the
Visual Studio About box. When you run the About Visual Studio
menu option, the dialog box displays a list of all installed products,
including add-ins. When a user navigates to your add-in, any
information you provide will be displayed below the add-in list.
Summary
After you have filled in all of the information, a summary screen will
be shown:
Figure 4: Summary of add-in options
Double-check your selections, and if they all look okay, click Finish.
The wizard will work for a bit, and then produce a source file that
provides implementation methods for the IDTExtensibility2 and
IDTCommandTarget interfaces. It will also generate the XML
configuration files with your add-in load instructions.
Connection code
The code generated by the OnConnection method will look like the
following code sample (it may be different depending upon language
and settings):
public void OnConnection(object application, ext_ConnectMode connectMode,
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if(connectMode == ext_ConnectMode.ext_cm_UISetup)
((CommandBars.CommandBars)_applicationObject.CommandBars)["MenuB
ar"];
try
"HelloWorld", "HelloWorld",
(int)vsCommandStatus.vsCommandStatusSupported+
(int)vsCommandStatus.vsCommandStatusEnabled,
(int)vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
{ command.AddControl(toolsPopup.CommandBar, 1);
catch(System.ArgumentException)
}
The code checks to see the connect mode, and only installs the add-
in during the UI Setup call. This event is called during the splash
screen display when Visual Studio starts. OnConnection will be
called other times by Visual Studio, but there is no need to install the
command into the menu structure more than once.
The code will search the IDE’s command menu structure to find the
Tools menu, and then add your add-in to that menu. Most add-in
modules are placed on the Tools menu, but you are free to put them
anywhere you’d like.
Notice that the Application parameter is assigned to
_applicationObject, a private variable in the class. This variable
and the _addInInstance variable will allow your add-in code to
interact with various Visual Studio elements.
Note: The private class variables (_applicationObject and
_AddInInstance) are populated during the connection routine, so
they can be referred to during your Exec() and Query Status()
method calls.
Exec code
The generated code includes an Exec() method, which is where
you’ll add the code you want your add-in to execute. The Handled
variable, passed by reference, should be set to true to inform Visual
Studio that the particular command was processed by the add-in
method.
public void Exec(string commandName, vsCommandExecOption executeOption, ref o
bject varIn, ref object varOut, ref bool handled)
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
if(commandName == "HelloWorld.Connect.HelloWorld")
{
MessageBox.Show("Hello World!", "Hello" ,MessageBoxButtons.O
K);
handled = true;
return;
if(neededText == vsCommandStatusTextWanted.vsCommandStatusTextWantedNo
ne)
if(commandName == "HelloWorld.Connect.HelloWorld")
{ status = (vsCommandStatus)vsCommandStatus.vsCommandStatu
sSupported
|vsCommandStatus.vsCommandStatusEnable
d;
return;
Although the generated code provides the basic query result, you
may need to adjust the code to return a Not Supported status if the
add-in module should not be called during the debugging process of
Visual Studio.
If your code does not update the status variable, the default behavior
is to disable the menu or toolbar item.
Generated files
The wizard will generate the standard project files (Project and
AssemblyInfo.cs), as well as the source code files containing your
add-in code:
Connect.cs: Generated source code of the add-in.
<YourName>.AddIn: XML Configuration file for your add-in.
<YourName> - For Testing.AddIn: XML configuration file to
test your add-in.
Chapter 3 Hooking into the
IDE
In this chapter, we will look at the code to hook your add-in module
into Visual Studio, and see how you can find the menus and tool
windows to integrate with your add-in.
OnConnection Method
The OnConnection method is the method used to load your add-in
to the Visual Studio IDE. The wizard-generated code searches the
GUI controls for the Tools menu item and adds your add-in module
as the first item in that drop-down menu.
Tip: The wizard will run the connection code when ConnectMode is
ext_cm_UISetup. If you want the add-in module to attach to Tool
windows or other items, rather than the standard bar or menu, you
might want to wait to connect until ConnectMode is
ext_cm_AfterStartup to ensure the control you want to connect to is
created.
menuBarCommandBar = ((VisualStudio.CommandBars.CommandBars)
_applicationObject.CommandBars)["MenuBar"];
These next lines get the top menu bar and find the drop-down menu
associated with the string we specified previously. The menu control
is placed in the toolsPopup variable.
At this point, we have both the commands collection and the
toolsPopup GUI control. The following two lines add our add-in to
the command collection and the GUI control.
Command command = commands.AddNamedCommand2(_addInInstance, "HelloWorld", "He
llo World",
(int)vsCommandStatus.vsCommandStatusSupported+
(int)vsCommandStatus.vsCommandStatusEnabled,
(int)vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
command.AddControl(toolsPopup.CommandBar, 1);
(int)vsCommandStatus.vsCommandStatusSupported+
(int)vsCommandStatus.vsCommandStatusEnabled,
(int)vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
CmdBar.Controls.Count + 1);
cmdBarCtl.Caption = "HelloWorld";
Note that in this example, we are adding our module to the end of
the context menu, not the first item.
We will cover creating an add-in attached to the code window in
Chapter 12.
sb.AppendLine(cb.Name);
(int)vsCommandStatus.vsCommandStatusSupported +
(int)vsCommandStatus.vsCommandStatusEnabled);
{ if(cb.Name=="Standard")
{ stdCmdBar = cb;
break;
cmdBarBtn.Style = MsoButtonStyle.msoButtonIcon;
When adding to a toolbar, the MSOButton Style controls how the icon
appears on the toolbar. Some options are:
msoButtonIcon: Only show button.
msoButtonIconAndCaption: Show icon and caption text.
msoButtonIconAndWrapCaption: Show icon and wrap caption
text.
QueryStatus method
The QueryStatus method is called by Visual Studio whenever the
IDE wants to display your menu item. The method returns a status
code to the IDE, indicating whether the menu option is currently
supported or enabled. Visual Studio then uses this status to
determine the menu’s appearance and whether or not the user can
activate it.
Note that there is no Command Status Disabled option. If you
want your command to be disabled, simply do not update the status
variable, since the default status is disabled.
Other methods
There are other methods you can use to interact with Visual Studio.
While these methods are generated as empty modules by the wizard,
you might need them depending on your add-in’s behavior.
OnAddInsUpdate method
This method is called when add-ins are loaded into the Visual Studio
environment (as well as when the user clicks OK from the Add-in
Manager window). If your add-in is dependent on other add-ins,
you can check those dependencies during this method.
OnBeginShutdown method
When the user begins to close Visual Studio, this method is called.
This is the time to clean up any resources your add-in has created,
and save any user configuration information needed for the next time
the add-in is loaded.
OnDisconnection method
This method is called when Visual Studio unloads your add-in. If you
created or locked any resources when your add-in was connected,
this is the method you can use to unlock or free those resources.
On StartupComplete
This method is called once Visual Studio has completed the start-up
process. If your add-in is not loaded due to a component
dependency, you could install your add-in during this method to
ensure all components within Visual Studio have been loaded.
A few caveats
Before we dig in and design some add-in modules, there are a couple
of tips to keep in mind.
Tip: Avoid admin rights. When designing your add-in module, keep in
mind that starting with Windows Vista, Windows employs User
Account Control (UAC), which means it is very likely that Visual
Studio will not have admin rights.
Tip: Be careful about storing setting information in non-writable
folders or registry entries. Use the APPDATA system variable to find
a folder to store your settings.
By keeping the new security model in mind, you can prevent your
add-in modules from requiring Visual Studio to be run in admin mode
or seeing the access denied error.
Chapter 4 Application and
Add-in Objects
In this chapter, we will give a quick overview of the two main object
classes that Visual Studio provides to add-in authors to interact with
the IDE and with other add-ins.
Application object
The _applicationObject variable contains a DTE2 object reference,
which provides properties and methods to allow you to interact with
the Visual Studio IDE. Many of these properties will be explored in
subsequent chapters and examples. Some of the more commonly
used ones are:
ActiveDocument
This property returns a document object reference to the document
that currently has focus. The object contains information such as the
file name, whether the document has been saved, the selected text,
the kind of document being edited, etc.
ActiveWindow
This property returns a window object reference to the currently
active window. The window object contains the caption, kind of
window (tool or document window), the size (width and height), and
position (left and top). It also contains a reference to the document
currently in the window. You can do some basic manipulation of the
window, such as hiding it, moving it, closing it, etc.
Debugger
This property returns a reference to the debugger object, which
allows you to find out the current breakpoints, processes running on
the machine, the current program and process, etc. You can also
move to various code points, evaluate expressions, etc.
Documents
The Documents property is a collection of all currently open
documents within Visual Studio. Each individual item refers to a
document within the IDE. In Chapter 11, we will work with document
objects and their contents.
Edition
This property contains a string indicating the edition of Visual Studio,
i.e. Professional, Enterprise, etc. It can be useful if your add-in should
not be run in certain editions, for example.
ItemOperations
This property provides an object class that allows you to add new or
existing items to the current project. You can also navigate to a URL
and have the IDE open a browser window. We will use this object in
Chapter 15 when we generate source code files.
LocaleID
This property returns the locale in which the development IDE is
running. You might use this to customize your add-in for various
countries and languages.
MainWindow
This property returns the main parent window for the IDE. It contains
all of the various window properties and you can explore its
LinkedWindows collection to find the various other windows linked to
it.
Mode
The Mode property indicates whether the IDE is in design
(vsIDEModeDesign) or debug mode (vsIDEModeDebug). You might
want to disable your add-in from running while the user is debugging
code.
Solution
This property returns a reference object to the currently open
solution in the IDE. The solution object contains a collection of all
projects in the solution, the file name, the global settings for the
solution, whether it has been saved, etc. In addition, you can add
and remove files from the solution, iterate projects, save the solution
as another name, etc. We will explore the solution object in Chapter
8.
ToolWindows
This property returns an object that makes it easier to search for
some of the common tool windows, such as the Task List, the
Solution Explorer, the Error list, etc. We explore tool windows in
Chapter 14.
Windows
This property is a collection of windows currently open within Visual
Studio. Each item in the collection is a window object, allowing you to
resize and move windows, update captions, change focus, etc. We
explore the windows collection in detail in Chapter 10.
AddIn object
The _addInInstance object is an instance of the AddIn class. The
_addInInst parameter is passed to your add-in during the
onConnection method and it is assigned to the private class
variable _addInInstance. This variable provides details specific to
this instance of your add-in.
Add-in properties
The following properties are available for your add-in.
Collection
The Collection property returns a reference to the collection of add-
in objects currently installed in Visual Studio. You can use this
property to check for any dependencies your add-in may have.
Connected
This is a Boolean value indicating whether your add-in is loaded and
connected within Visual Studio. You can connect your add-in
programmatically by setting this property to True if not already
connected, i.e.:
if (_addinInstance.Connected)
Description
This string property contains the descriptive text that is displayed in
the Add-in Manager and sometimes as tooltip text. The property is
read/write, so you can dynamically update the title in your add-in.
GUID
This read-only string contains the CLSID of the add-in from the add-
in registry entry.
Name
This read-only string property holds the command name associated
with the add-in. It is the name parameter passed to the
AddNamedCommand method of the Visual Studio Commands
collection.
Object
The Object property is a reference to the instance of the actual
object containing your add-in’s implementation code. You can use this
property to access any additional information you’ve stored in your
object class that is needed to implement your add-in module.
ProgID
This read-only string property contains the unique program name for
your add-in’s command, typically the file name, class name, and
command name delimited by periods.
SatelliteDLLPath
This read-only string is the full path name where the DLL containing
the code implementing the add-in is located.
Assemblies
The following assemblies are used by the add-in modules and can be
added into your code as necessary. Keep in mind that some features
are only available in later versions of Visual Studio, so only use them
if you know the minimum version your add-in will run in.
Extensibility.dll
This assembly contains all versions of Visual Studio-IDTExtensibility2
and enums for connection purposes.
CommandBars.dll
Starting in VS 2005, Microsoft.VisualStudio.CommandBars.dll contains
the command bar model. Early versions used the command bar
model from Office.dll.
EnvDTE.dll
This assembly contains the extensibility model of Visual Studio to
manage the IDE, solutions, projects, files, code, etc. Later versions
are all additive to provide more version specific features:
80 (VS 2005, 2008, 2010)
90 (VS 2008, 2010)
100 (VS 2010)
VSLangProj.dll
This assembly contains more detailed extensibility models, specifically
for VB.NET and C# projects.
Chapter 5 Save Some Files
Add-In
Now that we have explored the various parts of an add-in module,
we can put them all together and write a simple add-in project. We
can start by creating a basic add-in using the wizard. Be sure to have
the wizard generate our starting code and the code to hook it into
the Tools menu.
Our add-in is going to look at all documents that have been edited,
but not saved, and display them in a check box list. Users can then
mark the ones they want to save and click to save only those files.
Our add-in will be called SaveSomeFiles.
SaveSomeFiles add-in
We can start our add-in using the Add-in Wizard described in Chapter
2. Use the following settings while running the wizard:
Visual C# (or your preferred language).
Application Host: Only Visual Studio.
Name/Description:SaveSomeFiles and Selectively save open files.
Create UI Menu and make sure load at start-up is not selected.
Verify the settings in the Summary screen, and if they look okay,
generate the code.
Note: Add a reference to System.Windows.Form in your add-in
project’s references. You’ll need this for the GUI screen we will
build. You will want to include this for most add-ins you create.
Designing the selection form
The selection form will be a standard Windows form with a
CheckedListBox control, Save, and Cancel buttons. Our add-in
will populate the list box and then display it to the user. Once the
user clicks Save, the code will save the selected files. If the user
clicks Cancel, the dialog box will close and no action will take place.
if (theDoc.Saved==false)
theForm.CLB.Items.Add(theDoc.FullName.ToString());
theForm.ShowDialog();
After the user closes the dialog box, we need to step through the
checked items, and call the Save method on the corresponding
document object.
if (theForm.DialogResult == DialogResult.OK)
{
if (theDoc.FullName.ToString() == theForm.CLB.Items[xx].ToStri
ng())
theDoc.Save();
theForm.Dispose();
Once we’ve completed the Save operation for the requested files, we
can dispose of the form we created earlier in the code.
if(neededText == vsCommandStatusTextWanted.vsCommandStatusTextWantedNo
ne)
if(commandName == "SaveSomeFiles.Connect.SaveSomeFiles")
status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupp
orted |
vsCommandStatus.vsCommandStatusEna
bled;
return;
if (_applicationObject.Mode == vsIDEMode.vsIDEModeDebug)
status = (vsCommandStatus)vsCommandStatus.vsCommandStatus
Supported;
else
status = (vsCommandStatus)vsCommandStatus.vsCommandStatus
Supported | vsCommandStatus.vsCommandStatusEnabled;
return;
else
status = (vsCommandStatus)vsCommandStatus.vsCommandStatus
Supported | vsCommandStatus.vsCommandStatusEnabled;
return;
}
When the IDE attempts to build the File menu, it will ask any add-ins
whether they are enabled. If we are in debug mode at the time, the
menu option will be disabled.
Summary
In this chapter, we designed a simple add-in module to show how to
interact with Windows forms and to extract information from the
_applicationObject variable. Many add-in modules will have similar
approaches, collecting and displaying information to the user, and
then interacting through the variable directly with Visual Studio.
Chapter 6 Testing Your Add-
In
Once you’ve coded your add-in, you can easily test it using the Visual
Studio debugger. However, debugging can be a bit easier once you
review the XML configuration files and understand the add-in life
cycle.
Configuration files
When you first create an add-in using the wizard, the wizard
generates your class code, and also two XML configuration files that
control your add-in’s behavior. These are:
<Add-in Name> - For Testing.Addin
<Add-in Name>.AddIn
For Testing.AddIn
When you generate an add-in using the wizard, it creates the XML file
and places it into the add-in folder. This file allows Visual Studio to
load your add-in, but refers to the assembly DLL in your project
folder. Other than the assembly location, this file has the same
content as your actual AddIn file you’ll use to install the add-in.
Of course, this can create a catch-22 for future debugging sessions.
When Visual Studio loads the add-in, the DLL containing the add-in
code is locked by the IDE. Hence, you might see this message when
you attempt to tweak and build your add-in:
Unable to delete file ".\bin\CodeWindow.dll".
Access to the path 'C:\Users\..\documents\visual studio
2010\Projects\CodeWindow\CodeWindow\bin\CodeWindow.dll' is
denied.
Another random document with
no related content on Scribd:
Ernest. Et cela, c’était une perspective abominable.
C’est à ce moment que les Debousquet, le beau-frère et la sœur
d’Ernest, eurent l’idée de fiancer leur fille aînée. Fabienne fut
atterrée, quand elle reçut la nouvelle de cet heureux événement
familial. C’était, en perspective, trois jours à passer dans la Seine-
Inférieure. Et il était de toute nécessité de télégraphier à Ernest pour
qu’il eût à presser son retour.
En apprenant cette nouvelle, Robert fit son possible pour prendre
un air ennuyé qui ne parût pas hypocrite.
Il avait pensé tout de suite, comme par un déclic : « Je vais
pouvoir aller voir mes parents… »
Fabienne, l’instant d’après, lui disait :
— Hé bien ! vous êtes content, vous allez pouvoir aller voir vos
parents ?
— Peut-être… dit-il évasivement… peut-être… plutôt que de
rester seul ici…
A partir de ce moment, le visage de Fabienne prit une expression
de dureté inflexible. Elle ne paraissait pas positivement fâchée. Mais
c’est à peine si elle adressait la parole à Robert. Quand elle était
ainsi changée en statue, on eût dit que son âme gentille, gaie et
tendre, était partie pour jamais.
Puis, brusquement, sans prévenir, quand elle en avait assez
d’être partie, l’âme de Fabienne revenait. Alors, c’était la résurrection
de son regard et de son sourire.
— Le méchant, qui est content de me quitter…
— Tu es bête, dit-il en l’embrassant.
Une dépêche annonça le retour d’Ernest pour le lendemain soir.
Robert décida qu’avant son arrivée, et pour éviter (ce qu’il ne dit
pas à Fabienne) les bonnes poignées de main du retour, il prendrait
lui-même, vers la fin de l’après-midi, le train de Paris. C’était un
samedi. A Paris, il coucherait à l’hôtel, et arriverait au Vésinet le
dimanche dans la matinée. Les Nordement, depuis qu’ils avaient
acheté leur villa, restaient à la campagne jusqu’à la fin d’octobre.
« Même quand on rentre à la nuit, disait M. Nordement, c’est
agréable de respirer une bouffée d’air du jardin. » Et il se persuadait
que c’était vrai.
La plus jeune de ses filles, Jenny, dont le mari était encore au
Maroc pour affaires, habitait avec ses parents.
Fabienne, le jour du départ, n’avait cessé de pleurer, si bien
qu’elle n’avait plus une figure convenable pour conduire Robert à la
gare. Elle aurait tout juste le temps de se remettre pour le retour
d’Ernest. D’ailleurs, disait-elle, ça lui était bien égal qu’il s’aperçût
qu’elle avait pleuré !… Ce qui ne l’empêcha pas, après le départ de
Robert, et à la réflexion, de remédier du mieux qu’elle put au
désordre de son visage.
Elle avait serré le jeune homme dans des bras frénétiques, en
répétant comme une folle :
— Je ne te verrai plus ! Je ne te verrai plus !
Puis, le moment du départ arrivé, elle l’avait poussé brusquement
vers la porte :
— Va-t’en ! Va-t’en !
Robert n’avait jamais considéré ce départ comme définitif. Mais
elle lui avait tant répété qu’il ne reviendrait plus, qu’il en avait été
impressionné, et qu’il se demandait maintenant si quelque
événement tout-puissant et inattendu n’allait pas l’empêcher de
retourner à Caen.
C’était un bon, brave et faible garçon ; mais sa situation d’homme
aimé lui donnait une espèce de férocité quasi professionnelle. Il
écarta l’image de cette femme en pleurs, et ne pensa qu’à la joie de
son retour au milieu des siens. Et il avait une grande hâte de revoir
la figure heureuse de ses parents. De nouveau, dans le train, il
passa en revue de nombreux souvenirs familiaux, à qui il trouvait
chaque fois un charme plus prenant.
— Il faut vraiment, pensait-il, avoir été séparé de son père et de
sa mère, pour comprendre la valeur de ce trésor inestimable :
l’affection des siens.
Il n’eut en les retrouvant aucune déception, et sa joie passa son
espérance.
Il avait passé la nuit à l’hôtel, tout près de la gare Saint-Lazare.
Et, dès huit heures du matin, après une nuit où il s’était cru arrivé au
jour une dizaine de fois, il s’habilla à la hâte, et courut à la gare avec
sa valise. Le train, par lequel il devait arriver là-bas, partait à huit
heures de la gare. Ce train lui parut marcher plus lentement encore
si possible qu’il ne marchait réellement. Le parcours entre les deux
dernières stations fut interminable.
Son père l’attendait sur le quai. De sa portière, ouverte
longtemps à l’avance, il vit les yeux de M. Nordement qui le
cherchaient.
Le père et de fils ne tombèrent pas dans les bras l’un de l’autre
comme cela se fait dans les pièces de théâtre. Robert jeta au hasard
sur la barbe grise un baiser presque furtif. Et il sentit à son tour un
effleurement de poils sur sa joue.
Papa ne savait plus très bien ce qu’il faisait, et Robert dut le
repousser presque rudement pour détourner les mains tremblantes
qui lui prenaient sa valise des mains. M. Nordement avait tellement
perdu le contrôle de lui-même que Robert l’empêcha de héler une
voiture pour parcourir les quatre cents mètres qui séparaient la gare
de la villa.
L’embrassade de maman fut plus dramatique, plus consciente,
plus mouillée. Maman, avec son petit air un peu sec, ne négligeait
jamais une occasion de verser des larmes.
Elle l’écarta d’elle, pour le regarder…
— Je ne lui trouve pas bonne mine…
— A force de manger à droite et à gauche, et de la nourriture
d’hôtel, ça n’est pas ça qui lui donnera bonne mine, dit M.
Nordement, qui avait fait les départements pendant plusieurs années
de sa jeunesse, et gardait rancune à certains hôtels du Commerce,
qui d’ailleurs ne figuraient pas toujours parmi les plus coûteux de la
ville.
Jeanne, la sœur aînée, était déjà rentrée à Paris avec son mari,
M. Glass. « Mais tu peux être tranquille, dit papa, on les verra à
déjeuner. » Jenny, l’autre sœur, toujours un peu en retard le matin
(« tu la connais »), descendit de sa chambre, pour embrasser son
frère et émettre à son tour sur sa mine un avis défavorable.
Tous leurs petits ridicules n’échappaient pas au jeune homme.
Mais désormais il n’en éprouvait plus que de l’attendrissement… Il
entrait avec délices, sans le moindre frisson, dans ce bain
d’affection, ni trop chaud ni trop froid, préparé à la température de
son cœur.
Il avait déjeuné le matin à l’hôtel, mais moitié pour faire plaisir à
sa mère, moitié par gourmandise, il prit une grosse tasse d’un café
au lait de tradition, que personne ne faisait comme « à la maison ».
Il fallut ensuite aller serrer la main à Florentine, la cuisinière, à
Louise, la femme de chambre, et saluer d’un simple sourire l’autre
bonne, plus nouvelle.
Très discrètement, et pour éviter de lui poser, au moins tout de
suite, des questions, on l’avait conduit à sa chambre, bien qu’il en
sût le chemin. On lui avait mis aux fenêtres des rideaux tout propres,
et une carpette neuve au bas de son lit. Évidemment ces dépenses
ne faisaient pas une brèche colossale à la fortune des Nordement. Il
en fut cependant touché, car il connaissait bien son père et sa
mère…
Mais il n’était pas au bout de ses surprises. Il y avait sur la table
de nuit un porte-montre. Le verre d’eau, fêlé depuis douze ans, était
remplacé. Et il trouva dans le bas de l’armoire une paire de
pantoufles toutes pareilles, en neuf, à ses vieilles. Il y vit comme une
espèce de symbole de ses habitudes de toujours, qui
réapparaissaient rajeunies, avec un charme nouveau.
Ses parents l’avaient laissé seul. Mais, sa sœur Jenny, plus
curieuse, était venue le retrouver.
C’était une petite femme brune assez jolie, au nez investigateur.
— Te voilà, j’espère, revenu pour de bon ?
— Pourquoi dis-tu cela ? dit Robert… Je n’étais pas parti…
J’étais simplement en voyage…
— Allons donc ! dit Jenny. Nous avons tous eu l’impression que
c’était fini, que tu avais assez de ta famille, que tu ne voulais plus
nous revoir… Dis-moi, un peu pourquoi, mon garçon ? ajouta-t-elle
en hochant la tête… Alors tu te figures que papa et maman
t’auraient marié de force, et obligé à épouser cette jeune fille qui ne
te plaisait pas ? Tu sais pourtant comment sont papa et maman.
Avec ça que, dans la vie, nous n’avons pas toujours fait ce que nous
désirions ! Je ne sais pas si je te l’ai dit, mais quand il a été question
pour moi d’épouser Félix, papa et maman n’étaient pas chauds
chauds pour ce mariage. Ça n’empêche pas que j’ai fait ce que j’ai
voulu et que papa et maman aiment maintenant Félix comme leur
enfant… Sans compter que, tu sais, on était très inquiets à la
maison. Personne ne savait ce que tu étais devenu. On nous a
raconté qu’on t’avait vu à Dinard avec une grosse dame qui n’était
plus de la première jeunesse. On se demandait si elle t’avait
enlevé…
— Voilà comme on écrit l’histoire, dit Robert, qui se mit à rire en
pensant à Fatma Orega.
Puis il changea de conversation. Car la question de Jenny : « Te
voilà revenu pour tout de bon ? », il ne voulait pas encore qu’elle fût
posée. Il se disait seulement qu’il serait obligé de rester dans sa
famille tout de même un peu plus longtemps qu’il n’avait eu, et qu’il
écrirait à Fabienne pour lui dire qu’il prolongerait son séjour. Mais il
n’avait pas encore trouvé les prétextes valables qui justifieraient
cette prolongation.
— Tu ne peux pas savoir, dit-il à Jenny, la joie profonde que l’on
éprouve à se retrouver dans sa famille, quand on l’a quittée pendant
quelque temps…
— Tu vois bien, fit Jenny, que tu étais parti avec l’idée de ne plus
revenir ?
— Je ne dis pas cela, dit Robert, qui ne voulait toujours pas, en
effet, que ce fût dit, mais que ça ne gênait plus que ce fût supposé…
Je puis l’avouer à toi, ajouta-t-il après une hésitation, ce que je ne
dirais pas à papa et à maman. C’est que j’avais l’intention, non pas
de les quitter, bien sûr, mais de fuir leur tutelle… C’est d’ailleurs une
intention… que je n’ai pas abandonnée…
— Allons ! allons ! fit Jenny, tu dis ça… Mais j’espère bien que tu
n’y penses plus…
— … Enfin, dit Robert, il n’est pas question de ça pour le
moment… Ce que je voudrais te dire, en amenant la conversation là-
dessus, c’est que le fait d’être parti m’a fait apprécier plus que
jamais le charme précieux de la famille…
— Allons ! tant mieux, dit Jenny, qui, ne cherchait pas midi à
quatorze heures, et ne tenait pas à être une personne compliquée.
Robert connaissait la qualité d’esprit de sa sœur et savait qu’elle
n’était pas pour lui la confidente rêvée. Mais il avait besoin de se
confier à quelqu’un et d’élucider ses idées en les exprimant tout
haut. Il n’était donc pas nécessaire que Jenny le comprît
absolument. D’ailleurs cette incompréhension même servait sa
thèse. Elle prouvait que sa sœur n’était pas en état d’apprécier cette
famille qu’elle n’avait jamais quittée.
— Ainsi, Jenny, tu ne sais pas ce que c’est que papa…
— Ah, il est magnifique, voilà maintenant qu’il découvre papa !
— Ne ris pas. Je t’assure que je comprends mieux papa qu’avant
d’être parti.
— Moi, dit Jenny, j’ai toujours eu pour mes parents les sentiments
qu’il faut avoir…
— Justement, Jenny, les sentiments, qu’il faut avoir…, c’est-à-
dire des sentiments de consigne, d’habitude, qui n’ont, crois-le bien,
aucun rapport avec l’amour filial ardent et spontané…
— Oh ! je ne te suis plus, fit Jenny.
— Je le sais, que tu ne me suis plus. Quand tu as quitté nos
parents pour habiter avec ton mari, à vrai dire, tu ne te séparais pas
d’eux. Tu n’as cessé de les voir à peu près tous les jours… Je
m’entends : il t’est arrivé parfois d’aller en voyage, et de rester
absente quelques semaines comme moi, cette fois-ci… Mais moi,
j’avais l’impression que cette séparation durerait très longtemps… et
que je resterais peut-être des années sans revenir à la maison…
Alors j’ai pensé à mes parents comme tu n’y as jamais pensé,
comme moi non plus je n’y avais pas pensé auparavant. Alors j’ai
senti que je les aimais véritablement, profondément, éternellement,
et que ce n’était plus là une question de consigne et d’habitude, que
je ne les aimais plus en vertu d’un commandement de la Bible. Ma
petite Jenny, quand je suis entré tout à l’heure dans la salle à
manger, quand j’ai vu ces vieux meubles autour desquels nous
avons été élevés…
— C’est vrai, dit la précise Jenny. Ce sont, en effet, les meubles
de notre enfance. Papa et maman les ont mis ici quand ils ont
acheté la villa et qu’ils ont meublé à neuf leur appartement de Paris.
— Le buffet de la salle à manger, Jenny ! Tu ne sais pas ce que
c’est que le buffet de notre salle à manger ! J’aurais voulu me mettre
à genoux et l’embrasser…
— Le buffet ? dit Jenny. Quel type ! Voilà maintenant qu’il veut
embrasser le buffet !
— Et ce tableau, Jenny, qui est près de la cheminée. A Paris, il
était dans la chambre de notre mère… Ce tableau qui représente un
moulin à vent… Je le trouvais si joli quand j’étais petit, et si laid plus
tard… Maintenant, je t’assure qu’il est délicieux ! Il me semble que
j’ai été élevé près de ce moulin !
— C’est de l’imagination, dit Jenny.
— Je me suis assis un instant sur une de nos vieilles chaises
cannées. Je n’ai jamais été assis si à mon aise. Comprends-tu
cela ?
— Non, fit nettement Jenny.
— Ah ! je te plains vraiment, ma pauvre Jenny. Je te plains de ne
pas sentir toute l’affection qu’il y a dans les yeux de nos parents,
toute l’amitié qui s’exhale des meubles, des murs… Les fenêtres !…
Les fenêtres sont comme des visages qu’on ne voudrait plus jamais
quitter…
— Je te suis plus ou moins, dit Jenny, qui ne voulait plus faire
preuve d’incompréhension complète. Mais je t’assure bien que je
n’ai pas besoin d’éprouver ces sensations… poétiques… pour rester
auprès de mes parents, en me disant que je ne cesserai de les voir
que le jour où la mort nous séparera…
— Comment se porte papa ? demanda Robert avec un peu
d’inquiétude.
— Il est bien, dit Jenny. Il n’a pas eu la moindre crise cet été.
Tiens, justement, l’autre jour, j’ai rencontré dans le train le docteur
Paulon. Il déclare que papa peut très bien se remettre tout à fait.
Ils descendirent tous deux. Papa se promenait autour de la
pelouse, pour se conformer à l’affirmation de toute la famille, qui ne
cessait de répéter qu’il adorait se promener dans le jardin. Robert
prit le bras de M. Nordement, et, tous deux, comme un bon père et
un bon fils, marchèrent ensemble pendant une demi-heure sans se
dire un mot.
Mais à quoi bon se parler ? pensait Robert. On sait si bien qu’on
est d’accord. On est d’accord de naissance…
— Si tu n’es pas fatigué, dit papa, on ira ensemble à la gare pour
attendre ta sœur Jeanne ?
— Bonne idée, dit Robert.
Ces deux petites phrases échangées leur permettaient de
repartir pour un nouveau silence d’une demi-heure…
Robert avait songé à poser cette question à M. Nordement :
« Es-tu content des affaires ? » Seulement, il se dit que son père, à
son tour, lui demanderait : « Qu’as-tu fait pendant ce voyage ? » Et il
préférait laisser ce sujet-là tranquille…
A la gare, ils reçurent la famille Glass. Jeanne Glass était l’aînée
des trois enfants Nordement. C’était une femme grande,
délibérément pleine de décision, et douée d’admirables facultés
d’organisatrice, qu’elle appliquait à la vie la plus insignifiante qui fût.
Elle prenait des airs de général d’armée pour fixer la date d’un repas
de famille et faisait preuve d’une clairvoyance étonnante pour
pénétrer les intentions et les arrière-pensées les plus secrètes d’une
humble ouvrière en journée.
Glass, mari de la précédente, était antiquaire. Il avait repris la
maison fondée par David Glass, son père. La grande question,
maintes fois agitée dans le cercle de ses connaissances, était de
savoir s’il était aussi fort que le fondateur. Naturellement, les vieilles
générations tenaient pour le père Glass. D’ailleurs, aucun des
arbitres n’avait la moindre compétence pour se prononcer. Mais
ceux qui avaient connu David Glass avaient été impressionnés par
ses manières tranchantes et méprisantes, tandis que l’air poli et froid
du fils, avec sa lèvre rasée et ses cheveux blancs précoces,
formaient un ensemble qui en imposait beaucoup à ses
contemporains.
Mme Nordement avait toujours dans un coin un petit objet d’art,
acheté dans le courant de la semaine, et qu’elle montrait timidement
à son gendre…
— Qu’est-ce que vous avez payé ça, maman ?
— Deux cent cinquante…
— C’est à peu près ce que ça vaut. Vous n’avez pas été volée.
— Bien, bien, disait Mme Nordement sans laisser voir son dépit
de n’avoir pas fait l’affaire miraculeuse…
Robert revenait de la gare en tenant par la main son petit neveu
Gaston Glass, qu’il n’avait jamais trouvé si charmant. Et il pensait à
toutes les erreurs de jugement qu’il avait commises au détriment des
siens.
Pourquoi, jadis, en avait-il tant voulu à sa sœur Jeanne de
mépriser, d’ignorer plutôt ses préoccupations d’étudiant ? Pourquoi
avait-il été rebuté par ses conversations avec son beau-frère, qui
n’avait pas comme lui l’admiration des efforts des artistes nouveaux
et ne se passionnait pas pour les tentatives généreuses,
désintéressées, auxquelles lui-même et Francis Picard avaient si
religieusement applaudi ?
A chacun sa spécialité. Il ne faut pas exiger de chaque musicien
qu’il soit un orchestre complet, mais le féliciter quand il tient bien sa
place. L’élite, l’avant-garde, qui, par saccades brusques, essaie
constamment de tirer le monde en avant, l’élite a son rôle
nécessaire. Mais il ne faut pas demander à tout le genre humain
d’être une immense avant-garde impatiente.
Quand ils discutaient, son beau-frère et lui, ils avaient raison tous
les deux, chacun à la place où il se trouvait. Lui, Robert, suivait son
ardente curiosité de jeune homme. Et il faisait bien. Mais pouvait-on
blâmer M. Glass, le considérable antiquaire du faubourg Saint-
Honoré, de ne pas bousculer la foule lente de la clientèle, et, pour
résister aux poussées en avant de son beau-frère, de faire frein de
tout le poids de ses intérêts conservateurs ?
Robert ne cessait maintenant de se répéter : « Pour être heureux
avec les êtres, il ne faut leur demander que ce qu’ils peuvent
donner. »
Son petit neveu, dont il tenait la petite main dans le sienne, son
petit neveu avait six ans. Allait-il lui parler de métaphysique ou de
mathématiques supérieures ? Il fallait le regarder avec amour, en se
disant : il est tout petit, et comme il a bien la gaîté, la turbulence, la
naïveté exquise de son âge !
Pour goûter pleinement son bonheur, qu’il ne cessait de boire à
petits traits, et n’être pas tourmenté par l’idée d’avoir à écrire à
Fabienne une lettre difficile, il décida de s’acquitter rapidement de
cette tâche avant le déjeuner, et de porter tout de suite sa lettre à la
poste, afin qu’il n’y eût plus à y revenir.
Avant leur séparation, ils avaient décidé qu’à défaut de moyens
pratiques de s’écrire secrètement, il enverrait au couple Gaudron
des lettres qui ne seraient en réalité que pour la jeune femme. Elle
n’aurait qu’à faire mentalement les substitutions d’usage, à
remplacer « mes chers amis » par « ma chérie », le mot
« affectueusement » par « tendrement » et « mille amitiés » par cent
fois autant de baisers frénétiques. Ce code était des plus simples, et,
il n’y avait pas besoin de beaucoup de conventions préalables pour
l’appliquer.
Il écrivit donc :
« Je vais demander s’il n’y aurait pas moyen, pour une partie
tout au moins de ces actes notariés, de faire établir des
procurations. Mais je crains que pour certains d’entre eux ma
présence soit nécessaire. Je serai fixé demain, — après-demain
au plus tard, et je vous écrirai aussitôt.
« Mes souvenirs affectueux.
« Robert Nordement. »