LInet::SendSizeWinCmd

#include " ltwrappr.h "

L_INT LInet::SendSizeWinCmd (plRemoteComp, uCommandID, uWindowID, nLeft, nTop, nWidth, nHeight)

LInet * plRemoteComp;

/* instance of a remote computer */

L_UINT uCommandID;

/* command id */

LONG_PTR uWindowID;

/* window id */

L_INT nLeft;

/* horizontal position */

L_INT nTop;

/* vertical position */

L_INT nWidth;

/* window width */

L_INT nHeight;

/* window height */

Sends a size window command to a remote computer.

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.

uWindowID

The id of the window to size. This id should be unique for each window.

nLeft

X coordinate of the new origin of the window.

nTop

Y coordinate of the new origin of the window.

nWidth

New width of window.

nHeight

New height of window.

Returns

SUCCESS

This function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The remote computer should respond by calling LInet::SendSizeWinRspin its LInet::CommandCallBackfunction.

With this command, the local computer will signal the remote computer to size a window using the specified parameters.

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

The LInet::CommandCallBackfunction will receive the uWindowID, nLeft, nTop, nWidth and nHeight information in the pParams parameter. The uWindowID information will be in pParams[0]. The nLeft information will be in pParams[1], and so forth.

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::SendSizeWinRsp, LInet::ResponseCallBack, LInet::CommandCallBack, Class Members

Topics:

Sending Commands and Responses

 

A Client Server Diagram: Sending Commands and Responses

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
//This example sends a message to a remote connection to create a window.
//It is assumed that:
//1.  the network as been started (LInet::StartUp()) 
//2.  a connection has been established with a remote server (LInet::m_Inet.Connect())
class LUserNet8 : public LInet
{
public:
   L_INT  OnConnect(LInet *plConnection, L_INT nError)
   {
      L_INT   nRet = SUCCESS;
      L_CHAR  *pszHostName;
      L_TCHAR strMsg[L_MAXPATH];
      
      if(nError != SUCCESS)
      {
         wsprintf(strMsg, _T("Error[%d]: OnConnect"), nRet);
         MessageBox(NULL, strMsg, 0 , 0);
         return nError;
      }
      
      // Get the remote computer name   
      if ((pszHostName = plConnection->GetHostName(HOST_NAME_IP)) == NULL)      
         return FAILURE;   
      wsprintf(strMsg, _T("OnConnect: Connected to %hs"), (LPTSTR)pszHostName);
      MessageBox(0, strMsg, 0, 0);
      this->SendLoadCmd(plConnection, CMD_LOAD, MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")));
      return nRet;
   }
   L_INT CommandCallBack (LInet * plConnection,
                          CMDTYPE     uCommand,
                          L_UINT      uCommandID,
                          L_INT       nError,
                          L_UINT      uParams, 
                          pPARAMETER  pParams, 
                          L_UINT      uExtra,
                          L_CHAR*pExtra);
};
LUserNet8 m_ClientInet;
L_INT LInet__SendWizeWinCmdExample(LInet * pInetRemoteServer, L_UINT uWindowID)
{
   L_INT nRet = SUCCESS;
   nRet = m_ClientInet.SendSizeWinCmd(
      pInetRemoteServer,
      0,
      uWindowID, 
      30,  //left
      50,  //top,
      600, //width
      400  //height
      );
   if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED)
      return nRet;
   return SUCCESS;
}
//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
L_INT LUserNet8::CommandCallBack (LInet * plConnection,
                              CMDTYPE     uCommand,
                              L_UINT      uCommandID,
                              L_INT       nError,
                              L_UINT      uParams, 
                              pPARAMETER  pParams, 
                              L_UINT      uExtra,
                              L_CHAR*pExtra)
{
   UNREFERENCED_PARAMETER(pExtra);
   UNREFERENCED_PARAMETER(uExtra);
   UNREFERENCED_PARAMETER(uParams);
   UNREFERENCED_PARAMETER(pParams);
   UNREFERENCED_PARAMETER(uCommandID);
   UNREFERENCED_PARAMETER(plConnection);
   L_INT nStatus = ERROR_FEATURE_NOT_SUPPORTED;
   if(nError != SUCCESS)
      nStatus = ERROR_TRANSFER_ABORTED;
   else
   {
      switch(uCommand)
      {
      case CMD_SIZE_WIN: 
         {
            L_INT  nStatus = SUCCESS; 
            L_INT  nRet; 
            HWND   uWindowID = (HWND)(INT_PTR)pParams[0].uiValue; 
            L_UINT uLeft   = pParams[1].uiValue; 
            L_UINT uTop    = pParams[2].uiValue; 
            L_UINT uWidth  = pParams[3].uiValue; 
            L_UINT uHeight = pParams[4].uiValue; 
            
            if (IsWindow((HWND)uWindowID)) 
            {
               nRet = ::SetWindowPos(
                  ::GetParent((HWND)uWindowID), 
                  NULL, 
                  uLeft, 
                  uTop, 
                  uWidth, 
                  uHeight, 
                  SWP_NOOWNERZORDER 
                  ); 
               if (nRet == 0) 
                  nStatus = FAILURE; 
            }
            else
            {
               nStatus = ERROR_INV_PARAMETER; 
            }
         }
         break; 
         default: 
         {
            return nStatus; 
         }
      }
   }
   return nStatus;
}