Foundation > The Display System > Connecting to the Display Server
 
Connecting to the Display Server
To initialize a Rogue Wave® Views session, you have to create an instance of the IlvDisplay class. This involves:
*Opening a Connection and Checking the Display
*Closing a Connection and Ending a Session
Opening a Connection and Checking the Display
The member function isBad returns a Boolean value that tells you whether the IlvDisplay object has been successfully created, as shown in the following code. The reasons for a display failure vary from one display system to another.
IlvDisplay* display = new IlvDisplay("AppName",
"DisplayName",
argc,
argv);
if (display->isBad()) {
delete display;
IlvFatalError("Could not create display");
IlvExit(-1);
}
 
const char* dirName = "./localDirectory/subDirectory";
const char* fileName = "foo.txt";
display->prependToPath(dirName);
// Now, if a file such as
// "./localDirectory/subDirectory/foo.txt"
// or
// ".\localDirectory\subDirectory\foo.txt"
// exists, we should be able to find it.
const char* filePath = display->findInPath(fileName);
if (filePath)
IlvPrint("File %s found at %s", fileName, filePath);
else
IlvWarning("File %s not found", fileName);
For more information about Rogue Wave Views error messages, see Error Messages.
Closing a Connection and Ending a Session
To close a connection to the display server, just destroy the IlvDisplay object. The destructor, IlvDisplay::~IlvDisplay, immediately frees all graphic resources used by the display.
If the IlvDisplay was created on the basis of an existing link to a display system, delete does not destroy this link. Except in the rare cases of multidisplay applications, destroying the IlvDisplay means the end of the session, since you cannot do much without a display.
You must call functions::IlvExit to end the session properly. It frees memory allocated by Rogue Wave Views. This is especially important with Microsoft Windows, where this memory is not automatically freed by the system.
delete display;
IlvExit(0);

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.