OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Calling an ObjectWindows DLL

When both a child window and the parent window are created in an ObjectWindows application, communication between the parent and child windows is in place.

But you can also prepare your DLL for use by non-ObjectWindows applications.

When a child window is created in an ObjectWindows DLL and the parent window is created by a non-ObjectWindows application, the parent-child relationship must be simulated in the ObjectWindows DLL. This is done by constructing an alias window object in the ObjectWindows DLL that is associated with the parent window whose handle is specified on a DLL call.

In the following code, the exported function CreateDLLWindow is in an ObjectWindows DLL. The function will work for both ObjectWindows and non-ObjectWindows applications.

{
TWindow* parentAlias = GetWindowPtr(parentHWnd); // check if an OWL window
parentAlias = new TWindow(parentHWnd); // if not, make an alias
TWindow* window = new TWindow(parentAlias, "Hello from a DLL!");
window->Attr.Style |= WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME
window->Attr.X = 100;
window->Attr.Y = 100;
window->Attr.W = 300;
window->Attr.H = 300;
return window->Create();
}

CreateDLLWindow determines if it has been passed a non-ObjectWindows window handle by the call to GetWindowPtr, which returns 0 when passed a non-ObjectWindows window handle. If it is a non-ObjectWindows window handle, an alias parent TDialog object is constructed to serve as the parent window.

See Also