Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Hosting SWT windows inside a WIN32 app
Hosting SWT windows inside a WIN32 app [message #454610] Mon, 25 April 2005 19:21 Go to next message
Eclipse UserFriend
Originally posted by: rickkhunter.hotmail.com

Here's an interresting challenge.

As part of the migration process of porting our application from win32 to
java/SWT, it is a requierement that the migration be done progressively.
In other words, the main window of the application will remain win32
while we gradually re-write the child windows with SWT.

Our current approach is to contain SWT shells by first creating them, then
using their window handles and the SetParent WIN32 function to attach them
to our application. So far all seemed well but when the newly created SWT
window has the focus, the main window loses it.

From what I can tell, it's because the Shell object is by default created
as a main window. My question is this, is there a way to create a SWT
shell that would be a child to a WIN32 main window?

I have tried several things, but I can't seem to find a way to construct a
Shell and giving it a WIN32 window handle as a parent.

Is there a way to do that? or to do something that would do the equivalent?

Yannick Grosjean
Solutuons JetSoft
Re: Hosting SWT windows inside a WIN32 app [message #454624 is a reply to message #454610] Tue, 26 April 2005 05:13 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">My only suggestion would be to create a 'wrapper
Shell' for your win32 windows and assign this Shell instance the handle
of your win32 Shell.  You'll have to manually (through win32 code)
dispose of the Shell represented by the previous handle, but that
should be all the cleaning you'll have to do (to my knowledge anyway). 
Then you can create SWT Shell(s) with this wrapper Shell as a parent. 
As far as I know, there is no internal data stored by the Shell class
which would prevent this from working.  I don't know about the effect
on the other SWT classes (like Display).  Steve or Carolyn would be the
ones to answer that one.<br>
<br>
Daniel<br>
</font><br>
Yannick Grosjean wrote:
<blockquote cite="midfaaeedb3bcfbe1d1697ab6254a5cb47e$1@www.eclipse.org"
type="cite">Here's an interresting challenge.
<br>
<br>
As part of the migration process of porting our application from win32
to java/SWT, it is a requierement that the migration be done
progressively. In other words, the main window of the application will
remain  win32 while we gradually re-write the child windows with SWT. <br>
Our current approach is to contain SWT shells by first creating them,
then using their window handles and the SetParent WIN32 function to
attach them to our application. So far all seemed well but when the
newly created SWT window has the focus, the main window loses it.  <br>
From what I can tell, it's because the Shell object is by default
created as a main window. My question is this, is there a way to create
a SWT shell that would be a child to a WIN32 main window? <br>
I have tried several things, but I can't seem to find a way to
construct a Shell  and giving it a WIN32 window handle as a parent. <br>
Is there a way to do that? or to do something that would do the
equivalent?
<br>
<br>
Yannick Grosjean
<br>
Solutuons JetSoft
<br>
<br>
</blockquote>
</body>
</html>
Re: Hosting SWT windows inside a WIN32 app [message #454657 is a reply to message #454610] Tue, 26 April 2005 14:35 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Yes, if you mean "dialog child", then use the constructor "new Shell
(Shell)". If you mean "MDI child", then this is not supported in SWT.

I'm not sure what the original problem is. It should be easy enough to mix
SWT and native code. Can you give a better description, or even better,
some I can run code?

"Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
news:faaeedb3bcfbe1d1697ab6254a5cb47e$1@www.eclipse.org...
> Here's an interresting challenge.
>
> As part of the migration process of porting our application from win32 to
> java/SWT, it is a requierement that the migration be done progressively.
> In other words, the main window of the application will remain win32
> while we gradually re-write the child windows with SWT.
>
> Our current approach is to contain SWT shells by first creating them, then
> using their window handles and the SetParent WIN32 function to attach them
> to our application. So far all seemed well but when the newly created SWT
> window has the focus, the main window loses it.
>
> From what I can tell, it's because the Shell object is by default created
> as a main window. My question is this, is there a way to create a SWT
> shell that would be a child to a WIN32 main window?
>
> I have tried several things, but I can't seem to find a way to construct a
> Shell and giving it a WIN32 window handle as a parent.
>
> Is there a way to do that? or to do something that would do the
equivalent?
>
> Yannick Grosjean
> Solutuons JetSoft
>
Re: Hosting SWT windows inside a WIN32 app [message #454659 is a reply to message #454657] Tue, 26 April 2005 14:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rickkhunter.hotmail.com

actually I was indeed meanin MDI Child... I've been trying this morning
with decorations since they are said to be providing the functionality of
shells without being top windows, alas, without too much success.

Another way to put my problem would be to picture a very large WIN32 MDI
application, with many types of MDI Children, that I want to gradually
replace with SWT children, ultimately creating an MDI parent in SWT

Steve Northover wrote:

> Yes, if you mean "dialog child", then use the constructor "new Shell
> (Shell)". If you mean "MDI child", then this is not supported in SWT.

> I'm not sure what the original problem is. It should be easy enough to mix
> SWT and native code. Can you give a better description, or even better,
> some I can run code?

> "Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
> news:faaeedb3bcfbe1d1697ab6254a5cb47e$1@www.eclipse.org...
>> Here's an interresting challenge.
>>
>> As part of the migration process of porting our application from win32 to
>> java/SWT, it is a requierement that the migration be done progressively.
>> In other words, the main window of the application will remain win32
>> while we gradually re-write the child windows with SWT.
>>
>> Our current approach is to contain SWT shells by first creating them, then
>> using their window handles and the SetParent WIN32 function to attach them
>> to our application. So far all seemed well but when the newly created SWT
>> window has the focus, the main window loses it.
>>
>> From what I can tell, it's because the Shell object is by default created
>> as a main window. My question is this, is there a way to create a SWT
>> shell that would be a child to a WIN32 main window?
>>
>> I have tried several things, but I can't seem to find a way to construct a
>> Shell and giving it a WIN32 window handle as a parent.
>>
>> Is there a way to do that? or to do something that would do the
> equivalent?
>>
>> Yannick Grosjean
>> Solutuons JetSoft
>>
Re: Hosting SWT windows inside a WIN32 app [message #454680 is a reply to message #454659] Wed, 27 April 2005 13:28 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Windows MDI is a real mess, even for C programmers. MDI is not supported by
SWT because it only occurs on Windows and is not portable.

If you really need Windows MDI, you might be better off leaving that part in
C and embedding SWT composites inside C based MDI parents. This may require
modifications to the SWT event loop and other low level hacks to the toolkit
to get it to work.

"Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
news:9bc963ed116964571994583f4d96c228$1@www.eclipse.org...
> actually I was indeed meanin MDI Child... I've been trying this morning
> with decorations since they are said to be providing the functionality of
> shells without being top windows, alas, without too much success.
>
> Another way to put my problem would be to picture a very large WIN32 MDI
> application, with many types of MDI Children, that I want to gradually
> replace with SWT children, ultimately creating an MDI parent in SWT
>
> Steve Northover wrote:
>
> > Yes, if you mean "dialog child", then use the constructor "new Shell
> > (Shell)". If you mean "MDI child", then this is not supported in SWT.
>
> > I'm not sure what the original problem is. It should be easy enough to
mix
> > SWT and native code. Can you give a better description, or even better,
> > some I can run code?
>
> > "Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
> > news:faaeedb3bcfbe1d1697ab6254a5cb47e$1@www.eclipse.org...
> >> Here's an interresting challenge.
> >>
> >> As part of the migration process of porting our application from win32
to
> >> java/SWT, it is a requierement that the migration be done
progressively.
> >> In other words, the main window of the application will remain win32
> >> while we gradually re-write the child windows with SWT.
> >>
> >> Our current approach is to contain SWT shells by first creating them,
then
> >> using their window handles and the SetParent WIN32 function to attach
them
> >> to our application. So far all seemed well but when the newly created
SWT
> >> window has the focus, the main window loses it.
> >>
> >> From what I can tell, it's because the Shell object is by default
created
> >> as a main window. My question is this, is there a way to create a SWT
> >> shell that would be a child to a WIN32 main window?
> >>
> >> I have tried several things, but I can't seem to find a way to
construct a
> >> Shell and giving it a WIN32 window handle as a parent.
> >>
> >> Is there a way to do that? or to do something that would do the
> > equivalent?
> >>
> >> Yannick Grosjean
> >> Solutuons JetSoft
> >>
>
Re: Hosting SWT windows inside a WIN32 app [message #454692 is a reply to message #454680] Wed, 27 April 2005 14:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rickkhunter.hotmail.com

Actually it is what I'm trying to do. Let me give some more details. The
current application is built using a development tool called NatStar which
has it's own wrapper over windows API. It is designed for N-tier apps and
generates C code for the target platform. We use it on windows so it is
rougly the same as talking about a C MDI App.

Using a DLL in C and JNI, we are able to create SWT java windows. Since
constructing a composite requires a parent composite, I guess this is
where some of the low level hacking occurs? From what I get of your last
post, it seems to we it would be a lot of pain to get this to work? I
don't suppose it's been done before?


Steve Northover wrote:

> Windows MDI is a real mess, even for C programmers. MDI is not supported by
> SWT because it only occurs on Windows and is not portable.

> If you really need Windows MDI, you might be better off leaving that part in
> C and embedding SWT composites inside C based MDI parents. This may require
> modifications to the SWT event loop and other low level hacks to the toolkit
> to get it to work.

> "Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
> news:9bc963ed116964571994583f4d96c228$1@www.eclipse.org...
>> actually I was indeed meanin MDI Child... I've been trying this morning
>> with decorations since they are said to be providing the functionality of
>> shells without being top windows, alas, without too much success.
>>
>> Another way to put my problem would be to picture a very large WIN32 MDI
>> application, with many types of MDI Children, that I want to gradually
>> replace with SWT children, ultimately creating an MDI parent in SWT
>>
>> Steve Northover wrote:
>>
>> > Yes, if you mean "dialog child", then use the constructor "new Shell
>> > (Shell)". If you mean "MDI child", then this is not supported in SWT.
>>
>> > I'm not sure what the original problem is. It should be easy enough to
> mix
>> > SWT and native code. Can you give a better description, or even better,
>> > some I can run code?
>>
>> > "Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
>> > news:faaeedb3bcfbe1d1697ab6254a5cb47e$1@www.eclipse.org...
>> >> Here's an interresting challenge.
>> >>
>> >> As part of the migration process of porting our application from win32
> to
>> >> java/SWT, it is a requierement that the migration be done
> progressively.
>> >> In other words, the main window of the application will remain win32
>> >> while we gradually re-write the child windows with SWT.
>> >>
>> >> Our current approach is to contain SWT shells by first creating them,
> then
>> >> using their window handles and the SetParent WIN32 function to attach
> them
>> >> to our application. So far all seemed well but when the newly created
> SWT
>> >> window has the focus, the main window loses it.
>> >>
>> >> From what I can tell, it's because the Shell object is by default
> created
>> >> as a main window. My question is this, is there a way to create a SWT
>> >> shell that would be a child to a WIN32 main window?
>> >>
>> >> I have tried several things, but I can't seem to find a way to
> construct a
>> >> Shell and giving it a WIN32 window handle as a parent.
>> >>
>> >> Is there a way to do that? or to do something that would do the
>> > equivalent?
>> >>
>> >> Yannick Grosjean
>> >> Solutuons JetSoft
>> >>
>>
Re: Hosting SWT windows inside a WIN32 app [message #454913 is a reply to message #454692] Mon, 02 May 2005 17:41 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You might be able to use Shell.win32_new() to get what you want but no
guarantees. Sorry I can't be of more help but I have no time.

"Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
news:0c3f4dfaa0c31cca7bfcf0215279dee5$1@www.eclipse.org...
> Actually it is what I'm trying to do. Let me give some more details. The
> current application is built using a development tool called NatStar which
> has it's own wrapper over windows API. It is designed for N-tier apps and
> generates C code for the target platform. We use it on windows so it is
> rougly the same as talking about a C MDI App.
>
> Using a DLL in C and JNI, we are able to create SWT java windows. Since
> constructing a composite requires a parent composite, I guess this is
> where some of the low level hacking occurs? From what I get of your last
> post, it seems to we it would be a lot of pain to get this to work? I
> don't suppose it's been done before?
>
>
> Steve Northover wrote:
>
> > Windows MDI is a real mess, even for C programmers. MDI is not
supported by
> > SWT because it only occurs on Windows and is not portable.
>
> > If you really need Windows MDI, you might be better off leaving that
part in
> > C and embedding SWT composites inside C based MDI parents. This may
require
> > modifications to the SWT event loop and other low level hacks to the
toolkit
> > to get it to work.
>
> > "Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
> > news:9bc963ed116964571994583f4d96c228$1@www.eclipse.org...
> >> actually I was indeed meanin MDI Child... I've been trying this morning
> >> with decorations since they are said to be providing the functionality
of
> >> shells without being top windows, alas, without too much success.
> >>
> >> Another way to put my problem would be to picture a very large WIN32
MDI
> >> application, with many types of MDI Children, that I want to gradually
> >> replace with SWT children, ultimately creating an MDI parent in SWT
> >>
> >> Steve Northover wrote:
> >>
> >> > Yes, if you mean "dialog child", then use the constructor "new Shell
> >> > (Shell)". If you mean "MDI child", then this is not supported in
SWT.
> >>
> >> > I'm not sure what the original problem is. It should be easy enough
to
> > mix
> >> > SWT and native code. Can you give a better description, or even
better,
> >> > some I can run code?
> >>
> >> > "Yannick Grosjean" <rickkhunter@hotmail.com> wrote in message
> >> > news:faaeedb3bcfbe1d1697ab6254a5cb47e$1@www.eclipse.org...
> >> >> Here's an interresting challenge.
> >> >>
> >> >> As part of the migration process of porting our application from
win32
> > to
> >> >> java/SWT, it is a requierement that the migration be done
> > progressively.
> >> >> In other words, the main window of the application will remain
win32
> >> >> while we gradually re-write the child windows with SWT.
> >> >>
> >> >> Our current approach is to contain SWT shells by first creating
them,
> > then
> >> >> using their window handles and the SetParent WIN32 function to
attach
> > them
> >> >> to our application. So far all seemed well but when the newly
created
> > SWT
> >> >> window has the focus, the main window loses it.
> >> >>
> >> >> From what I can tell, it's because the Shell object is by default
> > created
> >> >> as a main window. My question is this, is there a way to create a
SWT
> >> >> shell that would be a child to a WIN32 main window?
> >> >>
> >> >> I have tried several things, but I can't seem to find a way to
> > construct a
> >> >> Shell and giving it a WIN32 window handle as a parent.
> >> >>
> >> >> Is there a way to do that? or to do something that would do the
> >> > equivalent?
> >> >>
> >> >> Yannick Grosjean
> >> >> Solutuons JetSoft
> >> >>
> >>
>
Previous Topic:Mozilla browser in eclipse problems.
Next Topic:Anti-aliasing
Goto Forum:
  


Current Time: Fri Apr 26 14:49:45 GMT 2024

Powered by FUDForum. Page generated in 0.03969 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top