home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 7.ddi / OWLDEMOS.ZIP / DLLHELLO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.6 KB  |  52 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <stdlib.h>
  4. #include <owl.h>
  5. #include "windows.h"
  6. #include "dllhello.h"
  7.  
  8. PTModule DLLHelloLib;
  9.  
  10. BOOL far _export CreateDLLWindow(HWND ParentHWnd)
  11. {
  12.   PTWindowsObject AParentAlias;
  13.   PTWindow TheWindow;
  14.  
  15.   AParentAlias = DLLHelloLib->GetParentObject(ParentHWnd);
  16.   TheWindow = new TWindow(AParentAlias, "Hello from a DLL!", DLLHelloLib);
  17.   TheWindow->Attr.Style |= WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME
  18.     | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
  19.   TheWindow->Attr.X = 100; TheWindow->Attr.Y = 100;
  20.   TheWindow->Attr.W = 300; TheWindow->Attr.H = 300;
  21.   return (DLLHelloLib->MakeWindow(TheWindow) == TheWindow);
  22. }
  23.  
  24. int FAR PASCAL LibMain(HINSTANCE hInstance, WORD /*wDataSeg*/,
  25.   WORD /* cbHeapSize */, LPSTR lpCmdLine)
  26. {
  27.     int TheStatus;
  28.  
  29.     // Note that we can't ensure that DLLHelloLib is allocated
  30.     // in memory owned by DLLHELLO.DLL.  Hence, it will get owned
  31.     // by the first application that caused DLLHELLO.DLL to be
  32.     // loaded.
  33.     DLLHelloLib = new TModule("DLLHello", hInstance, lpCmdLine);
  34.     TheStatus = DLLHelloLib->Status;
  35.     if ( TheStatus != 0 )
  36.     {
  37.       delete DLLHelloLib;
  38.       DLLHelloLib = NULL;
  39.     }
  40.     return (TheStatus == 0);
  41. }
  42.  
  43. int FAR PASCAL WEP ( int /*bSystemExit*/ )
  44. {
  45.     // don't delete DLLHelloLib here.  We haven't guaranteed that
  46.     // DLLHelloLib points to memory owned by DLLHELLO.DLL.  It
  47.     // will belong to the application that first caused DLLHELLO.DLL
  48.     // to be loaded.  At the time WEP is called, that application,
  49.     // and all of its memory, has been deleted.
  50.     return 1;
  51. }
  52.