home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ucmenu.zip / UCMENUS.PAK / SAMPLES / SAMP1 / SAMP1.C < prev    next >
Text File  |  1995-09-28  |  22KB  |  424 lines

  1. /************************************************************************/
  2. /* Program name: SAMP1.C                                                */
  3. /*                                                                      */
  4. /* OS/2 Developer Magazine, Issue:  Jan '95                             */
  5. /* Author:  Mark McMillan, IBM Corp.                                    */
  6. /*                                                                      */
  7. /* Description: UCMenu sample #1                                        */
  8. /*                                                                      */
  9. /* Program Requirements:  OS/2 2.x                                      */
  10. /*                        IBM C Set/2 (or other OS/2 compiler)          */
  11. /*                        OS/2 Toolkit                                  */
  12. /*                                                                      */
  13. /* Copyright (c)International Business Machines Corp. 1994              */
  14. /*                                                                      */
  15. /************************************************************************/
  16.  
  17. /************************************************************************/
  18. /************************************************************************/
  19. /*                      DISCLAIMER OF WARRANTIES.                       */
  20. /************************************************************************/
  21. /************************************************************************/
  22. /*     The following [enclosed] code is source code created by the      */
  23. /*     author(s).  This source code is provided to you solely           */
  24. /*     for the purpose of assisting you in the development of your      */
  25. /*     applications.  The code is provided "AS IS", without             */
  26. /*     warranty of any kind.  The author(s) shall not be liable         */
  27. /*     for any damages arising out of your use of the source code,      */
  28. /*     even if they have been advised of the possibility of such        */
  29. /*     damages.  It is provided purely for instructional and            */
  30. /*     illustrative purposes.                                           */
  31. /************************************************************************/
  32. /************************************************************************/
  33.  
  34. /*----------------------------------------------------------------------------
  35. Notes for sample #1:
  36.  
  37. This sample shows the visual appearence of several UC menus in a standard
  38. frame with all the frame controls used (e.g. menu bar, vertical and
  39. horizontal scroll bars, etc).  There is no functionality in this sample, its
  40. only purpose is to show how UC menus can be made into frame controls on any
  41. edge of a standard frame window.  It also shows how UC menus are created from
  42. resource file templates and given various attributes and styles.  This is not
  43. a full UC menus implementation -- not all the WM_CONTROL messages from the
  44. menu are processed (and thus some fields of the menu customization dialogs
  45. will be blank).  See sample #2 for a full implementation.
  46. ----------------------------------------------------------------------------*/
  47.  
  48. #define  INCL_BASE
  49. #define  INCL_WIN
  50. #define  INCL_GPI
  51. #define  INCL_DOS
  52. #define  INCL_WINSTDSPIN
  53. #define  INCL_GPIBITMAPS
  54.  
  55. #include <os2.h>
  56. #include <string.h>
  57. #include <stdio.h>
  58. #include <stdlib.h>
  59.  
  60. #include "samp1.h"
  61. #include "UCMenus.h"
  62. #include "UCMUtils.h"
  63.  
  64. #define APP_CLASS "UCMSamp"
  65. #define APP_TITLE "UC Menus Sample #1"
  66. #define ERRBOX(Owner,Title,Msg) WinMessageBox(HWND_DESKTOP,Owner,Msg,Title,0,MB_OK|MB_ERROR)
  67. #define MSGBOX(Owner,Title,Msg) WinMessageBox(HWND_DESKTOP,Owner,Msg,Title,0,MB_OK|MB_INFORMATION) /*! <Main> <Defines> 6 */
  68.  
  69. /* Global data */
  70. HWND CommandBar, ToolBar, ColorBar, DiskBar;   /* UC menu window handles */
  71. HWND FrameHwnd,  ClientHwnd;          /* Application window handles */
  72. HWND ActionMenu;                      /* Std PM text menu handle    */
  73. HAB  Hab;                             /* Application PM anchor block */
  74. HMQ  Hmq;                             /* Application msg queue handle */
  75.  
  76. /* Prototypes */
  77. MRESULT EXPENTRY ClientWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  78.  
  79. /******************************************************************************/
  80. int main(int argc,char **argv, char **envp)
  81. /******************************************************************************/
  82. /* The main routine just does basic PM initialization and creates a standard  */
  83. /* frame window.  All the work is done in the client window procedure below.  */
  84. /******************************************************************************/
  85. {
  86. QMSG    Qmsg;           /* PM Q message for dispatching */
  87. ULONG   FrameStyles;    /* Main frame window style flags */
  88.  
  89.    /* Initialize PM and get message queue */
  90.    /* NOTE! Need extra large queue when using UC menu controls */
  91.  
  92.    Hab = WinInitialize(0L);
  93.    Hmq = WinCreateMsgQueue(Hab, 50);
  94.  
  95.    MSGBOX(HWND_DESKTOP,"UC Menus Sample #1 (Standard PM Window) - Notes:",
  96.     "This sample is only intended to show the visual effects of various "
  97.     "menu style and placement options.  It is not fully functional (in "
  98.     "particular, some fields of the menu customization dialogs will appear "
  99.     "blank, checkable items are not toggled, and changes to the menus "
  100.     "are not saved).\n\nItems can be drag/dropped to rearrange menus or to move/copy "
  101.     "items between menus.\n\nDisk menu (on right edge) is UCS_STATIC "
  102.     "style and cannot be modified."
  103.     "\n\nSee Sample #2 for a complete menu implementation.");
  104.  
  105.    /* Create main application window */
  106.    WinRegisterClass(Hab, APP_CLASS, (PFNWP)ClientWindowProc, CS_SIZEREDRAW, sizeof(PVOID));
  107.    FrameStyles = FCF_TITLEBAR | FCF_SYSMENU | FCF_MENU | FCF_MINMAX | 
  108.                  FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_SIZEBORDER |
  109.                  FCF_ICON | FCF_AUTOICON | FCF_TASKLIST;
  110.    FrameHwnd = WinCreateStdWindow(HWND_DESKTOP, 0L, &FrameStyles,
  111.                  APP_CLASS, APP_TITLE, 0L, NULLHANDLE, ID_FRAME_RESOURCE, &ClientHwnd);
  112.  
  113.    /* Get and dispatch messages until application terminates */
  114.  
  115.    while (WinGetMsg(Hab, &Qmsg, NULLHANDLE, 0L, 0L ))
  116.       WinDispatchMsg(Hab, &Qmsg);
  117.  
  118.    /* Cleanup */
  119.    WinDestroyWindow(FrameHwnd);
  120.    WinDestroyMsgQueue(Hmq);
  121.    WinTerminate(Hab);
  122. }
  123.  
  124. /******************************************************************************/
  125. MRESULT EXPENTRY ClientWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  126. /******************************************************************************/
  127. /* This is the client window procedure.  During creation it will create the   */
  128. /* UC menus and place them as frame controls.  The client window will be      */
  129. /* filled with a bitmap, just for interest.                                   */
  130. /******************************************************************************/
  131. {
  132. static HPS     HpsBitmap;
  133. static HBITMAP Bitmap;
  134.  
  135. UCMINFO UCMInit;        /* UC menu initialization data */
  136. HWND    DummyHwnd;      /* Text menu handle (unused) */
  137. RECTL   Rect;           /* Rectangle for placement calculations */
  138. BITMAPINFOHEADER2 BitmapInfo;  /* Header info for bitmap */
  139.  
  140.   switch (msg) {
  141.  
  142.     case WM_CREATE:
  143.       /* Need these even before WinCreatStdWindow() completes */
  144.       ClientHwnd = hwnd;
  145.       FrameHwnd  = WinQueryWindow(hwnd, QW_PARENT);
  146.       ActionMenu = WinWindowFromID(FrameHwnd, FID_MENU);
  147.  
  148.       /* NOTE: To really do this well, the loading of the toolbar menus */
  149.       /* should really be done with another thread to keep from tying   */
  150.       /* up PM while all the bitmaps and such are loaded.               */
  151.  
  152.       /* Create graphic toolbars for edges of frame */
  153.     
  154.       memset(&UCMInit, 0x00, sizeof(UCMINFO));    /* Setup initialization data */
  155.       UCMInit.cb = sizeof(UCMINFO);
  156.       UCMInit.hModule = NULLHANDLE;         /* All resources are bound to EXE */
  157.       UCMInit.BgBmp   = 0x00CCCCCC;         /* Light grey is bkgnd color in bitmaps */
  158.       UCMInit.BgColor = 0x00B0B0B0;         /* Darker grey is toolbar background */
  159.       UCMInit.ItemBgColor = WinQuerySysColor(HWND_DESKTOP,SYSCLR_MENU,0L); /* Items are menu color */
  160.       UCMInit.BubbleDelay = 0L;             /* Instant bubble help */
  161.       UCMInit.BubbleRead = 3500L;           /* 3.5 seconds to autodismiss bubble help */
  162.     
  163.       UCMInit.Style   = UCS_FRAMED |        /* Use 3D effects */
  164.                         UCS_CHNGBMPBG_AUTO |/* Auto-detect bitmap background color */
  165.                         UCS_NODEFAULTACTION|/* Don't put 'exec pgm' on list of actions */
  166.                         UCS_CUSTOMHLP |     /* We will provide all help */
  167.                         UCS_BUBBLEHELP;     /* Enable bubble help */
  168.       CommandBar = UCMenuCreateFromResource(Hab,
  169.                     FrameHwnd,              /* Frame is parent of its controls */
  170.                     ClientHwnd,             /* Client will get messages */
  171.                     CMS_HORZ | WS_VISIBLE,  /* Horizontal orientation */
  172.                     0,0,0,0,                /* Size/position will be done by frame */
  173.                     HWND_TOP,               /* Put on top of siblings */
  174.                     ID_COMMANDBAR,          /* ID new menu will have */
  175.                     NULLHANDLE,             /* Resources come from EXE */
  176.                     ID_COMMANDBAR,          /* ID of menu template in resource file */
  177.                     &UCMInit,               /* Initialization data structure */
  178.                     &DummyHwnd);            /* Returned text menu handle (not used) */
  179.     
  180.       UCMInit.Style   = UCS_NOTEXT |        /* No text under bitmaps */
  181.                         UCS_CHNGBMPBG_AUTO |/* Auto-detect bitmap background color */
  182.                         UCS_CUSTOMHLP ;     /* We will provide all help */
  183.       UCMInit.ItemBgColor = 0x00B0B0B0;     /* Blend color dots into background */
  184.       ColorBar   = UCMenuCreateFromResource(Hab,
  185.                     FrameHwnd,              /* Frame is parent of its controls */
  186.                     ClientHwnd,             /* Client will get messages */
  187.                     CMS_HORZ,               /* Horizontal orientation */
  188.                     0,0,0,0,                /* Size/position will be done by frame */
  189.                     HWND_TOP,               /* Put on top of siblings */
  190.                     ID_COLORBAR,            /* ID new menu will have */
  191.                     NULLHANDLE,             /* Resources come from EXE */
  192.                     ID_COLORBAR,            /* ID of menu template in resource file */
  193.                     &UCMInit,               /* Initialization data structure */
  194.                     &DummyHwnd);            /* Returned text menu handle (not used) */
  195.  
  196.       UCMInit.ItemBgColor = WinQuerySysColor(HWND_DESKTOP,SYSCLR_MENU,0L); /* Items are menu color */
  197.       UCMInit.Style   = UCS_FRAMED |        /* No text under bitmaps */
  198.                         UCS_CHNGBMPBG_AUTO |/* Auto-detect bitmap background color */
  199.                         UCS_STATIC |        /* Allow no customizing of the menu */
  200.                         UCS_CUSTOMHLP ;     /* We will provide all help */
  201.       DiskBar    = UCMenuCreateFromResource(Hab,
  202.                     FrameHwnd,              /* Frame is parent of its controls */
  203.                     ClientHwnd,             /* Client will get messages */
  204.                     CMS_VERT,               /* Vertical orientation */
  205.                     0,0,0,0,                /* Size/position will be done by frame */
  206.                     HWND_TOP,               /* Put on top of siblings */
  207.                     ID_DISKBAR,             /* ID new menu will have */
  208.                     NULLHANDLE,             /* Resources come from EXE */
  209.                     ID_DISKBAR,             /* ID of menu template in resource file */
  210.                     &UCMInit,               /* Initialization data structure */
  211.                     &DummyHwnd);            /* Returned text menu handle (not used) */
  212.     
  213.       UCMInit.Style   = UCS_FRAMED |        /* Use 3D effects */
  214.                         UCS_NOTEXT |        /* No text under bitmaps */
  215.                         UCS_CHNGBMPBG_AUTO |/* Auto-detect bitmap background color */
  216.                         UCS_NODEFAULTACTION|/* Don't put 'exec pgm' on list of actions */
  217.                         UCS_CUSTOMHLP ;     /* We will provide all help */
  218.       UCMInit.NbOfCols=2;
  219.       UCMInit.NbOfRows=30; /* max */
  220.       ToolBar    = UCMenuCreateFromResource(Hab,
  221.                     FrameHwnd,              /* Frame is parent of its controls */
  222.                     ClientHwnd,             /* Client will get messages */
  223.                     CMS_MATRIX_VERT,        /* Vertical matrix menu */
  224.                     0,0,0,0,                /* Size/position will be done by frame */
  225.                     HWND_TOP,               /* Put on top of siblings */
  226.                     ID_TOOLBAR,             /* ID new menu will have */
  227.                     NULLHANDLE,             /* Resources come from EXE */
  228.                     ID_TOOLBAR,             /* ID of menu template in resource file */
  229.                     &UCMInit,               /* Initialization data structure */
  230.                     &DummyHwnd);            /* Returned text menu handle (not used) */
  231.     
  232.       /* Now make them frame controls so we will not have to worry about */
  233.       /* size or position of the menus as the window is sized.           */
  234.     
  235.       UCMUtilsAddToFrame(FrameHwnd, CommandBar, UCMUTILS_PLACE_TOP);
  236.       UCMUtilsAddToFrame(FrameHwnd, ToolBar,    UCMUTILS_PLACE_LEFT);
  237.       UCMUtilsAddToFrame(FrameHwnd, ColorBar,   UCMUTILS_PLACE_BOTTOM);
  238.       UCMUtilsAddToFrame(FrameHwnd, DiskBar,    UCMUTILS_PLACE_RIGHT);
  239.  
  240.       /* Update View-> submenu to indicate all toolbars are showing */
  241.       WinSendMsg(ActionMenu, MM_SETITEMATTR, MPFROM2SHORT(ID_ACTION_VIEWCMD, TRUE),   MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  242.       WinSendMsg(ActionMenu, MM_SETITEMATTR, MPFROM2SHORT(ID_ACTION_VIEWTOOL, TRUE),  MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  243.       WinSendMsg(ActionMenu, MM_SETITEMATTR, MPFROM2SHORT(ID_ACTION_VIEWCOLOR, TRUE), MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  244.       WinSendMsg(ActionMenu, MM_SETITEMATTR, MPFROM2SHORT(ID_ACTION_VIEWDISK, TRUE),  MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  245.  
  246.       /* Hardwire checkstate of some menu items, just for show */
  247.       WinSendMsg(ActionMenu, MM_SETITEMATTR, MPFROM2SHORT(ID_ACTION_ITALIC, TRUE),  MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  248.       WinSendMsg(ActionMenu, MM_SETITEMATTR, MPFROM2SHORT(ID_ACTION_CYAN,   TRUE),  MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  249.       UCMenuSetActionAttr(CommandBar, "Style: Italic", MIA_CHECKED, MIA_CHECKED);
  250.       UCMenuSetActionAttr(ColorBar,   "Color: Cyan",   MIA_CHECKED, MIA_CHECKED);
  251.  
  252.       /* Load bitmap for later display in the client area */
  253.       HpsBitmap = WinGetPS(hwnd);
  254.       Bitmap = GpiLoadBitmap(HpsBitmap, NULLHANDLE, ID_GALORE_BITMAP, 0L, 0L);
  255.  
  256.       /* Size frame such that client is natural size of bitmap */
  257.       BitmapInfo.cbFix = sizeof(BITMAPINFOHEADER2);
  258.       GpiQueryBitmapInfoHeader(Bitmap, &BitmapInfo);
  259.       Rect.yBottom = 0;
  260.       Rect.xLeft   = 0;
  261.       Rect.yTop    = BitmapInfo.cy;
  262.       Rect.xRight  = BitmapInfo.cx;
  263.       WinSendMsg(FrameHwnd, WM_CALCFRAMERECT, MPFROMP(&Rect), MPFROMSHORT(FALSE));
  264.       Rect.xRight  = Rect.xRight - Rect.xLeft;    /* Calculate CX */
  265.       Rect.yTop    = Rect.yTop   - Rect.yBottom;  /* Calculate CY */
  266.       Rect.xLeft = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)/2 - Rect.xRight/2;
  267.       Rect.yBottom=WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)/2 - Rect.yTop/2;
  268.  
  269.       WinSetWindowPos(FrameHwnd, HWND_TOP, 
  270.                       Rect.xLeft, Rect.yBottom,
  271.                       Rect.xRight,Rect.yTop,
  272.                       SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER | SWP_SIZE | SWP_MOVE);
  273.       return (MRESULT) FALSE;
  274.  
  275.     case WM_ACTIVATE:
  276.       /* Tell toolbars we are getting/losing focus */
  277.       WinSendMsg(CommandBar, UCMENU_ACTIVECHG, mp1, MPVOID);
  278.       WinSendMsg(ColorBar,   UCMENU_ACTIVECHG, mp1, MPVOID);
  279.       WinSendMsg(ToolBar,    UCMENU_ACTIVECHG, mp1, MPVOID);
  280.       WinSendMsg(DiskBar,    UCMENU_ACTIVECHG, mp1, MPVOID);
  281.       break;
  282.  
  283.     case WM_CONTROL:
  284.       switch (SHORT1FROMMP(mp1)) {   /* ID of windows sending msg */
  285.         case ID_TOOLBAR:
  286.         case ID_DISKBAR:
  287.         case ID_COMMANDBAR:
  288.         case ID_COLORBAR:            /* Any of the UC menus */
  289.           switch (SHORT2FROMMP(mp1)) {
  290.             case UCN_QRYBUBBLEHELP:{ /* CommandBar needs bubble help text */
  291.                /* Toolbar needs to know what bubble help text to display. */
  292.                /* We keep bubble help in the pszData field of the UCMITEM */
  293.                /* structure, passed to us via mp2.  Note we must return   */
  294.                /* a COPY which UCMenus will free when it is done with it. */
  295.                QBUBBLEDATA *BubbleInfo;
  296.                BubbleInfo = (QBUBBLEDATA *)mp2;
  297.  
  298.                if (UCMFIELD(BubbleInfo->MenuItem, pszData) != NULL)
  299.                  BubbleInfo->BubbleText = UCMenuStrdup(UCMFIELD(BubbleInfo->MenuItem, pszData));
  300.                return 0;
  301.                }
  302.  
  303.             case UCN_QRYDEFTEMPLATEID:
  304.               /* User wants to reload default menu config.  Tell UC menus */
  305.               /* what menu resource to load and replace current menu.     */
  306.               /* This is the ID we originally loaded, which is the same   */
  307.               /* as the ID of the UC menu window itself.                  */
  308.               *(USHORT *)mp2 = SHORT1FROMMP(mp1);
  309.               return (MRESULT)TRUE;
  310.             case UCN_QRYTEMPLATEMODULE:
  311.               /* Need to tell UCMenu where to module to load resources    */
  312.               /* from.  Return NULLHANDLE for EXE-bound resources.        */
  313.               *(HMODULE *)mp2 = NULLHANDLE;
  314.               return (MRESULT)TRUE;
  315.            }
  316.       }
  317.       break;
  318.  
  319.     case WM_COMMAND: {
  320.       /* Process messages from normal PM text bar */
  321.       USHORT Attr, MenuPlace;
  322.       HWND   MenuHwnd;
  323.       /* Toggle visibility of the four tool menus */
  324.       switch (SHORT1FROMMP(mp1)){
  325.         case ID_ACTION_VIEWCMD:
  326.         case ID_ACTION_VIEWTOOL:
  327.         case ID_ACTION_VIEWCOLOR:
  328.         case ID_ACTION_VIEWDISK:
  329.           Attr = (SHORT)WinSendMsg(ActionMenu, MM_QUERYITEMATTR,
  330.                             MPFROM2SHORT(SHORT1FROMMP(mp1),TRUE),
  331.                             MPFROMSHORT(MIA_CHECKED));
  332.           Attr = Attr ^ MIA_CHECKED;
  333.           WinSendMsg(ActionMenu, MM_SETITEMATTR,
  334.                             MPFROM2SHORT(SHORT1FROMMP(mp1),TRUE),
  335.                             MPFROM2SHORT(MIA_CHECKED, Attr));
  336.           switch (SHORT1FROMMP(mp1)){
  337.             case ID_ACTION_VIEWCMD:
  338.               MenuHwnd = CommandBar;
  339.               MenuPlace= UCMUTILS_PLACE_TOP;
  340.               break;
  341.             case ID_ACTION_VIEWTOOL:
  342.               MenuHwnd = ToolBar;
  343.               MenuPlace= UCMUTILS_PLACE_LEFT;
  344.               break;
  345.             case ID_ACTION_VIEWCOLOR:
  346.               MenuHwnd = ColorBar;
  347.               MenuPlace= UCMUTILS_PLACE_BOTTOM;
  348.               break;
  349.             case ID_ACTION_VIEWDISK:
  350.               MenuHwnd = DiskBar;
  351.               MenuPlace= UCMUTILS_PLACE_RIGHT;
  352.               break;
  353.           }
  354.           if (Attr & MIA_CHECKED)  /* Add or remove menu from frame */
  355.             UCMUtilsAddToFrame(FrameHwnd, MenuHwnd, MenuPlace);
  356.             else UCMUtilsRemoveFromFrame(FrameHwnd, MenuHwnd);
  357.       }
  358.       }
  359.       return;
  360.  
  361.     case WM_DESTROY:
  362.       /* Release resources */
  363.       GpiDeleteBitmap(Bitmap);
  364.       WinReleasePS(HpsBitmap);
  365.       break;
  366.  
  367.     case WM_PAINT: {
  368.         /* Draw bitmap previously loaded into whole client window.  Note  */
  369.         /* that since the menu bars are frame controls, we do not have to */
  370.         /* account for them in the size of the client window (e.g. they   */
  371.         /* are outside the client window).                                */
  372.         SWP swp;
  373.         RECTL rc;
  374.         HPS Hps;
  375.  
  376.         Hps = WinBeginPaint(hwnd, NULLHANDLE, (PRECTL)NULL);
  377.         /* Get size of client window and draw bitmap into it */
  378.         WinQueryWindowPos(hwnd, &swp);
  379.         rc.xLeft   = 0;
  380.         rc.yBottom = 0;
  381.         rc.xRight  = swp.cx;
  382.         rc.yTop    = swp.cy;
  383.         WinDrawBitmap(Hps, Bitmap, NULL, (POINTL *)&rc, 0L, 0L,
  384.                       DBM_STRETCH | DBM_IMAGEATTRS);
  385.         WinEndPaint(Hps);
  386.       }
  387.       return 0;
  388. #if defined(ALTERNATE_PAINT)
  389.     case WM_PAINT: {
  390.         /* Draw box around edge and X through center of  window.    Note  */
  391.         /* that since the menu bars are frame controls, we do not have to */
  392.         /* account for them in the size of the client window (e.g. they   */
  393.         /* are outside the client window).                                */
  394.         HPS hPS;
  395.         POINTL Point;
  396.         SWP    ClientPos;
  397.  
  398.         hPS = WinBeginPaint(hwnd, (HPS)NULL, (PRECTL)0);
  399.         GpiErase( hPS );
  400.         GpiSetColor(hPS, CLR_GREEN);
  401.         Point.x = 0;
  402.         Point.y = 0;
  403.         GpiSetCurrentPosition(hPS, &Point);
  404.         WinQueryWindowPos(hwnd, &ClientPos);
  405.         Point.x = max(1, ClientPos.cx-2);
  406.         Point.y = max(1, ClientPos.cy-2);
  407.         GpiBox(hPS, DRO_OUTLINE, &Point, 0L, 0L);
  408.         GpiLine(hPS, &Point);
  409.         Point.x = 0;             /* Point to upper-left corner */
  410.         GpiSetCurrentPosition(hPS, &Point);
  411.         Point.y = 0;
  412.         Point.x = ClientPos.cx;  /* Lower right */
  413.         GpiLine(hPS, &Point);
  414.  
  415.         WinEndPaint( hPS );
  416.       }
  417.       return 0;
  418. #endif /* ALTERNATE_PAINT */
  419.  
  420.   } /* msg switch */
  421.   return  WinDefWindowProc(hwnd, msg, mp1, mp2 );
  422. }
  423.  
  424.