How to Enumerate non child windows? (1998-2005) & forum.sqlwindows (2000-2005)
Posts: 23
Joined: 22 Feb 2019, 18:42
Location: Siblingen

How to Enumerate non child windows?

Post by JMASEK » 21 Dec 2004, 17:50

 Posted by:  Jiri Masek 

Hi Gupta users,

I need to close all open Top level windows owned by the MDI window when the
MDI is closed.
So I use the On SAM_Close Message of the MDI window and will send SAM_Close
messages to all open window, that were created with
SalCreateWindow(frmXyz, hWndMDI).

As those windows are not defined below the MDI window but as top level
windows, the SalSendMsgToChildren(..) does not work.
Also SalGetFirstChild & SalGetNextChild does not return the correct handles.

Is there a way to get all those toplevel Windows enumerated.

(SalFindWindow (hWndMDI, 'frmXYZ') works, but I need to give the explicit
name of the window and there are lot of different names in our project)

Any idea ??



Ernesto de Miguel

Re: How to Enumerate non child windows?

Post by Ernesto de Miguel » 04 Jan 2005, 08:59

 Posted by:  Ernesto de Miguel 

Hi Jiri,

I would recommend to have an array of Window Handles for the windows so
opened. Something like:

MDI window
Window Variables
Window Handle: ahWndTopLevelWindows[*]
Number: nTopLevelWindows
Create a window this way:

Set hWndWindow = SalCreateWindow( frmXyz, hWndMDI )
If hWndWindow != hWndNULL
ahWndTopLevelWindows[nTopLevelWindows] = hWndWindow
nTopLevelWindows = nTopLevelWindows + 1

Now you know the exact handles of the windows created. Of course, you have
to take the window handle out of the array whenever you close one such
window, but if the execution is in the normal way this array should behave
as a FIFO stack in which the element to delete is the last one.

If this is not the case, you will have to implement a function to search the
window handle in the array and reorganize the array in order to eliminate
this window handle.


Jim McNamara

Re: How to Enumerate non child windows?

Post by Jim McNamara » 04 Jan 2005, 16:16

 Posted by:  Jim McNamara 

Or use a hard coded array index value for each window that is opened in the
MDI. I use this method to keep a user from opening multiple instances of
the same form. Only issue is that anything unnecessarily hard coded is not
necessarily politically correct programming technique. :-)

Return to “forum.sqlwindows”

Who is online

Users browsing this forum: [Ccbot] and 0 guests