Page 1 of 1

wxDataObject drag & drop problem

Posted: Mon Sep 05, 2005 2:16 pm
by Sickboy
I've got following wxDataObject derived class:

Code: Select all

#include <stdwx.h>
#include ".\DragDropObject.h"

ReactionDnDObject::ReactionDnDObject(void* buf, size_t len)
{
        m_Reaction   = (Reaction*)buf;
        m_ObjLen     = sizeof(*m_Reaction);

        m_DataInputFormat[0].SetId(wxT("Reaction"));

        m_DataOutputFormat[0].SetId(wxT("Reaction"));
        m_DataOutputFormat[1].SetType(wxDF_TEXT);
}



bool         ReactionDnDObject::GetDataHere(const wxDataFormat& format, void *buf )const
{
             if (format == m_DataOutputFormat[0])
             {
          	buf = (void*)m_Reaction;
          	return true;
             }else
	        return false;
}

bool         ReactionDnDObject::SetData( const wxDataFormat& format, size_t len, const void *buf )
{
             if (format == m_DataInputFormat[0])
             {
		m_Reaction = (Reaction*)buf;
             	return true;
             }else
              	return false;

}
//...
When i drag an item the GetDataHere method seem to work.
m_Reaction is the correct pointer to my object.
But in the SetData method i just receive trash from the buf.

Anyone see what i'm missing ?

thx