DoneMsg Template

[C++]

template <class T>
class DoneMsg : virtual public T
{
public:
  DoneMsg(HWND wnd, unsigned int msg, unsigned int requestId=0);

protected:
  void OnDone()
  {
    if (IsWindow(m_wnd)) SendMessageW(m_wnd, m_msg, WPARAM(this), LPARAM(m_requestId));
    T::OnDone();
  }

  HWND m_wnd;
  unsigned int m_msg;
  unsigned int m_requestId;private:
};


// DoneMsg typedefs
typedef DoneMsg<ProgressHandler>   ProgressMsg;
typedef DoneMsg<ForwardingHandler> ForwardingMsg;
typedef DoneMsg<ReceiveHandler>    ReceiveMsg;
typedef DoneMsg<RealPathHandler>   RealPathMsg;
typedef DoneMsg<StatHandler>       StatMsg;
typedef DoneMsg<SftpHandler>       SftpMsg;
typedef DoneMsg<ListHandler>       ListMsg;
typedef DoneMsg<TransferHandler>   TransferMsg;

Members

  • DoneMsg: Initializes parameters for the eventual SendMessage call.
    Parameters:
    • wnd: Handle to the window whose window procedure will receive the message.
    • msg: Specifies the message to be sent.
    • requestId: Specifies a request id (=LPARAM). This value is optional.
  • OnDone: Invokes SendMessage with the specified wnd and msg.
    Parameters:
    • wParam: A this pointer to the current handler object. With SendMessage, the object is guaranteed to exist until the message is processed and SendMessage returns. If you ever want to access the object after SendMessage, just AddRef it to prevent it from being destroyed.
    • lParam: Request id specified in the constructor.

Remarks

This template class adds Win32 message support on top of our handler classes. Its functionality comes in handy in GUI based applications. The FlowSshCpp_Sftp sample uses DoneMsg extensively.