Win32Window how to get Squeak's window Handle? VM?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
34 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Win32Window how to get Squeak's window Handle? VM?

Herbert König
Hello,

FFI's Win32Window>>getFocus works as long as Squeak has the input
focus.

The VM knows this handle under stWindow.

Is there a way to get this in Squeak? Besides writing a new primitive?

The goal of all this is to size the Windows window tightly around a
Morph.


Thanks,

Herbert                          mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Igor Stasenko
use GetProcessHandle, and then GetMainWindow..
win32 kernel functions.. i dont remember how called last function
exactly, but its somewhat possible to get main window for current
process.

On 11/07/07, Herbert König <[hidden email]> wrote:

> Hello,
>
> FFI's Win32Window>>getFocus works as long as Squeak has the input
> focus.
>
> The VM knows this handle under stWindow.
>
> Is there a way to get this in Squeak? Besides writing a new primitive?
>
> The goal of all this is to size the Windows window tightly around a
> Morph.
>
>
> Thanks,
>
> Herbert                          mailto:[hidden email]
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

timrowledge

On 11-Jul-07, at 7:40 AM, sig wrote:

> use GetProcessHandle, and then GetMainWindow..
> win32 kernel functions.. i dont remember how called last function
> exactly, but its somewhat possible to get main window for current
> process.
>
> On 11/07/07, Herbert König <[hidden email]> wrote:
>> Hello,
>>
>> FFI's Win32Window>>getFocus works as long as Squeak has the input
>> focus.
>>
>> The VM knows this handle under stWindow.
>>
>> Is there a way to get this in Squeak? Besides writing a new  
>> primitive?
Ffenestri. Search for it on the swiki. Assuming the windows plugin  
meets the spec then the window you normally think of as the main  
window should be accessible. IIRC. YMMV. TTFN.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
To err is human; to forgive, beyond the scope of the Operating System.



Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Herbert König
In reply to this post by Igor Stasenko
Hello Sig,

Wednesday, July 11, 2007, 4:40:25 PM, you wrote:

s> use GetProcessHandle, and then GetMainWindow..
s> win32 kernel functions.. i dont remember how called last function
s> exactly, but its somewhat possible to get main window for current
s> process.

Sounds good but alas my msdn help doesn't sprit out how to use
getProcessHandle or which dll it's in.

Can you give some details?


Thanks

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

RE: Win32Window how to get Squeak's window Handle? VM?

Ron Teitelbaum
http://support.microsoft.com/kb/124103 

Ron

> -----Original Message-----
> From: [hidden email] [mailto:squeak-dev-
> [hidden email]] On Behalf Of Herbert König
> Sent: Wednesday, July 11, 2007 12:49 PM
> To: The general-purpose Squeak developers list
> Subject: Re: Win32Window how to get Squeak's window Handle? VM?
>
> Hello Sig,
>
> Wednesday, July 11, 2007, 4:40:25 PM, you wrote:
>
> s> use GetProcessHandle, and then GetMainWindow..
> s> win32 kernel functions.. i dont remember how called last function
> s> exactly, but its somewhat possible to get main window for current
> s> process.
>
> Sounds good but alas my msdn help doesn't sprit out how to use
> getProcessHandle or which dll it's in.
>
> Can you give some details?
>
>
> Thanks
>
> Herbert                            mailto:[hidden email]
>



Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Igor Stasenko
In reply to this post by Herbert König
you can use EnumWindows function to enumerate all top level windows
and find one that having process handle (GetWindowThreadProcessId )
same as you get with GetProcessHandle

see
http://msdn2.microsoft.com/en-us/library/ms633497.aspx
http://msdn2.microsoft.com/en-us/library/ms633522.aspx


On 11/07/07, Herbert König <[hidden email]> wrote:

> Hello Sig,
>
> Wednesday, July 11, 2007, 4:40:25 PM, you wrote:
>
> s> use GetProcessHandle, and then GetMainWindow..
> s> win32 kernel functions.. i dont remember how called last function
> s> exactly, but its somewhat possible to get main window for current
> s> process.
>
> Sounds good but alas my msdn help doesn't sprit out how to use
> getProcessHandle or which dll it's in.
>
> Can you give some details?
>
>
> Thanks
>
> Herbert                            mailto:[hidden email]
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Herbert König
In reply to this post by Ron Teitelbaum
Hello Ron,

RT> http://support.microsoft.com/kb/124103
thanks but this is quite some c-code with a lot of if's attached :-)

It even might have the same problems as the FFI examples if Squeak
doesn't have the focus.

As I started the whole search after building a VM and after asking
some "Real Windows Developers :-)" it seems easiest to return the
handle from the VM which knows it as stWindow.

IIRC in the plugin building howtos there's one which simply returns an
Integer, I might be able to tweak this to return stWindow.

This may even end up being platform independent while my FFI-approach
will only be good for Windows.


Thanks again,

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Herbert König
In reply to this post by timrowledge
Hello Tim,

tR> Ffenestri. Search for it on the swiki. Assuming the windows plugin
tR> meets the spec then the window you normally think of as the main  
tR> window should be accessible. IIRC. YMMV. TTFN.

Ffenestri creates Windows and uses the handle returned by the OS. I
had an interesting tour through the VM and plugins today. Looks like I
will finally enter the club of plugin creators :-)


Thanks

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Igor Stasenko
btw, just recalled, you can't use EnumWindows function , because it
requires callback..
and you can't provide it except using plugin :)
or.. using my asm-generator with exupery to generate callback function
on-the-fly.
its still incomplete but will be very useful for such purposes :)

On 12/07/07, Herbert König <[hidden email]> wrote:

> Hello Tim,
>
> tR> Ffenestri. Search for it on the swiki. Assuming the windows plugin
> tR> meets the spec then the window you normally think of as the main
> tR> window should be accessible. IIRC. YMMV. TTFN.
>
> Ffenestri creates Windows and uses the handle returned by the OS. I
> had an interesting tour through the VM and plugins today. Looks like I
> will finally enter the club of plugin creators :-)
>
>
> Thanks
>
> Herbert                            mailto:[hidden email]
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Bert Freudenberg
In reply to this post by Herbert König
On Jul 11, 2007, at 23:46 , Herbert König wrote:

> Hello Tim,
>
> tR> Ffenestri. Search for it on the swiki. Assuming the windows plugin
> tR> meets the spec then the window you normally think of as the main
> tR> window should be accessible. IIRC. YMMV. TTFN.
>
> Ffenestri creates Windows and uses the handle returned by the OS. I
> had an interesting tour through the VM and plugins today. Looks like I
> will finally enter the club of plugin creators :-)

Why create another plugin if Ffenestri does what you need? And if it  
is missing something, I'd rather extend HostWindowPlugin than adding  
a new plugin.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Herbert König
Hello Bert,


BF> Why create another plugin if Ffenestri does what you need? And if it
BF> is missing something, I'd rather extend HostWindowPlugin than adding
BF> a new plugin.

the VM does what I need actually and I already thought of just making
a new VM which gives access to the C-variable stWindow to Squeak.

But I'll consider your suggestion too. So much to learn. And the
plugin documentation is a bit out of date.


Cheers

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

timrowledge

On 12-Jul-07, at 2:14 AM, Herbert König wrote:



>
> the VM does what I need actually and I already thought of just making
> a new VM which gives access to the C-variable stWindow to Squeak.
But that variable is slated for retirement; it is irrelevant once  
Ffenestri is actually used.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
"Bother!" said Pooh, searching for the $10m winning lottery ticket.



Reply | Threaded
Open this post in threaded view
|

How to coece a HWND* was: Win32Window how to get Squeak's window Handle? VM?

Herbert König
In reply to this post by Herbert König
Hello,

finally I managed to build a kind of working plugin.

Working in that I retrieve the window handle of the Squeak OS window
from the VM and I can use this handle (still inside the plugin) to
close the Squeak window.

How do I get this HWND* back to Squeak so that it returns the same as
Win32Window class getFocus?

I can send something back to Squeak (if I'm not closing the Squeak
window) but whatever I try gives a different result from what
Win32Window class getFocus returns.

I could stay within the plugin to do all I want but would prefer to
store the handle in Squeak and in subsequent calls use the plugin to
e.g. resize the window.



Thanks

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Win32Window how to get Squeak's window Handle? VM?

Herbert König
In reply to this post by timrowledge
Hi Tim,

>>
>> the VM does what I need actually and I already thought of just making
>> a new VM which gives access to the C-variable stWindow to Squeak.
tR> But that variable is slated for retirement; it is irrelevant once
tR> Ffenestri is actually used.

well I want to play with the window now and though I looked a lot at
the Ffenestri code I don't feel qualified to build myself a
HostWindows VM.

Actually I tried to experiment with HostWindows Rome from Impara but
couldn't get it to work (= load).

Cheers,

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Changing window size (was Re: How to coece a HWND*?)

Bert Freudenberg
In reply to this post by Herbert König

On Jul 12, 2007, at 19:39 , Herbert König wrote:

> Hello,
>
> finally I managed to build a kind of working plugin.
>
> Working in that I retrieve the window handle of the Squeak OS window
> from the VM and I can use this handle (still inside the plugin) to
> close the Squeak window.
>
> How do I get this HWND* back to Squeak so that it returns the same as
> Win32Window class getFocus?
>
> I can send something back to Squeak (if I'm not closing the Squeak
> window) but whatever I try gives a different result from what
> Win32Window class getFocus returns.
>
> I could stay within the plugin to do all I want but would prefer to
> store the handle in Squeak and in subsequent calls use the plugin to
> e.g. resize the window.

If resizing the Squeak window is actually what you want - why don't  
you implement primitive 92 which is meant for that purpose? It is  
only actually implemented on the Mac AFAIK but that would be actually  
useful to have on all platforms. See DisplayScreen  
class>>depth:width:height:fullscreen:

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Changing window size (was Re: How to coece a HWND*?)

johnmci
http://wiki.squeak.org/squeak/3862
Areithfa Ffenestri
Resizing can be done two ways - by using the Host UI tools or  
programmatically.
HostWindowProxy > primitiveWindowSize:x:y: will change the size of  
the specified window using HostWindowPlugin >


The depth:width:height:fullscreen:  call on the mac actually sets the  
monitor size and depth, and flips the screen to full screen removing  
the operating system visual widgets.



On Jul 12, 2007, at 12:18 PM, Bert Freudenberg wrote:

>
> On Jul 12, 2007, at 19:39 , Herbert König wrote:
>
>> Hello,
>>
>> finally I managed to build a kind of working plugin.
>>
>> Working in that I retrieve the window handle of the Squeak OS window
>> from the VM and I can use this handle (still inside the plugin) to
>> close the Squeak window.
>>
>> How do I get this HWND* back to Squeak so that it returns the same as
>> Win32Window class getFocus?
>>
>> I can send something back to Squeak (if I'm not closing the Squeak
>> window) but whatever I try gives a different result from what
>> Win32Window class getFocus returns.
>>
>> I could stay within the plugin to do all I want but would prefer to
>> store the handle in Squeak and in subsequent calls use the plugin to
>> e.g. resize the window.
>
> If resizing the Squeak window is actually what you want - why don't  
> you implement primitive 92 which is meant for that purpose? It is  
> only actually implemented on the Mac AFAIK but that would be  
> actually useful to have on all platforms. See DisplayScreen  
> class>>depth:width:height:fullscreen:
>
> - Bert -
>
>
>

--
========================================================================
===
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===



Reply | Threaded
Open this post in threaded view
|

Re: Changing window size (was Re: How to coece a HWND*?)

Michael Rueger-4
In reply to this post by Bert Freudenberg
Bert Freudenberg wrote:
> If resizing the Squeak window is actually what you want - why don't you
> implement primitive 92 which is meant for that purpose? It is only
> actually implemented on the Mac AFAIK but that would be actually useful
> to have on all platforms. See DisplayScreen
> class>>depth:width:height:fullscreen:

and while you're at it move
DisplayScreen>>supportsDisplayDepth: pixelDepth

highjack of primitive 91
InputSensor>>primCursorLocPut: aPoint

into a different place so Squeak again as the ability to set the cursor
position in a platform independent way.

;-)

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Changing window size (was Re: How to coece a HWND*?)

Bert Freudenberg
In reply to this post by johnmci
It actually should switch the screen resolution only if the  
fullscreen flag is true. Has been a bug for a long time. But since  
the prim wasn't implemented anywhere else, nobody used it anyway.

- Bert -

On Jul 12, 2007, at 21:24 , John M McIntosh wrote:

> The depth:width:height:fullscreen:  call on the mac actually sets  
> the monitor size and depth, and flips the screen to full screen  
> removing the operating system visual widgets.
>
>
>
> On Jul 12, 2007, at 12:18 PM, Bert Freudenberg wrote:
>
>>
>> On Jul 12, 2007, at 19:39 , Herbert König wrote:
>>
>>> Hello,
>>>
>>> finally I managed to build a kind of working plugin.
>>>
>>> Working in that I retrieve the window handle of the Squeak OS window
>>> from the VM and I can use this handle (still inside the plugin) to
>>> close the Squeak window.
>>>
>>> How do I get this HWND* back to Squeak so that it returns the  
>>> same as
>>> Win32Window class getFocus?
>>>
>>> I can send something back to Squeak (if I'm not closing the Squeak
>>> window) but whatever I try gives a different result from what
>>> Win32Window class getFocus returns.
>>>
>>> I could stay within the plugin to do all I want but would prefer to
>>> store the handle in Squeak and in subsequent calls use the plugin to
>>> e.g. resize the window.
>>
>> If resizing the Squeak window is actually what you want - why  
>> don't you implement primitive 92 which is meant for that purpose?  
>> It is only actually implemented on the Mac AFAIK but that would be  
>> actually useful to have on all platforms. See DisplayScreen  
>> class>>depth:width:height:fullscreen:
>>
>> - Bert -
>>
>>
>>
>
> --
> ======================================================================
> =====
> John M. McIntosh <[hidden email]>
> Corporate Smalltalk Consulting Ltd.  http://
> www.smalltalkconsulting.com
> ======================================================================
> =====
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Changing window size (was Re: How to coece a HWND*?)

Herbert König
In reply to this post by johnmci
Hello John,

JMM> http://wiki.squeak.org/squeak/3862
JMM> Areithfa Ffenestri
JMM> Resizing can be done two ways - by using the Host UI tools or  
JMM> programmatically.
HostWindowProxy >> primitiveWindowSize:x:y: will change the size of  
JMM> the specified window using HostWindowPlugin >

up to now I thought Ffenestri and HostWindowPlugin were the same.
Now I don't find HostWindowProxy in my Squeak where I built a VM with
HostWindowPlugin.

There I found HostWindowPlugin > primitiveHostWindowSizeSet which I
will be able to use after I managed to get the handle of the main
squeak window, which is not generated by the HostWindowPlugin.

What am I missing here? I'd prefer something proven over rolling my
own.


Thanks,

Herbert                            mailto:[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Changing window size (was Re: How to coece a HWND*?)

Herbert König
In reply to this post by Bert Freudenberg
Hello Bert,


BF> If resizing the Squeak window is actually what you want - why don't
BF> you implement primitive 92 which is meant for that purpose? It is
BF> only actually implemented on the Mac AFAIK but that would be actually
BF> useful to have on all platforms. See DisplayScreen  
class>>>depth:width:height:fullscreen:

mainly there's still too much I don't know. At the moment I think I'll
move from my own plugin to HostWindowPlugin as I'm already using ideas
and code from there.

I've already stumbled over
HostWindowPlugin > primitiveHostWindowSizeSet and think that's the way
to go.

Moving to HostWindowPlugin has the problem of getting my changes
accepted. And to find out what has to go into cross and what into the
Windows part of the tree.

As I don't want to do do too much in a single primitive call, I'm
still interested in my original question, how to get the window handle
into squeak for later use in other primitive calls.


Cheers


Herbert                            mailto:[hidden email]


12