OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Creating Window Interface Elements

After you have constructed a window object, you need to tell Windows to create the associated interface element.

Do this by calling the object's TWindow::Create() member function,

window.Create();

Create does the following things:

  • Creates the interface element
  • Sets HWindow to the handle of the interface element
  • Sets members of Attr to the actual state of the interface element (Style, ExStyle, X, Y, H, W)
  • Calls TWindow::SetupWindow()

An application's main window is automatically created by TApplication::InitInstance(). You do not need to call Create yourself to create the main window. C++ exceptions can be thrown while creating a window object's interface element. You should therefore enclose calls to Create within a try/catch block to handle any memory or resource problems your application might encounter. Create throws a TXWindow exception initialized with an IDS_WINDOWCREATEFAIL when the window cannot be created or an IDS_CLASSREGISTERFAIL when the window class cannot be registered. SetupWindow throws a TXWindow exception initialized with an IDS_CHILDCREATEFAIL when a child window in the window cannot be created. These exceptions are usually caused by insufficient memory or other resources.

Example

Here is an example of using exceptions to catch an error while creating a window object:

try
{
TWindow* window = new TMyWindow(this);
window->Create();
}
catch(TXOwl& exp)
{
MessageBox(exp.why.c_str(), "Window creation error");
throw(exp);
}

See Also