Hi, fltk-bugs.
Hello, dear mr. Bill Spitzak and others! I found one error when use
compiled DLL.
One process was loaded DLL (and free DLL) several times to different memory
adresses, therefore Fl_X::make
(in 1.1.8) called RegisterClassEx a lot of time, but class "FLTK" was
registered already. Next call CreateWindowEx
resulted an error, since the WndProc adress for registered classes "FLTK" is
wrong.
I propose some correction to repair this.
I hope that help you. Thank you very much.
Alexey Fofanov.
For 1.1.8
File Fl_win32.cxx
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static void unregister_winclass(LPCTSTR pocClassName, HINSTANCE voHInstance){
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
if (GetClassInfo(fl_display, pocClassName, &wc)) { // try to find
winclass with name = pocClassName
UnregisterClass(pocClassName, voHInstance); // we have to
delete class otherwise will get an error in dll
};
};
Fl_X* Fl_X::make(Fl_Window* w) {
Fl_Group::current(0); // get rid of very common user bug: forgot end()
// if the window is a subwindow and our parent is not mapped yet, we
// mark this window visible, so that mapping the parent at a later
// point in time will call this function again to finally map the subwindow.
if (w->parent() && !Fl_X::i(w->window())) {
w->set_visible();
return 0L;
}
static NameList class_name_list;
static const char *first_class_name = 0L;
const char *class_name = w->xclass();
if (!class_name) class_name = first_class_name; // reuse first class name used
if (!class_name) class_name = "FLTK"; // default to create a "FLTK" WNDCLASS
if (!first_class_name) {
first_class_name = class_name;
}
if (!class_name_list.has_name(class_name)) {
unregister_winclass(class_name, fl_display);
// ! Here i add some
WNDCLASSEX wc;
memset(&wc, 0, sizeof(wc));
.
.
.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
For 2.0.0
File win32\run.cxx
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static void unregister_winclass(LPCTSTR pocClassName, HINSTANCE voHInstance){
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
if (GetClassInfo(fl_display, pocClassName, &wc)) { // try to find
winclass with name = pocClassName
UnregisterClass(pocClassName, voHInstance); // we have to
delete class otherwise will get an error in dll
};
};
static void register_unicode(HICON smallicon, HICON bigicon)
{
unregister_winclass("fltk", xdisplay);
// ! Here i add some
static WNDCLASSEXW wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = wc.cbWndExtra = 0;
wc.hInstance = xdisplay;
wc.hIcon = bigicon;
wc.hIconSm = smallicon;
if (!default_cursor) default_cursor = LoadCursor(NULL, IDC_ARROW);
wc.hCursor = default_cursor;
//uchar r,g,b; get_color(GRAY,r,g,b);
//wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(r,g,b));
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = L"fltk";
wc.cbSize = sizeof(wc);
RegisterClassExW(&wc);
// This is needed or multiple DLL's get confused (?):
// No, doing this makes none of the windows appear:
//UnregisterClass(wc.lpszClassName, xdisplay);
}
static void register_ansi(HICON smallicon, HICON bigicon)
{
unregister_winclass("fltk", xdisplay);
// ! Here i add some
static WNDCLASSEXA wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = wc.cbWndExtra = 0;
wc.hInstance = xdisplay;
wc.hIcon = bigicon;
wc.hIconSm = smallicon;
if (!default_cursor) default_cursor = LoadCursor(NULL, IDC_ARROW);
wc.hCursor = default_cursor;
//uchar r,g,b; get_color(GRAY,r,g,b);
//wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(r,g,b));
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "fltk";
wc.cbSize = sizeof(wc);
RegisterClassExA(&wc);
// This is needed or multiple DLL's get confused (?):
// No, doing this makes none of the windows appear:
//UnregisterClass(wc.lpszClassName, xdisplay);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--
Truly yours,
Alexey Fofanov mailto:[EMAIL PROTECTED]
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs