home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OLogo.cpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  4KB  |  146 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OLogo.cpp
  5.  
  6. /*
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  13.  *    endorse or promote products derived from this software
  14.  *    without specific prior written permission.
  15.  * 3. See OCL.INF for a detailed copyright notice.
  16.  *
  17.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  */
  29.  
  30.  
  31. // $Header: W:/Projects/OCL/Source/rcs/OLogo.cpp 1.50 1996/08/11 23:49:21 B.STEIN Release $
  32.  
  33. #define __OCL_SOURCE__
  34.  
  35. #define OINCL_OSTRING
  36. #define OINCL_BASE
  37.  
  38. #include <ocl.hpp>
  39. #include <OLogo.hpp>
  40.  
  41.  
  42. OLogo::OLogo(const HMODULE module, const ULONG bitmapID, const ULONG cx, const ULONG cy)
  43.   : OFrame(bitmapID, 0, CS_SIZEREDRAW),
  44.     bmp(NULL),
  45.     mod(module)
  46. {
  47.  sizepos.cx = cx;
  48.  sizepos.cy = cy;
  49.  sizepos.x = (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)-cx)/2;
  50.  sizepos.y = (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)-cy)/2;
  51.  dest.x = 0;
  52.  dest.y = 0;
  53. }
  54.  
  55.  
  56. OLogo::OLogo(const PSZ filename, const ULONG frameID, const ULONG cx, const ULONG cy)
  57.   : OFrame(frameID, 0, CS_SIZEREDRAW),
  58.     bmp(NULL),
  59.     bmpfile((PSZ)filename),
  60.     mod(NULLHANDLE)
  61. {
  62.  sizepos.cx = cx;
  63.  sizepos.cy = cy;
  64.  sizepos.x = (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)-cx)/2;
  65.  sizepos.y = (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)-cy)/2;
  66.  dest.x = 0;
  67.  dest.y = 0;
  68. }
  69.  
  70.  
  71. OLogo::~OLogo() 
  72. {
  73.  if (bmp) delete bmp;
  74. }
  75.  
  76.  
  77. PSZ OLogo::isOfType() const
  78.  return("OLogo"); 
  79. }
  80.  
  81.  
  82. OLogo& OLogo::showLogo(const ULONG timeout)
  83. {
  84.  createFrame("OLogo");
  85.  
  86.  if (timeout != 0)
  87.    {
  88.     DosSleep(timeout);
  89.     destroyFrame();
  90.    }
  91.  return(*this);
  92. }
  93.  
  94.  
  95. BOOL OLogo::OCommand(ULONG msg, MPARAM mp1, MPARAM mp2)
  96. {
  97.  switch(msg)
  98.    {
  99.     case WM_CREATE:
  100.       WinSetWindowPos(frame, HWND_BOTTOM, sizepos.x, sizepos.y,
  101.                       sizepos.cx, sizepos.cy,
  102.                       SWP_MOVE | SWP_SIZE | SWP_SHOW);
  103.       try
  104.        {
  105.         if (bmpfile)
  106.           bmp = new OBitmap(hwnd, bmpfile);
  107.         else
  108.           bmp = new OBitmap(hwnd, res, mod);
  109.        }
  110.       catch(OPMException ex)
  111.        {
  112.         bmp = NULL;
  113.         ex.viewError();
  114.         return(TRUE);
  115.        }
  116.       hps = WinGetPS(hwnd);
  117.       WinDrawBitmap(hps, bmp->hbm, NULL, &dest, 0L, 0L, DBM_IMAGEATTRS);
  118.       break;
  119.  
  120.     case WM_ERASEBACKGROUND:
  121.       dest.x = 0;
  122.       dest.y = 0;
  123.       if (bmp)
  124.         WinDrawBitmap(hps, bmp->hbm, NULL, &dest, 0L, 0L, DBM_IMAGEATTRS);
  125.       return(TRUE);
  126.  
  127.     case WM_CLOSE:
  128.     case WM_DESTROY:
  129.       WinReleasePS(hps);
  130.       break;
  131.  
  132.     default:
  133.       return(FALSE);
  134.    }
  135.  return(TRUE);
  136. #ifdef __BCPLUSPLUS__
  137.   #pragma warn -par
  138. #endif
  139. }
  140. #ifdef __BCPLUSPLUS__
  141.   #pragma warn .par
  142. #endif
  143.  
  144. // end of source
  145.