DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2070
Version: -current


Can show a Window from dll, using load_plugin? I write fltk_plugin.cxx,
including fltk_main.cxx, fltk_plugin.cxx. after compile,
fltk_main.cxx -> fltk_main.exe
fltk_plugin.cxx -> fltk_plugin.dll
Use fltk_main.exe to show a window from fltk_plugin.dll, but CAN NOT show
normally.


Link: http://www.fltk.org/str.php?L2070
Version: -current
fltk_main.cxx
/*==========*/
// g++ `fltk-config --cxxflags` -o fltk_main.exe fltk_main.cxx `fltk-config 
--ldflags`
#include <fltk/Window.h>
#include <fltk/Group.h>
#include <fltk/Button.h>

#include <fltk/load_plugin.h>

using namespace fltk;

typedef Window * (*showWindow_t)();

void cb_btnTest(Widget *, void *) {
    char sSO[] = "./fltk_plugin.dll";
    char sSymbol[] = "showWindow";

    showWindow_t showWindow = (showWindow_t)load_plugin(sSO, sSymbol);
    Window *w = (Window *)showWindow();
    w->show(); /* here, CAN NOT show normally */

    return;
}

void cb_btnExit(Widget *, void *) {
  exit(0);
}

int main(int argc, char ** argv) {
  Window *window = new Window(320,65);

  window->begin();

  Button *btnTest = new Button(20, 20, 80, 25, "plugin test");
  btnTest->callback(cb_btnTest, 0);
  
  Button *btnExit = new Button(220,20, 80, 25, "E&xit");
  btnExit->callback(cb_btnExit, 0);

  window->end();
  window->show(argc,argv);

  return run();
}

fltk_plugin.cxx
/*===========*/
// g++ `fltk-config --cxxflags` -shared -o fltk_plugin.dll fltk_plugin.cxx 
`fltk-config --ldflags`

#include <stdio.h>
#include <fltk/ask.h>
#include <fltk/Window.h>
#include <fltk/Button.h>

using namespace fltk;

extern "C" __declspec(dllexport) Window* showWindow();

void cb_btnTest(Widget *, void *) {
    message("abc");
    return;
}

void cb_btnTest2(Widget *, void *) {
    message("abc 2");
    return;
}

Window* showWindow()
{
    Window *winOut = new Window(50, 50, 500, 500, "");
    winOut->copy_label("plugin window");
    winOut->box(BORDER_BOX);

    winOut->begin();

    Button *o = new Button(10, 10, 100, 20, "");
    o->copy_label("button test");
    o->callback(cb_btnTest);

    Button *o2 = new Button(120, 10, 100, 20, "");
    o2->copy_label("button test 2");
    o2->callback(cb_btnTest2);

    winOut->end();

    return winOut;
}
_______________________________________________
fltk-bugs mailing list
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to