LInet::SendAttachBitmapCmd

#include " ltwrappr.h "

L_INT LInet::SendAttachBitmapCmd (plRemoteComp, uCommandID, uBitmapID, uWindowID)

LInet L_FAR * plRemoteComp;

/* instance of a remote computer */

L_UINT uCommandID;

/* command id */

L_UINT uBitmapID;

/* bitmap id */

L_UINT uWindowID;

/* window id */

Sends an attach bitmap command to a remote computer. This function is only available in the Internet toolkit.

Parameter

Description

plRemoteComp

Instance of the remote computer to which the command will be sent.

uCommandID

Command ID. Each command sent by a member of a connection should have a unique ID. Since a member of a connection may send several commands, this ID allows that member to identify when a specific command request has been completed.

uBitmapID

The ID of the bitmap being attached. If the bitmap is successfully attached, then this bitmap will be painted whenever the window paints itself.

uWindowID

The id of the window that was just created.

Returns

SUCCESS

This function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The remote computer should respond by calling LInet::SendAttachBitmapRsp in its LInet::CommandCallBack function.

Once the remote computer receives this command it should always paint the specified bitmap inside the specified window. Both the bitmap and the window should exist on the remote computer. The remote computer will most likely paint the window at 1:1 ratio, adding scrollbars if possible. To change the way the bitmap is painted, call LInet::SendSetRectCmd.

The LInet::CommandCallBackfunction will receive the uBitmapID and uWindowID information in the pParams parameter. The uBitmapID information will be in pParams[0] and the uWindowID information will be in pParams[1].

To process responses to commands, a class must be derived from LInet and the LInet::ResponseCallBackmember function must be overridden.

Required DLLs and Libraries

LTNET

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LInet::SendAttachBitmapRsp, LInet::ResponseCallBack, LInet::CommandCallBack, Class Members

Topics:

Sending Commands and Responses

 

A Client Server Diagram: Sending Commands and Responses

Example

//This example sends a message to a remote connection to attach a loaded bitmap to a created window.
//It is assumed that:
//1.  m_Inet and m_pInetRemoteServer are an object of the class LInet.
//2.  the network as been started (LInet::StartUp()) 
//3.  a connection has been established with a remote server (LInet::m_Inet.Connect())
//4.  GetNextCommandID() is a function that returns a unique command identifier
//5.  UpdateStatusbar() is a function that displays a message in the status bar
//6.  m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result
//    of a call to m_Inet.SendCreateWinCmd()
//7.  m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result
//    of a call to m_Inet.SendLoadCmd()
void CMainFrame::OnRemoteAttachbitmaptowindow () 
{
   L_INT nRet = SUCCESS;
   
   nRet = m_Inet.SendAttachBitmapCmd(
      m_pInetRemoteServer, 
      GetNextCommandID(),
      m_uBitmapID,
      m_uWindowID);
   
   if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED)
   {
      UpdateStatusbar(TEXT("Error[%d]: OnRemoteLoadbitmap"), nRet);
   }
   else
   {
      UpdateStatusbar(TEXT("Success: OnRemoteLoadbitmap"), nRet);
   }
}

//The CommandCallBack() is processed on the server
//To process the commands sent to the computer, you must:
//1. Derive a class from LInet
//2. Override the CommandCallBack member function
//
//Assume that 
//1. m_Inet is an object of the class CMyNet (derived from LInet).
//2. the network as been started (LInet::StartUp()) 
//3. a connection has been established with a remote client
//4. UpdateStatusbar() displays a message in the status bar
//5. m_BitmapList maintains a list of LBitmapWindow objects
L_INT CMyNet::CommandCallBack (LInet L_FAR * plConnection,
                              CMDTYPE     uCommand,
                              L_UINT      uCommandID,
                              L_INT       nError,
                              L_UINT      uParams, 
                              pPARAMETER  pParams, 
                              L_UINT      uExtra,
                              L_CHAR L_FAR*pExtra)
{
   L_INT nStatus = ERROR_FEATURE_NOT_SUPPORTED; 
   L_UINT          uBitmapID = (L_UINT)-1; 
   
   CMainFrame *pMain; 
   pMain = GETMAINFRAME; 
   
   if(nError != SUCCESS) 
      nStatus = ERROR_TRANSFER_ABORTED; 
   else
      switch(uCommand) 
   {
      case CMD_ATTACH_BITMAP: 
         {
            L_UINT32 uBitmapID = pParams[0].uiValue; 
            HWND uWindowID = (HWND)pParams[1].uiValue; 

            //pParams[0] uBitmapID
            //pParams[1] uWindowID
            
            //Need to attach bitmap to BitmapWindow
            if (IsWndValid((HWND)uWindowID)) 
            {
               //Here you look up the uBitmapID in a list of 
               //BitmapWindow objects to verify
               //that it is a valid ID.  If it is, set the 
               //window handle of the BitmapWindow object
               //to uWindowID
               
               //Something like this... 
               /*
               LBitmapWindow *pBitmapWindow; 
               pBitmapWindow = m_BitmapList[uBitmapID]; 
               if (pBitmapWindow != NULL) 
               {
                    pBitmapWindow->SetWndHandle(uWindowID); 
               }
               */
            }
         }
         return pMain->m_Inet.SendAttachBitmapRsp(
                   plConnection, 
                   uCommandID, 
                   0, 
                  NULL, 
                  nStatus); 
         break; 

      default: 
         {
            return nStatus; 
         }
   }
   return nStatus; 
}