home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / drgmon.zip / show.c < prev   
Text File  |  1993-07-28  |  22KB  |  507 lines

  1. /*********************************************************************
  2.  *                                                                   *
  3.  * MODULE NAME :  show.c                 AUTHOR:  Rick Fishman       *
  4.  * DATE WRITTEN:  07-21-93                                           *
  5.  *                                                                   *
  6.  * MODULE DESCRIPTION:                                               *
  7.  *                                                                   *
  8.  *  Part of the 'DRGDROP' drag/drop sample program.                  *
  9.  *                                                                   *
  10.  *  This module takes Drag/Drop structures and displays their        *
  11.  *  contents in a debug window.                                      *
  12.  *                                                                   *
  13.  * NOTES:                                                            *
  14.  *                                                                   *
  15.  *                                                                   *
  16.  * FUNCTIONS AVALABLE TO OTHER MODULES:                              *
  17.  *                                                                   *
  18.  *   showDragoverNotifyInfo                                          *
  19.  *   showDragInfo                                                    *
  20.  *   showDragTransfer                                                *
  21.  *   showDragItem                                                    *
  22.  *   showRenderReply                                                 *
  23.  *   showPrintReply                                                  *
  24.  *                                                                   *
  25.  *                                                                   *
  26.  * HISTORY:                                                          *
  27.  *                                                                   *
  28.  *  07-21-93 - Program coded.                                        *
  29.  *                                                                   *
  30.  *  Rick Fishman                                                     *
  31.  *  Code Blazers, Inc.                                               *
  32.  *  4113 Apricot                                                     *
  33.  *  Irvine, CA. 92720                                                *
  34.  *  CIS ID: 72251,750                                                *
  35.  *                                                                   *
  36.  *********************************************************************/
  37.  
  38. #pragma strings(readonly)   // used for debug version of memory mgmt routines
  39.  
  40. /*********************************************************************/
  41. /*------- Include relevant sections of the OS/2 header files --------*/
  42. /*********************************************************************/
  43.  
  44. #define  INCL_SHLERRORS
  45. #define  INCL_WINERRORS
  46. #define  INCL_WINFRAMEMGR
  47. #define  INCL_WINSTDCNR
  48. #define  INCL_WINSTDDRAG
  49. #define  INCL_WINWINDOWMGR
  50.  
  51. /**********************************************************************/
  52. /*----------------------------- INCLUDES -----------------------------*/
  53. /**********************************************************************/
  54.  
  55. #include <os2.h>
  56. #include <stdio.h>
  57. #include <stdlib.h>
  58. #include <string.h>
  59. #include "drgdrop.h"
  60.  
  61. /*********************************************************************/
  62. /*------------------- APPLICATION DEFINITIONS -----------------------*/
  63. /*********************************************************************/
  64.  
  65.  
  66. /**********************************************************************/
  67. /*---------------------------- STRUCTURES ----------------------------*/
  68. /**********************************************************************/
  69.  
  70.  
  71. /**********************************************************************/
  72. /*----------------------- FUNCTION PROTOTYPES ------------------------*/
  73. /**********************************************************************/
  74.  
  75.  
  76. /**********************************************************************/
  77. /*------------------------ GLOBAL VARIABLES --------------------------*/
  78. /**********************************************************************/
  79.  
  80.  
  81. /**********************************************************************/
  82. /*--------------------- showDragoverNotifyInfo -----------------------*/
  83. /*                                                                    */
  84. /*  SHOW THE INFO ON A DM_DRAGOVERNOTIFY MESSAGE.                     */
  85. /*                                                                    */
  86. /*  PARMS: frame window handle whose debug window we will write to,   */
  87. /*         pointer to a DRAGINFO structure,                           */
  88. /*         the target's reply                                         */
  89. /*                                                                    */
  90. /*  NOTES:                                                            */
  91. /*                                                                    */
  92. /*  RETURNS: nothing                                                  */
  93. /*                                                                    */
  94. /*--------------------------------------------------------------------*/
  95. /**********************************************************************/
  96. void showDragoverNotifyInfo( HWND hwndFrame, PDRAGINFO pDragInfo, MRESULT mr )
  97. {
  98.     PINSTANCE pi = INSTDATA( hwndFrame );
  99.  
  100.     if( pi )
  101.     {
  102.         HWND  hDbg = pi->hwndDebug;
  103.         int   i;
  104.         char  szBuf[ 100 ];
  105.         ULONG ulDrop = SHORT1FROMMR( mr ), ulOp = SHORT2FROMMR( mr );
  106.  
  107.         if( !hDbg || !WinIsWindow( ANCHOR( hwndFrame ), hDbg ) )
  108.             return;
  109.  
  110.         if( dlgInfo.fOnlyMessageNames )
  111.         {
  112.             dbgInsert( hDbg, "DM_DRAGOVERNOTIFY" );
  113.             return;
  114.         }
  115.  
  116.         showDragInfo( hwndFrame, "DM_DRAGOVERNOTIFY", pDragInfo );
  117.  
  118.         strcpy( szBuf, "Target replied [" );
  119.  
  120.         for( i = 0; i < cDragoverReplyTypes; i++ )
  121.             if( ulDrop == dcDragoverReply[ i ].iItem )
  122.             {
  123.                 strcat( szBuf, dcDragoverReply[ i ].szItem );
  124.                 break;
  125.             }
  126.  
  127.         if( i == cDragoverReplyTypes )
  128.             strcat( szBuf, "0" );
  129.  
  130.         strcat( szBuf, "," );
  131.  
  132.         for( i = 0; i < cOperations; i++ )
  133.             if( ulOp == dcOperation[ i ].iItem )
  134.             {
  135.                 strcat( szBuf, dcOperation[ i ].szItem );
  136.                 break;
  137.             }
  138.  
  139.         if( i == cOperations )
  140.             strcat( szBuf, "0" );
  141.  
  142.         strcat( szBuf, "] to DM_DRAGOVER" );
  143.  
  144.         dbgInsert( hDbg, szBuf );
  145.     }
  146.     else
  147.         Msg( "showDragoverNotifyInfo cant get Inst data RC(%X)",
  148.              HWNDERR( hwndFrame ) );
  149. }
  150.  
  151. /**********************************************************************/
  152. /*-------------------------- showDragInfo ----------------------------*/
  153. /*                                                                    */
  154. /*  DISPLAY THE CONTENTS OF A DRAGINFO STRUCTURE.                     */
  155. /*                                                                    */
  156. /*  PARMS: frame window handle whose debug window we will write to,   */
  157. /*         string that uniquely identifies the operation going on,    */
  158. /*         pointer to a DRAGINFO structure                            */
  159. /*                                                                    */
  160. /*  NOTES:                                                            */
  161. /*                                                                    */
  162. /*  RETURNS: nothing                                                  */
  163. /*                                                                    */
  164. /*--------------------------------------------------------------------*/
  165. /**********************************************************************/
  166. void showDragInfo( HWND hwndFrame, PSZ pszCurrentOp, PDRAGINFO pDragInfo )
  167. {
  168.     PINSTANCE pi = INSTDATA( hwndFrame );
  169.  
  170.     if( pi )
  171.     {
  172.         HWND hDbg = pi->hwndDebug;
  173.         int  i;
  174.         char hstrBuf[ 100 ];
  175.  
  176.         if( !hDbg || !WinIsWindow( ANCHOR( hwndFrame ), hDbg ) )
  177.             return;
  178.  
  179.         if( dlgInfo.fOnlyMessageNames )
  180.         {
  181.             dbgInsert( hDbg, pszCurrentOp );
  182.             return;
  183.         }
  184.  
  185.         sprintf( hstrBuf, " %s ", pszCurrentOp );
  186.         dbgInsert( hDbg, hstrBuf );
  187.  
  188.         dbgInsert( hDbg, "Drag Items: %u", pDragInfo->cditem );
  189.  
  190.         *hstrBuf = 0;
  191.  
  192.         for( i = 0; i < cOperations; i++ )
  193.             if( pDragInfo->usOperation == dcOperation[ i ].iItem )
  194.             {
  195.                 strcpy( hstrBuf, dcOperation[ i ].szItem );
  196.                 break;
  197.             }
  198.  
  199.         dbgInsert( hDbg, "Operation: %X [%s]", pDragInfo->usOperation, hstrBuf);
  200.         dbgInsert( hDbg, "Source HWND: %p", pDragInfo->hwndSource );
  201.         dbgInsert( hDbg, "───────────────────────────────" );
  202.  
  203.         if( dlgInfo.fOnlyFirstItem || pDragInfo->cditem == 1 )
  204.             showDragItem( hwndFrame, pszCurrentOp,
  205.                           DrgQueryDragitemPtr( pDragInfo, 0 ), -1 );
  206.         else
  207.         {
  208.             for( i = 0; i < pDragInfo->cditem; i++ )
  209.             {
  210.                 showDragItem( hwndFrame, pszCurrentOp,
  211.                               DrgQueryDragitemPtr( pDragInfo, i ), i + 1 );
  212.  
  213.                 if( i != (pDragInfo->cditem - 1) )
  214.                     dbgInsert( hDbg, "───────────────────────────────" );
  215.             }
  216.  
  217.             dbgInsert( hDbg, " " );
  218.         }
  219.     }
  220.     else
  221.         Msg( "showDragInfo cant get Inst data RC(%X)", HWNDERR( hwndFrame ) );
  222. }
  223.  
  224. /**********************************************************************/
  225. /*------------------------- showDragTransfer -------------------------*/
  226. /*                                                                    */
  227. /*  SEND DRAGTRANSFER INFO TO THE DEBUG WINDOW.                       */
  228. /*                                                                    */
  229. /*  PARMS: frame window handle whose debug window we will write to,   */
  230. /*         string that uniquely identifies the operation going on,    */
  231. /*         pointer to a DRAGTRANSFER structure                        */
  232. /*                                                                    */
  233. /*  NOTES:                                                            */
  234. /*                                                                    */
  235. /*  RETURNS: nothing                                                  */
  236. /*                                                                    */
  237. /*--------------------------------------------------------------------*/
  238. /**********************************************************************/
  239. void showDragTransfer( HWND hwndFrame, PSZ pszCurrentOp,
  240.                        PDRAGTRANSFER pDragXfer )
  241. {
  242.     PINSTANCE pi = INSTDATA( hwndFrame );
  243.  
  244.     if( pi )
  245.     {
  246.         HWND hDbg = pi->hwndDebug;
  247.         int  i;
  248.         char hstrBuf[ 100 ];
  249.  
  250.         if( !hDbg || !WinIsWindow( ANCHOR( hwndFrame ), hDbg ) )
  251.             return;
  252.  
  253.         if( dlgInfo.fOnlyMessageNames )
  254.         {
  255.             dbgInsert( hDbg, pszCurrentOp );
  256.             return;
  257.         }
  258.  
  259.         sprintf( hstrBuf, " %s ", pszCurrentOp );
  260.         dbgInsert( hDbg, hstrBuf );
  261.  
  262.         dbgInsert( hDbg, "hwndClient: %p", pDragXfer->hwndClient );
  263.  
  264.         dbgInsert( hDbg, "───── DRAGITEM IN DRAGTRANSFER ─────" );
  265.         showDragItem( hwndFrame, pszCurrentOp, pDragXfer->pditem, -1 );
  266.         dbgInsert( hDbg, "────────────────────────────────────" );
  267.  
  268.         DrgQueryStrName( pDragXfer->hstrSelectedRMF, sizeof( hstrBuf ),
  269.                          hstrBuf );
  270.         dbgInsert( hDbg, "hstrSelectedRMF: %s", hstrBuf );
  271.  
  272.         DrgQueryStrName( pDragXfer->hstrRenderToName, sizeof( hstrBuf ),
  273.                          hstrBuf );
  274.         dbgInsert( hDbg, "hstrRenderToName: %s", hstrBuf );
  275.  
  276.         dbgInsert( hDbg, "ulTargetInfo: %u", pDragXfer->ulTargetInfo );
  277.  
  278.         *hstrBuf = 0;
  279.  
  280.         for( i = 0; i < cOperations; i++ )
  281.             if( pDragXfer->usOperation & dcOperation[ i ].iItem )
  282.             {
  283.                 strcat( hstrBuf, dcOperation[ i ].szItem );
  284.                 strcat( hstrBuf, " " );
  285.             }
  286.  
  287.         dbgInsert( hDbg, "usOperation: %X [%s]", pDragXfer->usOperation,
  288.                    hstrBuf );
  289.  
  290.         *hstrBuf = 0;
  291.  
  292.         for( i = 0; i < cRenderReplyTypes; i++ )
  293.             if( pDragXfer->fsReply & dcRenderReply[ i ].iItem )
  294.             {
  295.                 strcat( hstrBuf, dcRenderReply[ i ].szItem );
  296.                 strcat( hstrBuf, " " );
  297.             }
  298.  
  299.         dbgInsert( hDbg, "fsReply: %X [%s]", pDragXfer->fsReply, hstrBuf );
  300.         dbgInsert( hDbg, "────────────────────────────────────" );
  301.         dbgInsert( hDbg, " " );
  302.     }
  303. }
  304.  
  305. /**********************************************************************/
  306. /*--------------------------- showDragItem ---------------------------*/
  307. /*                                                                    */
  308. /*  SEND DRAGITEM INFO TO THE DEBUG WINDOW.                           */
  309. /*                                                                    */
  310. /*  PARMS: frame window handle whose debug window we will write to,   */
  311. /*         string that uniquely identifies the operation going on,    */
  312. /*         pointer to the DRAGITEM structure,                         */
  313. /*         positional 1-based offset of DRAGITEM in array of DRAGITEMS*/
  314. /*                                                                    */
  315. /*  NOTES:                                                            */
  316. /*                                                                    */
  317. /*  RETURNS: nothing                                                  */
  318. /*                                                                    */
  319. /*--------------------------------------------------------------------*/
  320. /**********************************************************************/
  321. void showDragItem( HWND hwndFrame, PSZ pszCurrentOp, PDRAGITEM pDragItem,
  322.                    int iOffset )
  323. {
  324.     PINSTANCE pi = INSTDATA( hwndFrame );
  325.  
  326.     if( pi )
  327.     {
  328.         HWND hDbg = pi->hwndDebug;
  329.         int  i;
  330.         char hstrBuf[ 100 ];
  331.         char szOffset[ 6 ];
  332.  
  333.         if( !hDbg || !WinIsWindow( ANCHOR( hwndFrame ), hDbg ) )
  334.             return;
  335.  
  336.         if( dlgInfo.fOnlyMessageNames )
  337.         {
  338.             dbgInsert( hDbg, pszCurrentOp );
  339.             return;
  340.         }
  341.  
  342.         // Take care of showing the offset if applicable. If this display is
  343.         // part of a global DRAGINFO display, the caller will take care of
  344.         // any border drawing. All callers outside of this module will call
  345.         // with a 0 as the last parameter. If called as part of a DRAGTRANSFER,
  346.         // the last parameter will by -1.
  347.  
  348.         if( iOffset == 0 )
  349.         {
  350.             strcpy( szOffset, ":" );
  351.             sprintf( hstrBuf, " %s ", pszCurrentOp );
  352.             dbgInsert( hDbg, hstrBuf );
  353.         }
  354.         else if( iOffset == -1 )
  355.             strcpy( szOffset, ":" );
  356.         else
  357.             sprintf( szOffset, "[%d]:", iOffset );
  358.  
  359.         dbgInsert( hDbg, "hwndItem%s %p, ulItemID%s %X", szOffset,
  360.                    pDragItem->hwndItem, szOffset, pDragItem->ulItemID );
  361.  
  362.         DrgQueryStrName( pDragItem->hstrType, sizeof( hstrBuf ), hstrBuf );
  363.         dbgInsert( hDbg, "Type%s %s", szOffset, hstrBuf );
  364.  
  365.         DrgQueryStrName( pDragItem->hstrRMF, sizeof( hstrBuf ), hstrBuf );
  366.         dbgInsert( hDbg, "RMF%s %s", szOffset, hstrBuf );
  367.  
  368.         DrgQueryStrName( pDragItem->hstrContainerName, sizeof( hstrBuf ),
  369.                          hstrBuf );
  370.         dbgInsert( hDbg, "CnrName%s %s", szOffset, hstrBuf );
  371.  
  372.         DrgQueryStrName( pDragItem->hstrSourceName, sizeof( hstrBuf ),
  373.                          hstrBuf );
  374.         dbgInsert( hDbg, "Source%s %s", szOffset, hstrBuf );
  375.  
  376.         DrgQueryStrName( pDragItem->hstrTargetName, sizeof( hstrBuf ),
  377.                          hstrBuf );
  378.         dbgInsert( hDbg, "Target%s %s", szOffset, hstrBuf );
  379.  
  380.         dbgInsert( hDbg, "cxOffset%s: %d", szOffset, pDragItem->cxOffset );
  381.         dbgInsert( hDbg, "cyOffset%s: %d", szOffset, pDragItem->cyOffset );
  382.  
  383.         *hstrBuf = 0;
  384.  
  385.         for( i = 0; i < cControlTypes; i++ )
  386.             if( pDragItem->fsControl & dcControl[ i ].iItem )
  387.             {
  388.                 strcat( hstrBuf, dcControl[ i ].szItem );
  389.                 strcat( hstrBuf, " " );
  390.             }
  391.  
  392.         dbgInsert( hDbg, "Control Flags%s %X [%s]", szOffset,
  393.                    pDragItem->fsControl, hstrBuf );
  394.  
  395.         *hstrBuf = 0;
  396.  
  397.         for( i = 0; i < cSupportedOps; i++ )
  398.             if( pDragItem->fsSupportedOps & dcSupportedOp[ i ].iItem )
  399.             {
  400.                 strcat( hstrBuf, dcSupportedOp[ i ].szItem );
  401.                 strcat( hstrBuf, " " );
  402.             }
  403.  
  404.         dbgInsert( hDbg, "Supported Ops%s %X [%s]", szOffset,
  405.                    pDragItem->fsSupportedOps, hstrBuf );
  406.  
  407.         // If this display is part of a global DRAGINFO display, the caller
  408.         // will be drawing borders. Same with DRAGTRANSFER.
  409.  
  410.         if( iOffset == 0 )
  411.         {
  412.             dbgInsert( hDbg, "───────────────────────────────" );
  413.             dbgInsert( hDbg, " " );
  414.         }
  415.     }
  416.     else
  417.         Msg( "showDragItem cant get Inst data RC(%X)", HWNDERR( hwndFrame ) );
  418. }
  419.  
  420. /**********************************************************************/
  421. /*------------------------- showRenderReply --------------------------*/
  422. /*                                                                    */
  423. /*  SHOW THE REPLY TO A DRAGTRANSFER MESSAGE.                         */
  424. /*                                                                    */
  425. /*  PARMS: frame window handle whose debug window we will write to,   */
  426. /*         string that will prefix the reply,                         */
  427. /*         the reply                                                  */
  428. /*                                                                    */
  429. /*  NOTES:                                                            */
  430. /*                                                                    */
  431. /*  RETURNS: nothing                                                  */
  432. /*                                                                    */
  433. /*--------------------------------------------------------------------*/
  434. /**********************************************************************/
  435. void showRenderReply( HWND hwndFrame, PSZ pszPrefix, ULONG flReply )
  436. {
  437.     PINSTANCE pi = INSTDATA( hwndFrame );
  438.  
  439.     if( pi )
  440.     {
  441.         HWND hDbg = pi->hwndDebug;
  442.         int  i;
  443.         char szBuf[ 100 ];
  444.  
  445.         if( !hDbg || !WinIsWindow( ANCHOR( hwndFrame ), hDbg ) )
  446.             return;
  447.  
  448.         *szBuf = 0;
  449.  
  450.         for( i = 0; i < cRenderReplyTypes; i++ )
  451.             if( flReply & dcRenderReply[ i ].iItem )
  452.             {
  453.                 strcat( szBuf, dcRenderReply[ i ].szItem );
  454.                 strcat( szBuf, " " );
  455.             }
  456.  
  457.         dbgInsert( hDbg, "%s%X [%s]", pszPrefix, flReply, szBuf );
  458.     }
  459.     else
  460.         Msg( "showRenderReply cant get Inst data RC(%X)", HWNDERR( hwndFrame ));
  461. }
  462.  
  463. /**********************************************************************/
  464. /*------------------------- showPrintReply ---------------------------*/
  465. /*                                                                    */
  466. /*  SHOW THE REPLY TO A DM_PRINTOBJECT or DM_DISCARDOBJECT MESSAGE.   */
  467. /*                                                                    */
  468. /*  PARMS: frame window handle whose debug window we will write to,   */
  469. /*         string that will prefix the reply,                         */
  470. /*         the reply                                                  */
  471. /*                                                                    */
  472. /*  NOTES:                                                            */
  473. /*                                                                    */
  474. /*  RETURNS: nothing                                                  */
  475. /*                                                                    */
  476. /*--------------------------------------------------------------------*/
  477. /**********************************************************************/
  478. void showPrintReply( HWND hwndFrame, PSZ pszPrefix, ULONG flReply )
  479. {
  480.     PINSTANCE pi = INSTDATA( hwndFrame );
  481.  
  482.     if( pi )
  483.     {
  484.         HWND hDbg = pi->hwndDebug;
  485.         int  i;
  486.         char szBuf[ 100 ];
  487.  
  488.         if( !hDbg || !WinIsWindow( ANCHOR( hwndFrame ), hDbg ) )
  489.             return;
  490.  
  491.         for( i = 0; i < cPrintReplyTypes; i++ )
  492.             if( flReply & dcPrintReply[ i ].iItem )
  493.             {
  494.                 strcpy( szBuf, dcPrintReply[ i ].szItem );
  495.                 break;
  496.             }
  497.  
  498.         dbgInsert( hDbg, "%s%X [%s]", pszPrefix, flReply, szBuf );
  499.     }
  500.     else
  501.         Msg( "showPrintReply cant get Inst data RC(%X)", HWNDERR( hwndFrame ) );
  502. }
  503.  
  504. /*************************************************************************
  505.  *                     E N D     O F     S O U R C E                     *
  506.  *************************************************************************/
  507.