Hierarchy of windows

Post Reply
Natter
Posts: 1244
Joined: Mon May 14, 2007 9:49 am

Hierarchy of windows

Post by Natter »

Hi,

My application window is in the foreground. How can I get a window handle located under my window ?
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Hierarchy of windows

Post by nageswaragunupudi »

Code: Select all | Expand

function Main()

   local oWnd

   DEFINE WINDOW oWnd FROM 100,100 TO 400,400 PIXEL TITLE "First Window"
   @ 20,20 BUTTON "New Window" SIZE 200,50 PIXEL OF oWnd ;
      ACTION ( CreateNextWindow( oWnd ), oWnd:GoTop() )

   ACTIVATE WINDOW oWnd

return nil

function CreateNextWindow( oMain )

   local oWnd

   DEFINE WINDOW oWnd FROM 200,200 TO 500,500 PIXEL OF oMain
   ACTIVATE WINDOW oWnd

return nil



 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Hierarchy of windows

Post by nageswaragunupudi »

Also you can use the function

Code: Select all | Expand

BringWindowToTop( hWnd )
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 1244
Joined: Mon May 14, 2007 9:49 am

Re: Hierarchy of windows

Post by Natter »

Rao, thank you for your reply. But I didn 't understand how it would help me ? There is a window of someone else's application under my window and I need to get a window handle of this someone else's application. In this case, using the FindWindow() function is not possible
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Hierarchy of windows

Post by Jimmy »

hi,

under HMG we have this Function
https://docs.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-getnextwindow?redirectedfrom=MSDN

Code: Select all | Expand

HB_FUNC (GETNEXTWINDOW)
{
   HWND hWnd     = (HWND) HMG_parnl (1);
   HWND hWndNext = GetWindow (hWnd, GW_HWNDNEXT);
   HMG_retnl ((LONG_PTR) hWndNext );
}

GW_HWNDNEXT 2 Returns a handle to the window below the given window.
GW_HWNDPREV 3 Returns a handle to the window above the given window.
greeting,
Jimmy
Natter
Posts: 1244
Joined: Mon May 14, 2007 9:49 am

Re: Hierarchy of windows

Post by Natter »

Yes, I understand. Rao, Jimmy thank you !
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Hierarchy of windows

Post by nageswaragunupudi »

But I didn 't understand how it would help me ?

Sorry. Your question was different and my answer was different.

While adopting Mr. Jimmy's advice, you need not write all the 'C' code.

You can use the FWH function GetWindow() directly in your program with the same syntax.

Code: Select all | Expand


GetWindow( hWnd, 2 or 3 )
 
Regards

G. N. Rao.
Hyderabad, India
Post Reply