home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / zfamily.zip / zfamily / ZISFUNCS / SAMPLE / ZZZLOGO.C < prev    next >
Text File  |  1993-09-01  |  5KB  |  166 lines

  1. /*
  2. ** /----------------------------------------------------------------------\
  3. ** |             IBM Z Family Reusable Libraries/2 (5641-504)             |
  4. ** |----------------------------------------------------------------------|
  5. ** | (C) Copyright International Business Machines Corporation 1993, 1994 |
  6. ** |----------------------------------------------------------------------|
  7. ** |                       DISCLAIMER OF WARRANTIES                       |
  8. ** |                       ------------------------                       |
  9. ** | The following code is sample code created by IBM Corporation.        |
  10. ** | Such a code is provided to you solely for the purpose of assisting   |
  11. ** | you in the development of your applications. The code is provided    |
  12. ** | "AS IS", without warranty of any kind.  IBM shall not be liable for  |
  13. ** | any damages arising out of your use of the following code, even if   |
  14. ** | they have been advised of the possibility of such damages.           |                                                                         *
  15. ** \----------------------------------------------------------------------/
  16. **
  17. **  Module  : ZZZLOGO.C
  18. **  Author  : Dario de Judicibus (DEJUDICI at ROMEPPC)
  19. **  Created : 30 Aug 1993
  20. **  Updated : 30 Aug 1993
  21. **  Version : 1.00
  22. **  Content : Logo Data Dialog Procedure
  23. **
  24. */
  25.  #define INCL_PM
  26.  #define INCL_DOSPROCESS
  27.  
  28.  #include <os2.h>
  29.  #include <stdio.h>
  30.  #include <stdlib.h>
  31.  #include <string.h>
  32.  #include <ctype.h>
  33.  
  34.  #include <zzzlogo.h>
  35.  
  36. /*------------------------------------------------------------------------*/
  37.  
  38.  MRESULT EXPENTRY zzzLogoDlgProc
  39.  (
  40.    HWND   hwnd ,
  41.    ULONG  msg  ,
  42.    MPARAM mp1  ,
  43.    MPARAM mp2
  44.  )
  45.  {
  46.    switch (msg)
  47.    {
  48.      case WM_INITDLG :
  49.      {
  50.        zzzPLOGODATA pLogoData = (zzzPLOGODATA)mp2 ;
  51.  
  52.        WinSetDlgItemText ( hwnd, ZZZLOGOLIBTX2, pLogoData->Library   ) ;
  53.        WinSetDlgItemText ( hwnd, ZZZLOGOVERTX2, pLogoData->Version   ) ;
  54.        WinSetDlgItemText ( hwnd, ZZZLOGOAUTTX2, pLogoData->Author    ) ;
  55.        WinSetDlgItemText ( hwnd, ZZZLOGOCPYTXT, pLogoData->Copyright ) ;
  56.  
  57.        (VOID)zzzCenterDialog (hwnd, HWND_DESKTOP) ;
  58.      }
  59.      break ;
  60.  
  61.      case WM_COMMAND:
  62.      {
  63.        switch (SHORT1FROMMP(mp1))
  64.        {
  65.          case DID_OK:
  66.          {
  67.            WinDismissDlg(hwnd, TRUE) ;
  68.            WinDestroyWindow(hwnd) ;
  69.            return ((MRESULT)FALSE) ;
  70.          }
  71.        }
  72.      }
  73.      break ;
  74.  
  75.      case WM_CLOSE:
  76.      {
  77.        return (WinDefDlgProc (hwnd, msg, mp1, mp2)) ;
  78.      }
  79.  
  80.      case WM_DESTROY:
  81.      {
  82.        return (WinDefDlgProc (hwnd, msg, mp1, mp2)) ;
  83.      }
  84.  
  85.      default:
  86.      {
  87.        return (WinDefDlgProc (hwnd, msg, mp1, mp2)) ;
  88.      }
  89.    }
  90.  
  91.    return ((MRESULT)FALSE) ;
  92.  }
  93.  
  94. /*------------------------------------------------------------------------*/
  95.  
  96. /*
  97. **  Function : zzzCenterDialog
  98. **  Author   : Dario de Judicibus (DEJUDICI at ROMEPPC)
  99. **  Created  : 09 Aug 1993
  100. **  Updated  : 09 Aug 1993
  101. **  Version  : 1.00
  102. **  Content  : Centers a dialog box on the client area of the caller
  103. **
  104. */
  105.  LONG EXPENTRY zzzCenterDialog
  106.  (
  107.    HWND hWnd       ,  // Handle of the window to be centered
  108.    HWND hWndCenter    // Handle of the window to center on
  109.  )
  110.  {
  111.    LONG   X, Y ;                         // Destination points
  112.    SWP    DlgSwp, CenterSwp ;            // Set window position structures
  113.    LONG   lScreenWidth, lScreenHeight ;  // Dimensions of the DESKTOP
  114.  
  115.   /*
  116.   **  Query width and depth of dialog box
  117.   */
  118.    WinQueryWindowPos (hWnd, (PSWP) &DlgSwp) ;
  119.  
  120.   /*
  121.   **  Query width and depth of caller
  122.   */
  123.    WinQueryWindowPos (hWndCenter, (PSWP) &CenterSwp) ;
  124.  
  125.   /*
  126.   **  Determine the difference in center points from owner to child
  127.   */
  128.    X = (CenterSwp.x + (CenterSwp.cx / 2)) - (DlgSwp.x + (DlgSwp.cx / 2)) ;
  129.    Y = (CenterSwp.y + (CenterSwp.cy / 2)) - (DlgSwp.y + (DlgSwp.cy / 2)) ;
  130.  
  131.   /*
  132.   **  Ajust x,y origin coordinates to new position of child
  133.   */
  134.    X = DlgSwp.x + X ;
  135.    Y = DlgSwp.y + Y ;
  136.  
  137.   /*
  138.   **  If either x,y origin point is less than zero, then set that point to
  139.   **  zero so that the entire dialog box will be positioned on the desktop.
  140.   **  First check the bottom and left sides.
  141.   */
  142.    X = (X < 0) ? 0 : X ;
  143.    Y = (Y < 0) ? 0 : Y ;
  144.  
  145.   /*
  146.   **  Query dimensions of the DESKTOP screen.
  147.   */
  148.    lScreenWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) ;
  149.    lScreenHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) ;
  150.  
  151.   /*
  152.   **  Second check the top and right sides against the desktop
  153.   **  screen width and height.
  154.   */
  155.    if ((X + DlgSwp.cx) > lScreenWidth ) X = lScreenWidth  - DlgSwp.cx ;
  156.    if ((Y + DlgSwp.cy) > lScreenHeight) Y = lScreenHeight - DlgSwp.cy ;
  157.  
  158.   /*
  159.   **  Move the dialog box to the center
  160.   */
  161.    return (WinSetWindowPos (hWnd, HWND_TOP, X, Y, 0, 0, SWP_MOVE)) ;
  162.  }
  163.  
  164. /*------------------------------------------------------------------------*/
  165.  
  166.