home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / REXX / CMD / EDMI7.ZIP / DROPME.ZIP / DROPME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-16  |  19.0 KB  |  510 lines

  1. #define INCL_WININPUT
  2. #define INCL_WINSTDCNR
  3. #define INCL_WINSTDDRAG
  4. #define INCL_WINSYS
  5. #define INCL_WINWINDOWMGR
  6. #include "defs.h"
  7. #include <stdlib.h>
  8. #include <string.h>
  9.  
  10. BOOL initContainer(PINSTDATA pidData)
  11. //-------------------------------------------------------------------------
  12. // This function initializes the container in detail view by allocating
  13. // and inserting the FIELDINFO structures.
  14. //
  15. // Input:  pidData - points to the instance data of the application
  16. // Returns:  TRUE/FALSE success indicator
  17. //-------------------------------------------------------------------------
  18. {
  19.    PFIELDINFO pfiDetails;
  20.    PFIELDINFO pfiCurrent;
  21.    FIELDINFOINSERT fiiDetails;
  22.    CNRINFO ciInfo;
  23.  
  24.    pfiDetails=(PFIELDINFO)PVOIDFROMMR(WinSendMsg(pidData->hwndCnr,
  25.                                                  CM_ALLOCDETAILFIELDINFO,
  26.                                                  MPFROMSHORT(MAX_DETAILFIELDS),
  27.                                                  0));
  28.    if (pfiDetails==NULL) {
  29.       return FALSE;
  30.    } /* endif */
  31.  
  32.    //----------------------------------------------------------------------
  33.    // Initialize each FIELDINFO structure.  (Sigh) I wish there were a
  34.    // way to condense this a bit.
  35.    //----------------------------------------------------------------------
  36.    pfiCurrent=pfiDetails;
  37.  
  38.    pfiCurrent->cb=sizeof(FIELDINFO);
  39.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  40.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  41.    pfiCurrent->pTitleData=pidData->achTtlHwndItem;
  42.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchHwndItem);
  43.    pfiCurrent->pUserData=NULL;
  44.  
  45.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  46.  
  47.    pfiCurrent->cb=sizeof(FIELDINFO);
  48.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  49.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  50.    pfiCurrent->pTitleData=pidData->achTtlUlItemID;
  51.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchUlItemID);
  52.    pfiCurrent->pUserData=NULL;
  53.  
  54.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  55.  
  56.    pfiCurrent->cb=sizeof(FIELDINFO);
  57.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  58.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  59.    pfiCurrent->pTitleData=pidData->achTtlHstrType;
  60.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchHstrType);
  61.    pfiCurrent->pUserData=NULL;
  62.  
  63.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  64.  
  65.    pfiCurrent->cb=sizeof(FIELDINFO);
  66.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  67.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  68.    pfiCurrent->pTitleData=pidData->achTtlHstrRMF;
  69.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchHstrRMF);
  70.    pfiCurrent->pUserData=NULL;
  71.  
  72.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  73.  
  74.    pfiCurrent->cb=sizeof(FIELDINFO);
  75.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  76.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  77.    pfiCurrent->pTitleData=pidData->achTtlHstrContainerName;
  78.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchHstrContainerName);
  79.    pfiCurrent->pUserData=NULL;
  80.  
  81.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  82.  
  83.    pfiCurrent->cb=sizeof(FIELDINFO);
  84.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  85.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  86.    pfiCurrent->pTitleData=pidData->achTtlHstrSourceName;
  87.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchHstrSourceName);
  88.    pfiCurrent->pUserData=NULL;
  89.  
  90.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  91.  
  92.    pfiCurrent->cb=sizeof(FIELDINFO);
  93.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  94.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  95.    pfiCurrent->pTitleData=pidData->achTtlHstrTargetName;
  96.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchHstrTargetName);
  97.    pfiCurrent->pUserData=NULL;
  98.  
  99.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  100.  
  101.    pfiCurrent->cb=sizeof(FIELDINFO);
  102.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  103.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  104.    pfiCurrent->pTitleData=pidData->achTtlCxOffset;
  105.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchCxOffset);
  106.    pfiCurrent->pUserData=NULL;
  107.  
  108.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  109.  
  110.    pfiCurrent->cb=sizeof(FIELDINFO);
  111.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  112.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  113.    pfiCurrent->pTitleData=pidData->achTtlCyOffset;
  114.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchCyOffset);
  115.    pfiCurrent->pUserData=NULL;
  116.  
  117.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  118.  
  119.    pfiCurrent->cb=sizeof(FIELDINFO);
  120.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  121.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  122.    pfiCurrent->pTitleData=pidData->achTtlFsControl;
  123.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchFsControl);
  124.    pfiCurrent->pUserData=NULL;
  125.  
  126.    pfiCurrent=pfiCurrent->pNextFieldInfo;
  127.  
  128.    pfiCurrent->cb=sizeof(FIELDINFO);
  129.    pfiCurrent->flData=CFA_STRING|CFA_HORZSEPARATOR|CFA_SEPARATOR;
  130.    pfiCurrent->flTitle=CFA_LEFT|CFA_VCENTER;
  131.    pfiCurrent->pTitleData=pidData->achTtlFsSupportedOps;
  132.    pfiCurrent->offStruct=FIELDOFFSET(CNRRECORD,iiInfo.pchFsSupportedOps);
  133.    pfiCurrent->pUserData=NULL;
  134.  
  135.    //----------------------------------------------------------------------
  136.    // Insert the FIELDINFO structures and change to detail view
  137.    //----------------------------------------------------------------------
  138.    fiiDetails.cb=sizeof(FIELDINFOINSERT);
  139.    fiiDetails.pFieldInfoOrder=(PFIELDINFO)CMA_FIRST;
  140.    fiiDetails.fInvalidateFieldInfo=TRUE;
  141.    fiiDetails.cFieldInfoInsert=MAX_DETAILFIELDS;
  142.  
  143.    WinSendMsg(pidData->hwndCnr,
  144.               CM_INSERTDETAILFIELDINFO,
  145.               MPFROMP(pfiDetails),
  146.               MPFROMP(&fiiDetails));
  147.  
  148.    ciInfo.flWindowAttr=CV_DETAIL|CA_DETAILSVIEWTITLES;
  149.  
  150.    WinSendMsg(pidData->hwndCnr,
  151.               CM_SETCNRINFO,
  152.               MPFROMP(&ciInfo),
  153.               MPFROMLONG(CMA_FLWINDOWATTR));
  154.  
  155.    return TRUE;
  156. }
  157.  
  158. BOOL displayDragitems(PDRAGINFO pdiInfo,HWND hwndCnr)
  159. //-------------------------------------------------------------------------
  160. // This function adds the contents of the linked list to the container.
  161. // 'Tis rather trivial.
  162. //
  163. // Input:  pdiInfo - points to the DRAGINFO structure of the items being
  164. //                   dragged
  165. //         hwndCnr - handle of the container window
  166. // Returns:  TRUE/FALSE success indicator
  167. //-------------------------------------------------------------------------
  168. {
  169.    PCNRRECORD pcrRecords;
  170.    PCNRRECORD pcrCurrent;
  171.    USHORT usIndex;
  172.    DRAGITEM diItem;
  173.    CHAR achField[256];
  174.    RECORDINSERT riInsert;
  175.  
  176.    //----------------------------------------------------------------------
  177.    // Get the number of records to insert and allocate them from the
  178.    // container.
  179.    //----------------------------------------------------------------------
  180.    pcrRecords=(PCNRRECORD)PVOIDFROMMR(WinSendMsg(hwndCnr,
  181.                                                  CM_ALLOCRECORD,
  182.                                                  MPFROMLONG(sizeof(CNRRECORD)-sizeof(MINIRECORDCORE)),
  183.                                                  MPFROMSHORT(pdiInfo->cditem)));
  184.    if (pcrRecords==NULL) {
  185.       return FALSE;
  186.    } /* endif */
  187.  
  188.    //----------------------------------------------------------------------
  189.    // Loop and initialize each record.
  190.    //----------------------------------------------------------------------
  191.    pcrCurrent=pcrRecords;
  192.  
  193.    for (usIndex=0; usIndex<pdiInfo->cditem; usIndex++) {
  194.       DrgQueryDragitem(pdiInfo,sizeof(diItem),&diItem,usIndex);
  195.  
  196.       pcrCurrent->mrcCore.pszIcon=(PSZ)&pcrCurrent->iiInfo;
  197.       pcrCurrent->mrcCore.hptrIcon=NULLHANDLE;
  198.       memset(&pcrCurrent->iiInfo,0,sizeof(ITEMINFO));
  199.  
  200.       sprintf(pcrCurrent->iiInfo.achHwndItem,"0x%08lX",diItem.hwndItem);
  201.       sprintf(pcrCurrent->iiInfo.achUlItemID,"%ld",diItem.ulItemID);
  202.  
  203.       DrgQueryStrName(diItem.hstrType,sizeof(achField),achField);
  204.       sprintf(pcrCurrent->iiInfo.achHstrType,"\"%s\"",achField);
  205.  
  206.       DrgQueryStrName(diItem.hstrRMF,sizeof(achField),achField);
  207.       sprintf(pcrCurrent->iiInfo.achHstrRMF,"\"%s\"",achField);
  208.  
  209.       DrgQueryStrName(diItem.hstrContainerName,sizeof(achField),achField);
  210.       sprintf(pcrCurrent->iiInfo.achHstrContainerName,"\"%s\"",achField);
  211.  
  212.       DrgQueryStrName(diItem.hstrSourceName,sizeof(achField),achField);
  213.       sprintf(pcrCurrent->iiInfo.achHstrSourceName,"\"%s\"",achField);
  214.  
  215.       DrgQueryStrName(diItem.hstrTargetName,sizeof(achField),achField);
  216.       sprintf(pcrCurrent->iiInfo.achHstrTargetName,"\"%s\"",achField);
  217.  
  218.       sprintf(pcrCurrent->iiInfo.achCxOffset,"%d",diItem.cxOffset);
  219.       sprintf(pcrCurrent->iiInfo.achCyOffset,"%d",diItem.cyOffset);
  220.       sprintf(pcrCurrent->iiInfo.achFsControl,"0x%04X",diItem.fsControl);
  221.       sprintf(pcrCurrent->iiInfo.achFsSupportedOps,
  222.               "0x%04X",
  223.               diItem.fsSupportedOps);
  224.  
  225.       pcrCurrent->iiInfo.pchHwndItem=
  226.          pcrCurrent->iiInfo.achHwndItem;
  227.       pcrCurrent->iiInfo.pchUlItemID=
  228.          pcrCurrent->iiInfo.achUlItemID;
  229.       pcrCurrent->iiInfo.pchHstrType=
  230.          pcrCurrent->iiInfo.achHstrType;
  231.       pcrCurrent->iiInfo.pchHstrRMF=
  232.          pcrCurrent->iiInfo.achHstrRMF;
  233.       pcrCurrent->iiInfo.pchHstrContainerName=
  234.          pcrCurrent->iiInfo.achHstrContainerName;
  235.       pcrCurrent->iiInfo.pchHstrSourceName=
  236.          pcrCurrent->iiInfo.achHstrSourceName;
  237.       pcrCurrent->iiInfo.pchHstrTargetName=
  238.          pcrCurrent->iiInfo.achHstrTargetName;
  239.       pcrCurrent->iiInfo.pchCxOffset=
  240.          pcrCurrent->iiInfo.achCxOffset;
  241.       pcrCurrent->iiInfo.pchCyOffset=
  242.          pcrCurrent->iiInfo.achCyOffset;
  243.       pcrCurrent->iiInfo.pchFsControl=
  244.          pcrCurrent->iiInfo.achFsControl;
  245.       pcrCurrent->iiInfo.pchFsSupportedOps=
  246.          pcrCurrent->iiInfo.achFsSupportedOps;
  247.  
  248.       pcrCurrent=(PCNRRECORD)pcrCurrent->mrcCore.preccNextRecord;
  249.    } /* endfor */
  250.  
  251.    //----------------------------------------------------------------------
  252.    // Delete the current records and insert the new records.
  253.    //----------------------------------------------------------------------
  254.    WinSendMsg(hwndCnr,CM_REMOVERECORD,MPFROMP(NULL),MPFROM2SHORT(0,CMA_FREE));
  255.  
  256.    riInsert.cb=sizeof(RECORDINSERT);
  257.    riInsert.pRecordOrder=(PRECORDCORE)CMA_END;
  258.    riInsert.pRecordParent=NULL;
  259.    riInsert.fInvalidateRecord=TRUE;
  260.    riInsert.zOrder=CMA_TOP;
  261.    riInsert.cRecordsInsert=pdiInfo->cditem;
  262.  
  263.    WinSendMsg(hwndCnr,
  264.               CM_INSERTRECORD,
  265.               MPFROMP(pcrRecords),
  266.               MPFROMP(&riInsert));
  267.    return TRUE;
  268. }
  269.  
  270. MRESULT EXPENTRY wndProc(HWND hwndWnd,
  271.                          ULONG ulMsg,
  272.                          MPARAM mpParm1,
  273.                          MPARAM mpParm2)
  274. {
  275.    PINSTDATA pidData;
  276.  
  277.    pidData=(PINSTDATA)WinQueryWindowPtr(hwndWnd,0);
  278.  
  279.    switch (ulMsg) {
  280.    case WM_CREATE:
  281.       {
  282.          CHAR achFont[32];
  283.  
  284.          pidData=calloc(1,sizeof(INSTDATA));
  285.          if (pidData==NULL) {
  286.             WinAlarm(HWND_DESKTOP,WA_ERROR);
  287.             return MRFROMSHORT(TRUE);
  288.          } /* endif */
  289.  
  290.          WinSetWindowPtr(hwndWnd,0,pidData);
  291.  
  292.          pidData->ulSzStruct=sizeof(INSTDATA);
  293.          pidData->habAnchor=WinQueryAnchorBlock(hwndWnd);
  294.          pidData->hwndFrame=WinQueryWindow(hwndWnd,QW_PARENT);
  295.          pidData->bEndDrag=TRUE;
  296.  
  297.          pidData->hwndCnr=WinCreateWindow(hwndWnd,
  298.                                           WC_CONTAINER,
  299.                                           "",
  300.                                           CCS_EXTENDSEL | CCS_MINIRECORDCORE,
  301.                                           0,
  302.                                           0,
  303.                                           0,
  304.                                           0,
  305.                                           hwndWnd,
  306.                                           HWND_TOP,
  307.                                           WND_CNR,
  308.                                           NULL,
  309.                                           NULL);
  310.          if (pidData->hwndCnr==NULLHANDLE) {
  311.             WinAlarm(HWND_DESKTOP,WA_ERROR);
  312.             free(pidData);
  313.             return MRFROMSHORT(TRUE);
  314.          } /* endif */
  315.  
  316.          strcpy(achFont,"8.Helv");
  317.          WinSetPresParam(pidData->hwndCnr,
  318.                          PP_FONTNAMESIZE,
  319.                          strlen(achFont)+1,
  320.                          achFont);
  321.  
  322.          //----------------------------------------------------------------
  323.          // Since the container does not copy detail view titles into its
  324.          // own global space, we must keep them in our instance data, so
  325.          // initialize the strings from the STRINGTABLE.
  326.          //----------------------------------------------------------------
  327.          WinLoadString(pidData->habAnchor,
  328.                        NULLHANDLE,
  329.                        STR_TTLHWNDITEM,
  330.                        sizeof(pidData->achTtlHwndItem),
  331.                        pidData->achTtlHwndItem);
  332.  
  333.          WinLoadString(pidData->habAnchor,
  334.                        NULLHANDLE,
  335.                        STR_TTLULITEMID,
  336.                        sizeof(pidData->achTtlUlItemID),
  337.                        pidData->achTtlUlItemID);
  338.  
  339.          WinLoadString(pidData->habAnchor,
  340.                        NULLHANDLE,
  341.                        STR_TTLHSTRTYPE,
  342.                        sizeof(pidData->achTtlHstrType),
  343.                        pidData->achTtlHstrType);
  344.  
  345.          WinLoadString(pidData->habAnchor,
  346.                        NULLHANDLE,
  347.                        STR_TTLHSTRRMF,
  348.                        sizeof(pidData->achTtlHstrRMF),
  349.                        pidData->achTtlHstrRMF);
  350.  
  351.          WinLoadString(pidData->habAnchor,
  352.                        NULLHANDLE,
  353.                        STR_TTLHSTRCONTAINERNAME,
  354.                        sizeof(pidData->achTtlHstrContainerName),
  355.                        pidData->achTtlHstrContainerName);
  356.  
  357.          WinLoadString(pidData->habAnchor,
  358.                        NULLHANDLE,
  359.                        STR_TTLHSTRSOURCENAME,
  360.                        sizeof(pidData->achTtlHstrSourceName),
  361.                        pidData->achTtlHstrSourceName);
  362.  
  363.          WinLoadString(pidData->habAnchor,
  364.                        NULLHANDLE,
  365.                        STR_TTLHSTRTARGETNAME,
  366.                        sizeof(pidData->achTtlHstrTargetName),
  367.                        pidData->achTtlHstrTargetName);
  368.  
  369.          WinLoadString(pidData->habAnchor,
  370.                        NULLHANDLE,
  371.                        STR_TTLCXOFFSET,
  372.                        sizeof(pidData->achTtlCxOffset),
  373.                        pidData->achTtlCxOffset);
  374.  
  375.          WinLoadString(pidData->habAnchor,
  376.                        NULLHANDLE,
  377.                        STR_TTLCYOFFSET,
  378.                        sizeof(pidData->achTtlCyOffset),
  379.                        pidData->achTtlCyOffset);
  380.  
  381.          WinLoadString(pidData->habAnchor,
  382.                        NULLHANDLE,
  383.                        STR_TTLFSCONTROL,
  384.                        sizeof(pidData->achTtlFsControl),
  385.                        pidData->achTtlFsControl);
  386.  
  387.          WinLoadString(pidData->habAnchor,
  388.                        NULLHANDLE,
  389.                        STR_TTLFSSUPPORTEDOPS,
  390.                        sizeof(pidData->achTtlFsSupportedOps),
  391.                        pidData->achTtlFsSupportedOps);
  392.  
  393.          initContainer(pidData);
  394.       }
  395.       break;
  396.    case WM_DESTROY:
  397.       WinDestroyWindow(pidData->hwndCnr);
  398.       free(pidData);
  399.       break;
  400.    case WM_SIZE:
  401.       WinSetWindowPos(pidData->hwndCnr,
  402.                       NULLHANDLE,
  403.                       0,
  404.                       0,
  405.                       SHORT1FROMMP(mpParm2),
  406.                       SHORT2FROMMP(mpParm2),
  407.                       SWP_MOVE|SWP_SIZE|SWP_SHOW);
  408.       break;
  409.    case WM_CONTROL:
  410.       if (SHORT1FROMMP(mpParm1)==WND_CNR) {
  411.          switch (SHORT2FROMMP(mpParm1)) {
  412.          case CN_DRAGOVER:
  413.             {
  414.                PCNRDRAGINFO pcdiDrag;
  415.  
  416.                //----------------------------------------------------------
  417.                // If the drag operation is still in progress, don't
  418.                // reinitialize
  419.                //----------------------------------------------------------
  420.                if (pidData->bEndDrag) {
  421.                   pidData->bEndDrag=FALSE;
  422.                   pcdiDrag=(PCNRDRAGINFO)PVOIDFROMMP(mpParm2);
  423.                   displayDragitems(pcdiDrag->pDragInfo,pidData->hwndCnr);
  424.                } /* endif */
  425.  
  426.                return MRFROM2SHORT(DOR_NODROP,DO_DEFAULT);
  427.             }
  428.             break;
  429.          case CN_DRAGLEAVE:
  430.             //-------------------------------------------------------------
  431.             // We will receive this whenever a) the mouse moves outside
  432.             // of the container, b) the mouse button was released, or c)
  433.             // the user presses ESC.  Flag the drag operation as completed.
  434.             //-------------------------------------------------------------
  435.             if (!pidData->bEndDrag) {
  436.                pidData->bEndDrag=TRUE;
  437.             } /* endif */
  438.             break;
  439.          default:
  440.             return WinDefWindowProc(hwndWnd,ulMsg,mpParm1,mpParm2);
  441.          } /* endswitch */
  442.       } else {
  443.          return WinDefWindowProc(hwndWnd,ulMsg,mpParm1,mpParm2);
  444.       } /* endif */
  445.       break;
  446.    case WM_PAINT:
  447.       {
  448.          HPS hpsPaint;
  449.          RECTL rclPaint;
  450.  
  451.          hpsPaint=WinBeginPaint(hwndWnd,NULLHANDLE,&rclPaint);
  452.          WinFillRect(hpsPaint,&rclPaint,SYSCLR_WINDOW);
  453.          WinEndPaint(hpsPaint);
  454.       }
  455.       break;
  456.    default:
  457.       return WinDefWindowProc(hwndWnd,ulMsg,mpParm1,mpParm2);
  458.    } /* endswitch */
  459.  
  460.    return MRFROMSHORT(FALSE);
  461. }
  462.  
  463. INT main(VOID)
  464. //-------------------------------------------------------------------------
  465. // Typical PM main() function.
  466. //-------------------------------------------------------------------------
  467. {
  468.    HAB habAnchor;
  469.    HMQ hmqQueue;
  470.    CHAR achTitle[64];
  471.    ULONG ulCreate;
  472.    HWND hwndFrame;
  473.    HWND hwndClient;
  474.    BOOL bLoop;
  475.    QMSG qmMsg;
  476.  
  477.    habAnchor=WinInitialize(0);
  478.    hmqQueue=WinCreateMsgQueue(habAnchor,0);
  479.  
  480.    WinRegisterClass(habAnchor,CLS_CLIENT,wndProc,0,sizeof(PVOID));
  481.  
  482.    WinLoadString(habAnchor,NULLHANDLE,STR_TITLE,sizeof(achTitle),achTitle);
  483.  
  484.    ulCreate=FCF_SYSMENU | FCF_TITLEBAR | FCF_MINMAX | FCF_SIZEBORDER |
  485.                FCF_SHELLPOSITION | FCF_TASKLIST;
  486.  
  487.    hwndFrame=WinCreateStdWindow(HWND_DESKTOP,
  488.                                 WS_VISIBLE,
  489.                                 &ulCreate,
  490.                                 CLS_CLIENT,
  491.                                 achTitle,
  492.                                 0,
  493.                                 NULLHANDLE,
  494.                                 RES_CLIENT,
  495.                                 &hwndClient);
  496.    if (hwndFrame!=NULLHANDLE) {
  497.       bLoop=WinGetMsg(habAnchor,&qmMsg,NULLHANDLE,0,0);
  498.       while (bLoop) {
  499.          WinDispatchMsg(habAnchor,&qmMsg);
  500.          bLoop=WinGetMsg(habAnchor,&qmMsg,NULLHANDLE,0,0);
  501.       } /* endwhile */
  502.  
  503.       WinDestroyWindow(hwndFrame);
  504.    } /* endif */
  505.  
  506.    WinDestroyMsgQueue(hmqQueue);
  507.    WinTerminate(habAnchor);
  508.    return 0;
  509. }
  510.