On Jan 9, 2:36 pm, Thomas  Hansen <[email protected]> wrote:
> On Jan 9, 1:33 pm, Thomas  Hansen <[email protected]> wrote:
>
>
>
> > On Jan 8, 6:39 pm, "Alex Holkner" <[email protected]> wrote:
>
> > > On Fri, Jan 9, 2009 at 11:38 AM, Alex Holkner <[email protected]> 
> > > wrote:
> > > > On Fri, Jan 9, 2009 at 10:51 AM, Thomas Hansen 
> > > > <[email protected]> wrote:
>
> > > >> this is a long shot...sorry i am not very experienced with win32 and
> > > >> this might be more of a win32 question than a pyglet question
>
> > > >> i have this pyglet app which runs in a nice window and implements a
> > > >> COM server so that it can be start and control it from Visual Basic
> > > >> etc.  What I would like to do is make it the window a child window of
> > > >> the actual application that launches it.
>
> > > >> I have tried calling:
> > > >> win32gui.SetParent(self._hwnd, parent_hwnd)
> > > >> within my window class (inherist from pyglet.window.Window) with
> > > >> little success..the window just disappears.
>
> > > >> other calls like win32gui.SetWindowPos(self._hwnd, ...) seem to work
> > > >> fine and have the expected effect
>
> > > >> Any ideas on how to accomplish this?  or is it simply not
> > > >> possible...I'm worried calling setParent destroys the OpenGl context
> > > >> or something like that..although there doesnt seeem to be any errors
> > > >> thrown by calling setParent.  I have looked at the pyglet window code
> > > >> for win32 and how it creates the window.  it calls CreateWindowExW;
> > > >> maybe I can hack pyglet here to achieve the desired effect?
>
> > > >> I'm really trying to avoid having to implement this app in C/C++ just
> > > >> so the window can be hooked to another appliaction window as a
> > > >> controll.  Any dieas?
>
> > > > I don't think reparenting the window is going to work.  However,
> > > > setting the window's parent in CreateWindowExW should work fine.
> > > > (Change the 0 under the 'height' argument to your parent window's
> > > > hwnd).
>
> > > You may also need to change the window style from WS_OVERLAPPED etc to 
> > > WS_CHILD.
>
> > > Alex.
>
> > Alex,
>
> > thanks alot for you help. I've tried your suggestions but havent
> > managed to get it to work yet.  I have added a handle to the parent
> > window in the BaseWindow class of my local pyglet install.  If I try
> > to set the parent window top most by calling from my pyglet window:
>
> > win32gui.SetWindowPos(self.parent_hwnd, win32con.HWND_TOPMOST,
> > 0,0,0,0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
>
> > that works fine; which makes me think my handle to the external window
> > works properly.
>
> > I then tried the following in the Win32Window's _create method,
> > attempting to make the window a child window of the external window
> > (with handle: self.parent_hwnd).  I changed the parent parameter (the
> > one after height) to the parent handle, likeyou suggested.  i set the
> > EX style to 0 and the WS style to WS_CHILD.  However, as soon as I
> > pass the parent handle to CreateWindowExW, neither of the windows are
> > displayed when I run the application, even if I leave the other style
> > parameters as is.  Any ideas?
>
> >             if self.parent_hwnd==0:
> >                 self._hwnd = _user32.CreateWindowExW(
> >                     self._ex_ws_style,
> >                     self._window_class.lpszClassName,
> >                     u'',
> >                     self._ws_style,
> >                     CW_USEDEFAULT,
> >                     CW_USEDEFAULT,
> >                     width,
> >                     height,
> >                     0,
> >                     0,
> >                     self._window_class.hInstance,
> >                     0)
> >             else: #we have a child window
> >                 self._hwnd = _user32.CreateWindowExW(
> >                     0,
> >                     self._window_class.lpszClassName,
> >                     u'',
> >                     WS_CHILD,
> >                     CW_USEDEFAULT,
> >                     CW_USEDEFAULT,
> >                     width,
> >                     height,
> >                     self.parent_hwnd,
> >                     0,
> >                     self._window_class.hInstance,
> >                     0)
>
> > Again,  thanks alot!
>
> _user32.CreateWindowExW  does not return when i pass it the parent
> handle.  Do I have to type cast or make sure the parent handle is of a
> specific type.  I guess I only tried it with win32gui.SetWindowPos();
> Maybe win32gui works different than the libs you call directly via
> ctypes here?
>
>  If this gets too off-topic for this mailing list let me know, im just
> trying to figure it out and figure i might as well keep posting my
> progress if anyone else ever wants to do something similar with a
> pyglet window.

the following did th trick!
Not sure why it doesn't work when I pass the parent handle directly to
CreateWindowExW.  Setting teh style to WS_CHILD also makes it not
work.  but this works for my purposes.

self._hwnd = _user32.CreateWindowExW(
                    self._ex_ws_style,
                    self._window_class.lpszClassName,
                    u'',
                    WS_POPUP,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    width,
                    height,
                    0,
                    0,
                    self._window_class.hInstance,
                    0)
                win32gui.SetParent(self._hwnd, self.parent_hwnd)




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to