Share via


Closing all windows in AX

void closeAllWindows()
{
     hwnd _hwnd, tempHwnd;
    #WinApi;

    While
    (WinApi::getWindow(WinAPI::getWindow(infolog.hWnd(),#GW_CHILD),#GW_CHILD))
    {
        _hwnd =
            WinAPI::getWindow(WinAPI::getWindow(infolog.hWnd(),#GW_CHILD),#GW_CHILD);
            WinAPI::sendMessageEx(_hwnd,#wm_sysCommand,#sc_close,0);

        if(_hwnd == tempHwnd)
            break;

        tempHwnd = _hwnd;
   }

}