home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / javasamp.zip / Support.C < prev   
C/C++ Source or Header  |  1996-10-01  |  7KB  |  178 lines

  1. #pragma    title("Java - PM Sample  --  Version 1.0  --  (Support.C)")
  2. #pragma    subtitle("   Support Routines - Interface Definitions")
  3.  
  4. #define    INCL_DOS           /* Include OS/2 PM DOS Interface    */
  5. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  6. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  7.  
  8. #include <os2.h>
  9. #include <string.h>
  10.  
  11. #include "appdefs.h"
  12. #include "java.h"
  13.  
  14. /* This    module contains    routine    used to    provide    various    support        */
  15. /* routines.                                */
  16.  
  17. /* Filename:   Support.C                        */
  18.  
  19. /*  Version:   1.0                            */
  20. /*  Created:   1996-10-10                        */
  21. /*  Revised:   1996-10-10                        */
  22.  
  23. /* Routines:   VOID InitApp(HWND hwndFrame, HWND hwndClient,        */
  24. /*                PSZ    pszWindowListTitle);            */
  25. /*           HWND CreateStdWindow(HWND hwndParent, ULONG flStyle,    */
  26. /*                    ULONG flCreateFlags,        */
  27. /*                    PSZ    pszClientClass,    PSZ pszTitle,    */
  28. /*                    ULONG styleClient, HMODULE hmod,    */
  29. /*                    ULONG idResources,            */
  30. /*                    PHWND phwndClient,            */
  31. /*                    LONG x, LONG y, LONG cx, LONG cy);    */
  32.  
  33.  
  34. /************************************************************************/
  35. /************************************************************************/
  36. /************************************************************************/
  37. /* DISCLAIMER OF WARRANTIES:                        */
  38. /* -------------------------                        */
  39. /* The following [enclosed] code is sample code    created    by IBM        */
  40. /* Corporation and Prominare Inc.  This    sample code is not part    of any    */
  41. /* standard IBM    product    and is provided    to you solely for the purpose    */
  42. /* of assisting    you in the development of your applications.  The code    */
  43. /* is provided "AS IS",    without    warranty of any    kind.  Neither IBM nor    */
  44. /* Prominare shall be liable for any damages arising out of your    */
  45. /* use of the sample code, even    if they    have been advised of the    */
  46. /* possibility of such damages.                        */
  47. /************************************************************************/
  48. /************************************************************************/
  49. /************************************************************************/
  50. /*               D I S C L A I M E R                */
  51. /* This    code is    provided on an as is basis with    no implied support.    */
  52. /* It should be    considered freeware that cannot    be rebundled as        */
  53. /* part    of a larger "*ware" offering without our consent.        */
  54. /************************************************************************/
  55. /************************************************************************/
  56. /************************************************************************/
  57.  
  58. /* Copyright ╕ International Business Machines Corp., 1996.        */
  59. /* Copyright ╕ 1996  Prominare Inc.  All Rights    Reserved.        */
  60.  
  61. /* --------------------------------------------------------------------    */
  62.  
  63.  
  64. #pragma    subtitle("   Program Initialization -   Program Initialization Function")
  65. #pragma    page( )
  66.  
  67. /* --- InitApp ----------------------------------------- [ Public ] ---    */
  68. /*                                    */
  69. /*     This function is    used to    perform    basic application        */
  70. /*     initialization to support the owner draw    list boxes and to set    */
  71. /*     the window list title if    provided.                */
  72. /*                                    */
  73. /*     Upon Entry:                            */
  74. /*                                    */
  75. /*     HWND hwndFrame;      = Application    Frame Window Handle        */
  76. /*     HWND hwndClient;      = Application    Client Window Handle        */
  77. /*     PSZ  pszTaskTitle; = Window List    Title                */
  78. /*                                    */
  79. /*     Upon Exit:                            */
  80. /*                                    */
  81. /*     Nothing                                */
  82. /*                                    */
  83. /* --------------------------------------------------------------------    */
  84.  
  85. VOID InitApp(HWND hwndFrame, HWND hwndClient, PSZ pszWindowListTitle)
  86.  
  87. {
  88. HPS    hPS;               /* Presentation Space Handle        */
  89. SWCNTRL    swCtl;               /* Task Switch Control Structure    */
  90.  
  91.                /* Get a    temporary presentation space so    that    */
  92.                /* the system's font metrics can be found and    */
  93.                /* the proper sizing of owner draw list boxes    */
  94.                /* can be performed properly            */
  95.  
  96. if ( (hPS = WinGetPS(hwndClient)) != (HPS)NULL )
  97.    {
  98.    GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &fm);
  99.  
  100.                /* Release the temporary    presentation space    */
  101.    WinReleasePS(hPS);
  102.    }
  103.  
  104. if ( pszWindowListTitle    )
  105.    {
  106.                /* Fill Switch Entry structure with required    */
  107.                /* values before    adding program name to Task    */
  108.                /* Manager switch list                */
  109.  
  110.    swCtl.hwnd           = hwndFrame;
  111.    swCtl.hwndIcon      = (HWND)NULL;
  112.    swCtl.hprog           = (HPROGRAM)NULL;
  113.    swCtl.idProcess     =
  114.    swCtl.idSession     = 0;
  115.    swCtl.uchVisibility = SWL_VISIBLE;
  116.    swCtl.fbJump           = SWL_JUMPABLE;
  117.    strcpy(swCtl.szSwtitle, pszWindowListTitle);
  118.  
  119.    hSwitch = WinAddSwitchEntry(&swCtl);
  120.    }
  121. }
  122. #pragma    subtitle("      Program Initialization - Window Creation Function")
  123. #pragma    page( )
  124.  
  125. /* --- CreateStdWindow --------------------------------- [ Public ] ---    */
  126. /*                                    */
  127. /*     This function is    used to    create a standard window using        */
  128. /*     WinCreateStdWindow and to place the window in the location    */
  129. /*     and size    specified if the shell position    style has not been    */
  130. /*     specified.                            */
  131. /*                                    */
  132. /*     Upon Entry:                            */
  133. /*                                    */
  134. /*     HWND    hwndParent;     = Parent    Window Handle            */
  135. /*     ULONG   flStyle;           = Window    Style                */
  136. /*     ULONG   flCreateFlags;  = Frame Creation    Flags            */
  137. /*     PSZ     pszClientClass; = Client    Area Class            */
  138. /*     PSZ     pszTitle;       = Window    Title                */
  139. /*     HMODULE hmod;           = Resources Module Handle        */
  140. /*     ULONG   idResources;    = Resource ID                */
  141. /*     PHWND   phwndClient;    = Client    Window Handle Pointer        */
  142. /*     LONG    x;           = x Co-ordinate                */
  143. /*     LONG    y;           = y Co-ordinate                */
  144. /*     LONG    cx;           = Window    Width                */
  145. /*     LONG    cy;           = Window    Height                */
  146. /*                                    */
  147. /*     Upon Exit:                            */
  148. /*                                    */
  149. /*     CreateStdWindow = NULL :    Error Occurred,    No Window Created    */
  150. /*               = > 0  :    Frame Window Handle            */
  151. /*                                    */
  152. /* --------------------------------------------------------------------    */
  153.  
  154. HWND CreateStdWindow(HWND hwndParent, ULONG flStyle, ULONG flCreateFlags, PSZ pszClientClass, PSZ pszTitle, ULONG styleClient,
  155.              HMODULE hmod, ULONG idResources, PHWND phwndClient, LONG x, LONG y, LONG cx, LONG cy)
  156.  
  157. {
  158. HWND   hwndFrame;           /* Frame Window Handle        */
  159. POINTL aptl[2];               /* Point Translation    Array        */
  160.  
  161. if ( !(hwndFrame = WinCreateStdWindow(hwndParent, flStyle, &flCreateFlags, pszClientClass, pszTitle, styleClient,
  162.                       hmod, idResources, phwndClient)) )
  163.    return((HWND)NULL);
  164.  
  165. if ( !(flCreateFlags & FCF_SHELLPOSITION) )
  166.    {
  167.    aptl[0].x = x;
  168.    aptl[0].y = y;
  169.    aptl[1].x = cx;
  170.    aptl[1].y = cy;
  171.    WinMapDlgPoints(HWND_DESKTOP, aptl, 2UL, TRUE);
  172.    WinSetWindowPos(hwndFrame, HWND_TOP,    aptl[0].x, aptl[0].y, aptl[1].x, aptl[1].y, SWP_ACTIVATE | SWP_SIZE | SWP_MOVE |
  173.            (ULONG)((flStyle & WS_VISIBLE) ? SWP_SHOW : 0UL));
  174.    }
  175.                /* Return back the window handle            */
  176. return(hwndFrame);
  177. }
  178.