[lazarus] Forms inside a library
Marc Weustink
marc at dommelstein.net
Sun Mar 16 18:24:41 EST 2003
At 02:24 17-3-2003 +1100, Steve Gatenby wrote:
>Is it possible to display forms contained in a library (lib***.so) ?
>I can use libraries for all non-graphical functions without problems, but
>fail with "Gtk-Warning **: gtk_type_create(): type 'LCLWinapiWidget
>already exists"
>
>Any ideas on this ??
At the time I wrote LCLWinapiWidget I wasn't a gtk expert (and that's still
the case :), so the code there is merely based on examples and some GTK
internals (I used gtkedit ? as an example).
However looking at it now I can imagine your problem. I wrote a little
patch based on dox, but couldn't test it. So I didn't commit it to cvs. If
you aply the patch and it works, please let me know.
Marc
<patch>
Index: gtkwinapiwindow.pp
===================================================================
RCS file: /FPC/CVS/projects/lazarus/lcl/interfaces/gtk/gtkwinapiwindow.pp,v
retrieving revision 1.43
diff -u -r1.43 gtkwinapiwindow.pp
--- gtkwinapiwindow.pp 30 Dec 2002 17:24:08 -0000 1.43
+++ gtkwinapiwindow.pp 16 Mar 2003 23:33:36 -0000
@@ -331,10 +331,11 @@
end;
function GTKAPIWidgetClient_GetType: Guint;
const
+ TYPE_NAME = 'LCLWinapiClient';
TheType: Guint = 0;
Info: TGTKTypeInfo = (
- type_name: 'LCLWinapiClient';
+ type_name: TYPE_NAME;
object_size: SizeOf(TGTKAPIWidgetClient)+100;
class_size: SizeOf(TGTKAPIWidgetClientClass)+100;
class_init_func: @GTKAPIWidgetClient_ClassInit;
@@ -344,8 +345,12 @@
base_class_init_func: nil;
);
begin
- if (TheType = 0) then
- TheType := gtk_type_unique(gtk_fixed_type, at Info);
+ if (TheType = 0)
+ then begin
+ TheType := gtk_type_from_name(TYPE_NAME);
+ if TheType = 0
+ then TheType := gtk_type_unique(gtk_fixed_type, at Info);
+ end;
Result := TheType;
end;
@@ -674,9 +679,10 @@
function GTKAPIWidget_GetType: Guint;
const
+ WAW_NAME = 'LCLWinapiWidget';
wawType: Guint = 0;
wawInfo: TGTKTypeInfo = (
- type_name: 'LCLWinapiWidget';
+ type_name: WAW_NAME;
object_size: SizeOf(TGTKAPIWidget)+100; // a TGTKScrolledWindow
class_size: SizeOf(TGTKAPIWidgetClass)+100;
class_init_func: @GTKAPIWidget_ClassInit;
@@ -687,7 +693,11 @@
);
begin
if (wawType = 0)
- then wawType := gtk_type_unique(gtk_scrolled_window_get_type, @wawInfo);
+ then begin
+ wawType := gtk_type_from_name(WAW_NAME);
+ if wawType = 0
+ then wawType := gtk_type_unique(gtk_scrolled_window_get_type, @wawInfo);
+ end;
Result := wawType;
end;
</patch>
More information about the Lazarus
mailing list