Finding parent window?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: Finding parent window?

  1. #1
    Mattias Sjögren Guest

    Re: Finding parent window?

    Jan,

    >I can get the Hwnd by enumerating the windows & comparing the title bars -
    >but this is not very satisfactory as all sorts of side effects can occur
    >(and there may be multiple instances of the app running).


    Instead of doing a full enumeration, you can enumerate only the
    windows in the current thread using EnumThreadWindows. That should
    reduce the chance of getting the wrong window.


    Matt

    ============================================
    Mattias Sjögren - mattiass @ hem.passagen.se
    CodeHound - Free VB Search Engine
    http://www.codehound.com

  2. #2
    Mattias Sjögren Guest

    Re: Finding parent window?

    Jan,

    >I can get the Hwnd by enumerating the windows & comparing the title bars -
    >but this is not very satisfactory as all sorts of side effects can occur
    >(and there may be multiple instances of the app running).


    Instead of doing a full enumeration, you can enumerate only the
    windows in the current thread using EnumThreadWindows. That should
    reduce the chance of getting the wrong window.


    Matt

    ============================================
    Mattias Sjögren - mattiass @ hem.passagen.se
    CodeHound - Free VB Search Engine
    http://www.codehound.com

  3. #3
    Mark Bax Guest

    Re: Finding parent window?

    Jan: In VB, App.ThreadId

    Mark Bax

    "Jan Sears" <jan.sears@aspentech.com> wrote in message
    news:3a1418e6@news.devx.com...
    > I am not at all experienced with Threads, so this maybe a silly question,
    > but I take it then, that the several dll's sitting between the main App

    and
    > the Form hosting the GUI should all be in the same thread?
    >
    > How do I get the ThreadId? Would I have to do it from the C++ code or can

    I
    > get it from VB?
    >
    > thanks,
    >
    > Jan
    >
    >




  4. #4
    Mark Bax Guest

    Re: Finding parent window?

    Jan: In VB, App.ThreadId

    Mark Bax

    "Jan Sears" <jan.sears@aspentech.com> wrote in message
    news:3a1418e6@news.devx.com...
    > I am not at all experienced with Threads, so this maybe a silly question,
    > but I take it then, that the several dll's sitting between the main App

    and
    > the Form hosting the GUI should all be in the same thread?
    >
    > How do I get the ThreadId? Would I have to do it from the C++ code or can

    I
    > get it from VB?
    >
    > thanks,
    >
    > Jan
    >
    >




  5. #5
    Jan Sears Guest

    Finding parent window?

    Hi all,
    I have an OCX control, which is launched on a form contained in a VB
    dll, which in turn is loaded & called from a C++ dll, which in turn has been
    called by a WinGUI fronting a fortran engine. (phew! complicated or what?)

    My problem is that I have to make the form hosting the OCX appear to be a
    child window of the parent apps GUI - it has a limited API, but that doesn't
    include passing it's Hwnd.

    I can get the Hwnd by enumerating the windows & comparing the title bars -
    but this is not very satisfactory as all sorts of side effects can occur
    (and there may be multiple instances of the app running).

    Can anybody think of another way? (Without having to change the parent Apps
    code)

    Thanks in advance for any ideas...

    Jan



  6. #6
    Jan Sears Guest

    Re: Finding parent window?

    I am not at all experienced with Threads, so this maybe a silly question,
    but I take it then, that the several dll's sitting between the main App and
    the Form hosting the GUI should all be in the same thread?

    How do I get the ThreadId? Would I have to do it from the C++ code or can I
    get it from VB?

    thanks,

    Jan



  7. #7
    Jan Sears Guest

    Re: Finding parent window?

    I am not at all experienced with Threads, so this maybe a silly question,
    but I take it then, that the several dll's sitting between the main App and
    the Form hosting the GUI should all be in the same thread?

    How do I get the ThreadId? Would I have to do it from the C++ code or can I
    get it from VB?

    thanks,

    Jan



  8. #8
    Jan Sears Guest

    Re: Finding parent window?

    And is it possible from C++ / C ?

    "Mark Bax" <MarkB@BlaiseSoft.com> wrote in message
    news:3a143c40@news.devx.com...
    > Jan: In VB, App.ThreadId
    >
    > Mark Bax
    >
    > "Jan Sears" <jan.sears@aspentech.com> wrote in message
    > news:3a1418e6@news.devx.com...
    > > I am not at all experienced with Threads, so this maybe a silly

    question,
    > > but I take it then, that the several dll's sitting between the main App

    > and
    > > the Form hosting the GUI should all be in the same thread?
    > >
    > > How do I get the ThreadId? Would I have to do it from the C++ code or

    can
    > I
    > > get it from VB?
    > >
    > > thanks,
    > >
    > > Jan
    > >
    > >

    >
    >




  9. #9
    Jan Sears Guest

    Re: Finding parent window?

    And is it possible from C++ / C ?

    "Mark Bax" <MarkB@BlaiseSoft.com> wrote in message
    news:3a143c40@news.devx.com...
    > Jan: In VB, App.ThreadId
    >
    > Mark Bax
    >
    > "Jan Sears" <jan.sears@aspentech.com> wrote in message
    > news:3a1418e6@news.devx.com...
    > > I am not at all experienced with Threads, so this maybe a silly

    question,
    > > but I take it then, that the several dll's sitting between the main App

    > and
    > > the Form hosting the GUI should all be in the same thread?
    > >
    > > How do I get the ThreadId? Would I have to do it from the C++ code or

    can
    > I
    > > get it from VB?
    > >
    > > thanks,
    > >
    > > Jan
    > >
    > >

    >
    >




  10. #10
    Jan Sears Guest

    Re: Finding parent window?

    Unfortunately it seems the in-process VB DLL runs in a new thread - so I get
    it's own windows & the windows spawned by itself, but not those of the
    application which called the DLL... grrrr

    Any other ideas anyone?




  11. #11
    Jan Sears Guest

    Re: Finding parent window?

    Unfortunately it seems the in-process VB DLL runs in a new thread - so I get
    it's own windows & the windows spawned by itself, but not those of the
    application which called the DLL... grrrr

    Any other ideas anyone?




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center