Re: Mixing Windows API and GTK+
- From: Michael L Torrie <torriem chem byu edu>
- To: gtk-list gnome org
- Subject: Re: Mixing Windows API and GTK+
- Date: Wed, 06 Jul 2005 14:02:56 -0600
On Wed, 2005-07-06 at 14:46 -0500, Douglas Vechinski wrote:
> I have a gtk+ application that I developed under Linux. I "ported" to
> Windows using the MSYS/MINGW environments along with the native window
> compilation of GTK+. Now someone is interested in have me create a DLL
> out of this code so that it can be used as part of another Windows
> applications. While one question pertains to how do I create a DLL
> using the MSYS/MINGW environment but is not related to this list. My
> question for this list is, can there be a problem with mixing a Windows
> code that uses then WINAPI to create windows and such and call a
> function that would essentially create my GTK+ window and its associated
> widgets and mouse events and such or should everything work ok.
I am also interested in doing this for other reasons. However I see a
number of problems.
First, GTK is an event-driven library. That means you usually call gtk
and it never returns to you, except to call callbacks. I think you
could get around this problem by having your dll launch gtk_main() in a
thread.
Additionally, like all GUI toolkits, GTK widgets can only be accessed by
one thread at a time. In MFC I used to have to post messages to the
windows' event loop to do things. With GTK, there are locking
primitives you can use. Just be aware that you have to take special
steps when using gtk in a threaded environment.
You'd also have to make sure you didn't accidentally start up a bunch of
gtk main loops. Probably the dll initialization code could start a
thread and initalize the gtk main loop. Then other functions could, via
the locking primitives, interact with the main loop.
I think this is definitely doable. And I'd love to see a demonstration
of this type of thing. I can see a number of applications where
embedding a gtk applet as a dll (callable by a simple function call)
would be useful. I may just try coding up a small example to test my
theories.
Michael
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]