LInet::SendCreateWinCmd

#include " ltwrappr.h "

L_INT LInet::SendCreateWinCmd (plRemoteComp, uCommandID, pszClassName, pszWindowName, ulFlags, nLeft, nTop, nWidth, nHeight, uParentID)

LInet L_FAR * plRemoteComp;

/* instance of a remote computer */

L_UINT uCommandID;

/* command id */

L_TCHAR L_FAR * pszClassName;

/* window class name */

L_TCHAR L_FAR * pszWindowName;

/* name of window */

L_UINT ulFlags;

/* window creation flags */

L_INT nLeft;

/* x coordinate */

L_INT nTop;

/* y coordinate */

L_INT nWidth;

/* width */

L_INT nHeight;

/* height */

L_UINT uParentID;

/* parent id */

Sends a create win 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.

pszClassName

Character string containing the class name for which to register the window. This must be a valid string, and should be related to your application, to avoid conflicting with an existing registered window class name.

pszWindowName

Character string containing the name of the window. This parameter can be an empty string ("").

ulFlags

Flags that indicate how to create the window. It is recommended to use the same flags shown in CreateWindow in the Microsoft SDK. However, you can pass 0 if you do not wish to use ulFlags, or you can define your own flags.

nLeft

X coordinate for the origin of the window to create.

nTop

Y coordinate for the origin of the window to create.

nWidth

Requested width of the window's client area.

nHeight

Requested height of the window's client area.

uParentID

Id of the parent or owner window of the window being created.

Returns

SUCCESS

This function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

With this command, the local computer will signal the remote computer to create a window using the specified parameters. The window identifier will be sent in the response to this command.

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 pszClassName, pszWindowName, ulFlags, nLeft, nTop, nWidth, nHeight and uParentID information in the pParams parameter. The pszClassName information will be in pParams[0]. The pszWindowName information will be in pParams[1], the ulFlags information will be in pParams[2], 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::SendCreateWinRsp, 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 create a 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()
void CMainFrame::OnRemoteCreatewindow () 
{
   L_INT nRet = SUCCESS;
   L_INT nNotUsed = 0;
   
   nRet = m_Inet.SendCreateWinCmd(
      m_pInetRemoteServer,
      GetNextCommandID(),
      TEXT(""), 
      TEXT("Window created by remote computer"), 
      nNotUsed, nNotUsed, nNotUsed, 300, 300, 0);
   
   if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED)
      UpdateStatusbar(TEXT("Error[%d] OnRemoteCreatewindow"), 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; 
   
   if(nError != SUCCESS) 
      nStatus = ERROR_TRANSFER_ABORTED; 
   else
      switch(uCommand) 
      {
            case CMD_CREATE_WIN: 
            {
               //Code to create a new window on the server goes here
               //m_hWnd contains the window handle of the new window
               //m_hWnd is returned in the response

               //Your m_hWnd would be an actual window handle
                  HWND m_hWnd = 0; 

                  return m_Inet.SendCreateWinRsp(
                     plConnection, 
                     uCommandID, 
                     (L_UINT)m_hWnd, 
                     0, 
                     NULL, 
                     SUCCESS); 
            }
            break; 
            default: 
            {
               return nStatus; 
            }
      }
   return nStatus;
}