Detecting when in function wizard in Excel xll

169 Views Asked by At

I have some old C code which I have used in the past to detect when an xll function is in the excel function wizard. this is to stop the function from executing until all the parameters have been supplied. this code relied on detecting that window class "bosa_sdm_xl" is the current window. I have recently ported this to Office 365 and this doesn't seem to be the case anymore. the class name that I keep seeing are "OfficeGripperWnd" and "IME". Anyone know how I can use these classnames to detect the function wizard ? this the code fwiw

static BOOL CALLBACK EnumProc(HWND hwnd, EnumStruct* enm)
{
    // Check if the parent window is Excel.
    // Note: Because of the change from MDI (Excel 2010)
    // to SDI (Excel 2013), comment out this step in Excel 2013.
    if ((DWORD)GetParent(hwnd) == enm->hwndXLMain)
    {
        const int CLASS_NAME_BUFFSIZE = 512;
        WCHAR class_name[CLASS_NAME_BUFFSIZE + 1];
        //  Ensure that class_name is always null terminated for safety.
        class_name[CLASS_NAME_BUFFSIZE] = 0;
        GetClassNameW(hwnd, class_name, CLASS_NAME_BUFFSIZE);
        //  Do a case-insensitve comparison for the Excel dialog window
        //  class name with the Excel version number truncated.
        if (_wcsnicmp(class_name, L"bosa_sdm_xl", 11) == 0)
        {
            enm->funcwiz = true;
            return FALSE; // Tells Windows to stop iterating.
        }
    }
    return TRUE; // Tells Windows to continue iterating.
}
0

There are 0 best solutions below