Finding MDI Child windows
Moderators: Dorian (MJT support), JRL
Finding MDI Child windows
I want to make a toolbar to activate my current windows in my CAD application rather than going to the window menu and choosing them from a list. My first problem is I do not know how to get a list of child windows present. ?
I wrote this back while v12 was in beta as a proof of concept. Basically it uses Window's "GetWindow" API function to move through the child windows and build a list. This sample is built to look specifically at the windows XP "Display Properties" window. If you open "Display Properties" then open "View System Windows" and expand the child window list to see the window handles and names. You should be able to then run this script and see that list show up one child window at a time in the message box or listed in the file %temp_dir%childwindowlist.txt.
Hope this is helpful.
Hope this is helpful.
Code: Select all
/*
GetWindow params
#define GW_HWNDFIRST 0
#define GW_HWNDLAST 1
#define GW_HWNDNEXT 2
#define GW_HWNDPREV 3
#define GW_OWNER 4
#define GW_CHILD 5
*/
//Run>desk.cpl
Let>kk=1
LibFunc>user32,GetDesktopWindow,hwnd
LibFunc>user32,GetWindow,GWres,hwnd,5
GetWindowNames>GWres,title,class
Writeln>%temp_dir%childwindowlist.txt,wres,Handle=%GWres%%TAB%Name=%title%%TAB%Class=%class%
Let>Window_%kk%=%GWres%
Repeat>GWres
Add>kk,1
LibFunc>user32,GetWindow,GWres,%GWres%,2
Let>Window_%kk%=%GWres%
GetWindowNames>GWres,title,class
Let>WinName=Window_Name_%kk%
MDL>Handle=%GWres%%CRLF%Name=%title%%CRLF%Class=%class%
Writeln>%temp_dir%childwindowlist.txt,wres,Handle=%GWres%%TAB%Name=%title%%TAB%Class=%class%
Until>GWres=0
Let>kkk=1
Let>GWress=Window_1
LibFunc>user32,GetWindow,GWress,GWress,5
GetWindowNames>GWress,title,class
Writeln>%temp_dir%childwindowlist.txt,wres,Handle=%GWress%%TAB%Name=%title%%TAB%Class=%class%
Let>Window_%kkk%=%GWress%
Repeat>GWress
Add>kkk,1
LibFunc>user32,GetWindow,GWress,%GWress%,2
Let>Window_%kkk%=%GWress%
GetWindowNames>GWress,title,class
Let>WinName=Window_Name_%kkk%
MDL>Handle=%GWress%%CRLF%Name=%title%%CRLF%Class=%class%
Writeln>%temp_dir%childwindowlist.txt,wres,Handle=%GWress%%TAB%Name=%title%%TAB%Class=%class%
Until>GWress=0