Пока не нашёл ничего лучшего, как перебрать все окна текущего Workspace'а. Первым попавшимся проектным окном и будет верхнее в Z-последовательности окно.
X++:
HWND hWndParent = WinAPI::findWindowEx(infolog.hWnd(), 0, 'MDIClient', '');
HWND hWnd;
str caption;
str projName;
;
// активные/открытые проекты
for (hWnd = WinAPI::findWindowEx(hWndParent, 0, 'AxMDIChildWindow', '');
hWnd;
hWnd = WinAPI::findWindowEx(hWndParent, hWnd, 'AxMDIChildWindow', ''))
{
caption = WinAPI::getWindowText(hWnd);
if (strStartsWith(caption, "@SYS4534"))
{
projName = strDel(caption, 1, strLen("@SYS4534") + 1);
//WinAPI::flashWindowEx(hWnd, 1, 5, 200);
break;
}
}
Для своих целей я не ограничиваюсь первым найденным проектом, а ищу их все, заполняю в ComboBox, делаю верхний проект выбранным в ComboBox'е, а затем предлагаю юзеру самому выбрать проект:
X++:
for (hWnd = WinAPI::findWindowEx(hWndParent, 0, 'AxMDIChildWindow', '');
hWnd;
hWnd = WinAPI::findWindowEx(hWndParent, hWnd, 'AxMDIChildWindow', ''))
{
caption = WinAPI::getWindowText(hWnd);
if (strStartsWith(caption, "@SYS4534"))
Projects.add(strDel(caption, 1, strLen("@SYS4534") + 1));
}
Projects.selection(0);