Esempio n. 1
0
static DDESTRUCT *MakeDDEObject( HWND hwnd, char *item_name,
                                 USHORT fsStatus, USHORT usFormat,
                                 void *data, int data_len )
/****************************************************************/
{
    DDESTRUCT   *dde;
    int         item_len;
    PID         pid;
    TID         tid;

    if( item_name != NULL ) {
        item_len = strlen( item_name ) + 1;
    } else {
        item_len = 1;
    }
    if( !DosAllocSharedMem( (PPVOID)&dde, NULL, sizeof( DDESTRUCT ) +
                            item_len + data_len,
                            PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE ) ) {
        WinQueryWindowProcess( hwnd, &pid, &tid );
        DosGiveSharedMem( (PVOID)&dde, pid, PAG_READ | PAG_WRITE );
        dde->cbData = data_len;
        dde->fsStatus = fsStatus;
        dde->usFormat = usFormat;
        dde->offszItemName = sizeof( DDESTRUCT );
        if( (data_len != 0) && (data != NULL) ) {
            dde->offabData = (USHORT)(sizeof( DDESTRUCT ) + item_len);
        } else {
            dde->offabData = 0;
        }
        if( item_name != NULL ) {
            strcpy( (char *)DDES_PSZITEMNAME( dde ), item_name );
        } else {
            strcpy( (char *)DDES_PSZITEMNAME( dde ), "" );
        }
        if( data != NULL ) {
            memcpy( DDES_PABDATA( dde ), data, data_len );
        }
        return( dde );
    }
    return( NULL );
}
Esempio n. 2
0
static PDDESTRUCT MakeDDEObject (
   HWND Destination,                    // -> Destination window
   PSZ Item,                            // -> Item name or NULL.
   USHORT Status,                       // Status flags.
   USHORT Format,                       // Data format
   PVOID Data,                          // -> Data or NULL.
   ULONG DataLen                        // Data length in bytes.
) {

   ULONG ItemLen = Item ? strlen(PCHAR(Item))+1 : 1 ;

   PDDESTRUCT pBlock ;
   if ( DosAllocSharedMem ( PPVOID(&pBlock), 0, sizeof(DDESTRUCT) + ItemLen + DataLen,
      PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE ) )
      return ( 0 ) ;

   pBlock->cbData = DataLen ;
   pBlock->fsStatus = Status ;
   pBlock->usFormat = Format ;
   pBlock->offszItemName = sizeof(DDESTRUCT) ;

   if ( DataLen AND Data )
      pBlock->offabData = USHORT ( sizeof(DDESTRUCT) + ItemLen ) ;
   else
      pBlock->offabData = 0 ;

   if ( Item )
      strcpy ( PCHAR(DDES_PSZITEMNAME(pBlock)), PCHAR(Item) ) ;
   else
      strcpy ( PCHAR(DDES_PSZITEMNAME(pBlock)), "" ) ;

   if ( Data )
      memcpy ( DDES_PABDATA(pBlock), Data, size_t(DataLen) ) ;

   PID pid ; TID tid ;
   WinQueryWindowProcess ( Destination, &pid, &tid ) ;
   DosGiveSharedMem( (PVOID)pBlock, pid, PAG_READ | PAG_WRITE) ;

   return ( pBlock ) ;
}
Esempio n. 3
0
extern MRESULT APIENTRY Dde_Processor ( HWND Server, ULONG Msg, MPARAM mp1, MPARAM mp2 ) {

   switch ( Msg ) {

      case WM_CREATE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) mp1 ;
         WinSetWindowPtr ( Server, QWL_USER, Parms ) ;
         return ( 0 ) ; }

      case WM_DESTROY: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         Parms->Topic->Terminate ( Server, Parms->Client, FALSE ) ;
         return ( 0 ) ; }

      case WM_DDE_REQUEST: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         Parms->Topic->Request ( Server, Client, Item ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_POKE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         int Format = int ( Request->usFormat ) ;
         PVOID Data = PVOID ( DDES_PABDATA ( Request ) ) ;
         int Size = int ( Request->cbData ) ;
         Parms->Topic->Poke ( Server, Client, Item, Format, Data, Size ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_ADVISE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         Parms->Topic->Advise ( Server, Client, Item, ! ( Request->fsStatus & DDE_FNODATA ) ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_UNADVISE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         Parms->Topic->Unadvise ( Server, Client, Item ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_EXECUTE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         HWND Client = HWNDFROMMP ( mp1 ) ;
         PDDESTRUCT Request = PDDESTRUCT ( mp2 ) ;
         PCHAR Item = PCHAR ( DDES_PSZITEMNAME ( Request ) ) ;
         int Format = int ( Request->usFormat ) ;
         PVOID Data = PVOID ( DDES_PABDATA ( Request ) ) ;
         int Size = int ( Request->cbData ) ;
         Parms->Topic->Execute ( Server, Client, Item, Format, Data, Size ) ;
         DosFreeMem ( Request ) ;
         return ( 0 ) ; }

      case WM_DDE_TERMINATE: {
         DDESERVER_PARMS *Parms = (DDESERVER_PARMS*) WinQueryWindowPtr ( Server, QWL_USER ) ;
         Parms->Topic->Terminate ( Server, Parms->Client, TRUE ) ;
         return ( 0 ) ; }

   } /* endswitch */

   return ( WinDefWindowProc ( Server, Msg, mp1, mp2 ) ) ;
}