home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DRAGIN.ZIP / DRAGDLG.C next >
Text File  |  1993-02-15  |  10KB  |  331 lines

  1. /***************************************************************************/
  2. /* Dialog module for DRAGINFO                                              */
  3. /***************************************************************************/
  4. #include "draginfo.h"
  5.  
  6.  
  7. static char *apcReturn[][2] = {
  8.    { "DRR_SOURCE",  (char *)DRR_SOURCE },
  9.    { "DRR_TARGET",  (char *)DRR_TARGET },
  10.    { "DRR_ABORT",   (char *)DRR_ABORT },
  11.    { NULL, NULL }
  12. };
  13.  
  14. static char *apcControl[][2] = {
  15.    { "DC_OPEN",              (char *)DC_OPEN },
  16.    { "DC_REF",               (char *)DC_REF },
  17.    { "DC_GROUP",             (char *)DC_GROUP },
  18.    { "DC_CONTAINER",         (char *)DC_CONTAINER },
  19.    { "DC_PREPARE",           (char *)DC_PREPARE },
  20.    { "DC_REMOVEABLEMEDIA",   (char *)DC_REMOVEABLEMEDIA },
  21.    { NULL, NULL }
  22. };
  23. static char *apcOperations[][2] = {
  24.   {"DO_DEFAULT", (char *)DO_DEFAULT },
  25.   {"DO_COPY",    (char *)DO_COPY },
  26.   {"DO_LINK",    (char *)DO_LINK },
  27.   {"DO_MOVE",    (char *)DO_MOVE },
  28.   {"DO_CREATE",  (char *)DO_CREATE },
  29.   {"DO_UNKNOWN", (char *)DO_UNKNOWN },
  30.   { NULL, NULL }
  31. };
  32. static char *apcTypes[][2] = {
  33.   {"DRT_TEXT",               "Plain Text"},
  34.   {"DRT_UNKNOWN",            "Unknown"},
  35.   {"DRT_TEXT(obj)",          "DRT_TEXT" },
  36.   {"DRT_ASM",                "Assembler Code"},
  37.   {"DRT_BASIC",              "BASIC Code"},
  38.   {"DRT_BINDATA",            "Binary Data"},
  39.   {"DRT_BITMAP",             "Bitmap"},
  40.   {"DRT_C",                  "C Code"},
  41.   {"DRT_COBOL",              "COBOL Code"},
  42.   {"DRT_DLL",                "Dynamic Link Library"},
  43.   {"DRT_DOSCMD",             "DOS Command File"},
  44.   {"DRT_EXE",                "Executable"},
  45.   {"DRT_FORTRAN",            "FORTRAN Code"},
  46.   {"DRT_ICON",               "Icon"},
  47.   {"DRT_LIB",                "Library"},
  48.   {"DRT_METAFILE",           "Metafile"},
  49.   {"DRT_OS2CMD",             "OS/2 Command File"},
  50.   {"DRT_PASCAL",             "Pascal Code"},
  51.   {"DRT_RESOURCE",           "Resource File"},
  52.   { NULL, NULL }
  53. };
  54. static char *apcMechanisms[] = {
  55.   "DRM_OS2FILE",
  56.   "DRM_PRINT",
  57.   "DRM_DDE",
  58.   "DRM_OBJECT",
  59.   "DRM_DISCARD",
  60.   NULL
  61. };
  62. static char *apcFormats[] = {
  63.   "DRF_TEXT",
  64.   "DRF_UNKNOWN",
  65.   "DRF_OBJECT",
  66.   "DRF_BITMAP",
  67.   "DRF_DIB",
  68.   "DRF_DIF",
  69.   "DRF_DSPBITMAP",
  70.   "DRF_METAFILE",
  71.   "DRF_OEMTEXT",
  72.   "DRF_QWNERDISPLAY",
  73.   "DRF_PTRPICT",
  74.   "DRF_RTF",
  75.   "DRF_SYLK",
  76.   "DRF_TIFF",
  77.   NULL
  78. };
  79.  
  80. /*************************/
  81. /* exportierte Variablen */
  82. /*************************/
  83. BOOL   bDrgDrag       = TRUE;
  84. BOOL   bSourceRender  = TRUE;
  85. USHORT usDrgControl   = DC_OPEN;
  86. USHORT usDrgOperation = DO_DEFAULT;
  87. USHORT usDrgReturn    = DRR_SOURCE;
  88. PSZ    szDrgType      = DRT_TEXT;
  89. CHAR   szDrgRMF[100]  = "<DRM_OS2FILE, DRF_TEXT>";
  90. CHAR   szPath[CCHMAXPATHCOMP] = "D:\\TMP\\";
  91. CHAR   szFile[256] = "TEST.TXT";
  92. CHAR   szFilePath[CCHMAXPATHCOMP] = "D:\\TMP\\TEST.TXT";
  93.  
  94. static USHORT unRe=0;
  95. static USHORT unOp=0;
  96. static USHORT unTy=0;
  97. static USHORT unMe=0;
  98. static USHORT unFo=0;
  99.  
  100.  
  101. USHORT InitConfigDlg( HWND hwnd );
  102. void SetInfoParams( HWND hwnd );
  103.  
  104.  
  105. /*******************************************/
  106. /*Dialogprozedur für Konfigurations-Dialog */
  107. /*******************************************/
  108. MRESULT EXPENTRY 
  109. wpConfDrgDragFiles( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  110. {
  111.   switch( msg )
  112.   {
  113.   case WM_INITDLG:
  114.     WinSendDlgItemMsg( hwnd, RB_SOURCETRUE, BM_SETCHECK, 
  115.                        (MPARAM)bSourceRender, 0L );
  116.     WinSendDlgItemMsg( hwnd, RB_SOURCEFALSE, BM_SETCHECK,
  117.                        (MPARAM)(!bSourceRender), 0L );
  118.     WinSetDlgItemText( hwnd, EF_FILEPATH, szFilePath );
  119.     break;
  120.   case WM_COMMAND:                 
  121.     switch( SHORT1FROMMP( mp1 ) )
  122.     {
  123.     case DID_OK:
  124.       bSourceRender = (BOOL)WinSendDlgItemMsg( hwnd, RB_SOURCETRUE,
  125.                                          BM_QUERYCHECK, 0L, 0L );
  126.       WinQueryDlgItemText( hwnd, EF_FILEPATH, 100L, szFilePath );
  127.     case DID_CANCEL:
  128.       WinDismissDlg( hwnd, TRUE );  /* Remove the dialog box    */
  129.       break;
  130.     }
  131.   default:
  132.     return WinDefDlgProc( hwnd, msg, mp1, mp2 );
  133.   }
  134.   return (MRESULT) FALSE;
  135. }
  136.  
  137. /*******************************************/
  138. /*Dialogprozedur für Konfigurations-Dialog */
  139. /*******************************************/
  140. MRESULT EXPENTRY 
  141. wpConfDrgDrag( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  142. {
  143.   switch ( msg )
  144.   {
  145.   case WM_INITDLG:
  146.      InitConfigDlg(hwnd);
  147.      break;
  148.  
  149.   case WM_COMMAND:                 /* Posted by pushbutton or key  */
  150.     switch( SHORT1FROMMP( mp1 ) )     
  151.     {
  152.       case DID_OK:
  153.         SetInfoParams( hwnd );
  154.       case DID_CANCEL:
  155.         WinDismissDlg( hwnd, TRUE );  /* Remove the dialog box    */
  156.         return (MRESULT) FALSE;
  157.       default:
  158.         break;
  159.     }
  160.     break;
  161.   default:
  162.     return WinDefDlgProc( hwnd, msg, mp1, mp2 );
  163.   }
  164.   return (MRESULT) FALSE;
  165. }
  166.  
  167.  
  168. /****************************************/
  169. /* Initialisieren der Dialog-Cotrols    */
  170. /****************************************/
  171. USHORT InitConfigDlg( HWND hwnd )
  172. {
  173.   HWND    hControl;
  174.   USHORT  unCnt;
  175.  
  176.   /* set entryfields */
  177.   WinSetDlgItemText( hwnd, EF_CONTAINER, szPath );
  178.   WinSetDlgItemText( hwnd, EF_FILE, szFile );
  179.  
  180.   /* set combobox 'Operation' */
  181.   hControl = WinWindowFromID(hwnd, CO_OPERATION);
  182.   for( unCnt=0; apcOperations[unCnt][0]; unCnt++ )
  183.   {
  184.     WinSendMsg( hControl, LM_INSERTITEM, (MPARAM)LIT_END,
  185.                             MPFROMP(apcOperations[unCnt][0]) );
  186.   }
  187.   WinSendMsg( hControl, LM_SELECTITEM, (MPARAM)unOp, (MPARAM)0 );
  188.   WinSetDlgItemText( hwnd, CO_OPERATION, apcOperations[unOp][0] );
  189.  
  190.   /* set combobox 'Return' */
  191.   hControl = WinWindowFromID(hwnd, CO_RETURN);
  192.   for( unCnt=0; apcReturn[unCnt][0]; unCnt++ )
  193.   {
  194.     WinSendMsg( hControl, LM_INSERTITEM, (MPARAM)LIT_END,
  195.                             MPFROMP(apcReturn[unCnt][0]) );
  196.   }
  197.   WinSendMsg( hControl, LM_SELECTITEM, (MPARAM)unRe, (MPARAM)0 );
  198.   WinSetDlgItemText( hwnd, CO_RETURN, apcReturn[unRe][0] );
  199.  
  200.   /* set combobox 'Type' */
  201.   hControl = WinWindowFromID(hwnd, CO_TYPE );
  202.   for( unCnt=0; apcTypes[unCnt][0]; unCnt++ )
  203.   {
  204.     WinSendMsg( hControl, LM_INSERTITEM, (MPARAM)LIT_END,
  205.                             MPFROMP(apcTypes[unCnt][0]) );
  206.   }
  207.   WinSendMsg( hControl, LM_SELECTITEM, (MPARAM)unTy, (MPARAM)0 );
  208.   WinSetDlgItemText( hwnd, CO_TYPE, apcTypes[unTy][0] );
  209.  
  210.   /* set listbox 'Control' */
  211.   hControl = WinWindowFromID(hwnd, CO_FCONTROL );
  212.   for( unCnt=0; apcControl[unCnt][0]; unCnt++ )
  213.   {
  214.     WinSendMsg( hControl, LM_INSERTITEM, (MPARAM)LIT_END,
  215.                             MPFROMP(apcControl[unCnt][0]) );
  216.   }
  217.   for( unCnt=0; apcControl[unCnt][0]; unCnt++ )
  218.     if( (USHORT)(apcControl[unCnt][1]) & usDrgControl )
  219.       WinSendMsg( hControl, LM_SELECTITEM, (MPARAM)unCnt, (MPARAM)TRUE );
  220.  
  221.   /* set combobox 'Mechanism' */
  222.   hControl = WinWindowFromID(hwnd, CO_MECH );
  223.   for( unCnt=0; apcMechanisms[unCnt]; unCnt++ )
  224.   {
  225.     WinSendMsg( hControl, LM_INSERTITEM, (MPARAM)LIT_END,
  226.                             MPFROMP(apcMechanisms[unCnt]) );
  227.   }
  228.   WinSendMsg( hControl, LM_SELECTITEM, (MPARAM)unMe, (MPARAM)0 );
  229.   WinSetDlgItemText( hwnd, CO_MECH, apcMechanisms[unMe]);
  230.  
  231.   /* set combobox 'Format' */
  232.   hControl = WinWindowFromID(hwnd, CO_FORMAT );
  233.   for( unCnt=0; apcFormats[unCnt]; unCnt++ )
  234.   {
  235.     WinSendMsg( hControl, LM_INSERTITEM, (MPARAM)LIT_END,
  236.                             MPFROMP(apcFormats[unCnt]) );
  237.   }
  238.   WinSendMsg( hControl, LM_SELECTITEM, (MPARAM)unFo, (MPARAM)0 );
  239.   WinSetDlgItemText( hwnd, CO_FORMAT, apcFormats[unFo] );
  240.  
  241.   return 0;
  242. }
  243.  
  244.  
  245. /****************************************************/
  246. /*Belegen der Parameter für die Drag-Drop-Operation */
  247. /****************************************************/
  248. void SetInfoParams( HWND hwnd )
  249. {
  250. #define BUFLEN CCHMAXPATHCOMP
  251.   USHORT  unCnt, unIdx;
  252.   CHAR    achBuf[BUFLEN];
  253.   CHAR    szDrgMechanism[30];
  254.   CHAR    szDrgFormat[30];
  255.  
  256.   if( WinQueryDlgItemText( hwnd, EF_CONTAINER, BUFLEN, achBuf ) )
  257.     strcpy( szPath, achBuf );
  258.   if( WinQueryDlgItemText( hwnd, EF_FILE, BUFLEN, achBuf ) )
  259.     strcpy( szFile, achBuf );
  260.  
  261.   WinQueryDlgItemText( hwnd, CO_OPERATION, BUFLEN, achBuf );
  262.   for( unOp=0,unCnt=0; apcOperations[unCnt][0]; unCnt++ )
  263.   {
  264.     if( !strcmp( apcOperations[unCnt][0], achBuf ) )
  265.     {
  266.       unOp = unCnt;
  267.       usDrgOperation = (USHORT)apcOperations[unCnt][1];
  268.       break;
  269.     }
  270.   }
  271.  
  272.   WinQueryDlgItemText( hwnd, CO_RETURN, BUFLEN, achBuf );
  273.   for( unRe=0,unCnt=0; apcReturn[unCnt][0]; unCnt++ )
  274.   {
  275.     if( !strcmp( apcReturn[unCnt][0], achBuf ) )
  276.     {
  277.       unRe = unCnt;
  278.       usDrgReturn = (USHORT)apcReturn[unCnt][1];
  279.       break;
  280.     }
  281.   }
  282.  
  283.   WinQueryDlgItemText( hwnd, CO_TYPE, BUFLEN, achBuf );
  284.   for( unTy=0, unCnt=0; apcTypes[unCnt][0]; unCnt++ )
  285.   {
  286.     if( !strcmp( apcTypes[unCnt][0], achBuf ) )
  287.     {
  288.       unTy = unCnt;
  289.       szDrgType = apcTypes[unCnt][1];
  290.       break;
  291.     }
  292.   }
  293.  
  294.   usDrgControl = 0;
  295.   unIdx = (USHORT)WinSendMsg(WinWindowFromID(hwnd,CO_FCONTROL), 
  296.                        LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0);
  297.   while( unIdx != (USHORT)LIT_NONE )
  298.   {
  299.     usDrgControl |= (USHORT)(apcControl[unIdx][1]);
  300.     unIdx = (USHORT)WinSendMsg(WinWindowFromID(hwnd,CO_FCONTROL),
  301.                        LM_QUERYSELECTION, (MPARAM)unIdx, (MPARAM)0);
  302.   }
  303.  
  304.   if( WinQueryDlgItemText( hwnd, CO_MECH, BUFLEN, achBuf ) )
  305.   {
  306.     strcpy( szDrgMechanism, achBuf );
  307.     for( unMe=0, unCnt=0; apcMechanisms[unCnt]; unCnt++ )
  308.     {
  309.       if( !strcmp( apcMechanisms[unCnt], achBuf ) )
  310.       {
  311.         unMe = unCnt;
  312.         break;
  313.       }
  314.     }
  315.   }
  316.  
  317.   if( WinQueryDlgItemText( hwnd, CO_FORMAT, BUFLEN, achBuf ) )
  318.   {
  319.     strcpy( szDrgFormat, achBuf );
  320.     for( unFo=0, unCnt=0; apcFormats[unCnt]; unCnt++ )
  321.     {
  322.       if( !strcmp( apcFormats[unCnt], achBuf ) )
  323.       {
  324.         unFo = unCnt;
  325.         break;
  326.       }
  327.     }
  328.   }
  329.   sprintf( szDrgRMF, "<%s,%s>", szDrgMechanism, szDrgFormat );
  330. }
  331.