Thanks a lot for the help everyone!
It is now working in my code.
Seems like a call to CoInitialize() for some reason disabled DND-events.
I moved that call to after doing all the fltk-initialization and it now works.
> Thank you a lot for that!
> That code does indeed work great in fltk2!
>
> I still have a problem though:
>
> I copied that code into my main file and replaced the current main
> with that main and I got the two windows which allowed me to drag and drop.
>
> I replaced Receiver with my own Drag and Drop-receiving class and that worked
> great as well. BUT; my class still doesn't work in my actual application.
> Neither does Sender and Receiver.
>
> Anyone have an idea why my application isn't allowing drag and drop (and as I
> said, my DND-class works if I plug it into the code below).
>
> > Andreas schrieb:
> > > Hi everyone!
> > >
> > > I've been trying to get drag and drop to work in my application, but
> > > without success.
> >
> > gregs example works also with fltk2:
> >
> > /*
> > fltk2-config --compile dnd.cxx && ./dnd
> > */
> > #include "fltk/Box.h"
> > #include "fltk/events.h"
> > #include "fltk/Window.h"
> > #include "fltk/run.h"
> > #include <string.h>
> > #include <stdio.h>
> >
> > using namespace fltk;
> >
> > class Sender : public Widget
> > {
> > int no;
> > int handle(int event)
> > {
> > switch (event)
> > {
> > case PUSH:
> > char buf[16];
> > sprintf(buf,"message %d",no++);
> > copy(buf,strlen(buf),0);
> > dnd();
> > return 0;
> > }
> > return Widget::handle(event);
> > }
> > public:
> > Sender(int x, int y, int w, int h)
> > : Widget(x, y, w, h, "drag source")
> > ,no(0)
> > {
> > box(UP_BOX);
> > }
> > };
> >
> > class Receiver : public Widget
> > {
> > int handle(int event)
> > {
> > switch (event)
> > {
> > case DND_ENTER:
> > case DND_RELEASE:
> > case DND_DRAG:
> > return 1;
> > case PASTE:
> > //fprintf(stderr,"PASTE %s",event_text());
> > label(event_text());
> > redraw();
> > return 1;
> > }
> > return Widget::handle(event);
> > }
> > public:
> > Receiver(int x, int y, int w, int h)
> > : Widget(x, y, w, h, "drag target")
> > {
> > box(DOWN_BOX);
> > }
> > };
> >
> > int main(int argc, char **argv) {
> > // Create sender window and widget
> > Window win_a(33,33,166,166,"Sender");
> > win_a.begin();
> > Sender a(33,33,100,100);
> > win_a.end();
> > win_a.show();
> > // Create receiver window and widget
> > Window win_b(433,33,166,166,"Receiver");
> > win_b.begin();
> > Receiver b(33,33,100,100);
> > win_b.end();
> > win_b.show();
> > return run();
> > }
>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk