Exemplo n.º 1
0
int DisplayDialog ( WStringAutoPtr title, WStringAutoPtr message, WStringAutoPtr button1, WStringAutoPtr button2, WStringAutoPtr button3 )
{
    // set the names to be used for each button
    g_button1_name.swap ( *button1 );
    g_button2_name.swap ( *button2 );
    g_button3_name.swap ( *button3 );

    // the type of dialog displayed varies depends on the nunmber of buttons required
    UINT type = MB_OK;

    if ( g_button2_name != L"" ) {
        type = MB_OKCANCEL;
        if ( g_button3_name != L"" ) {
            type = MB_YESNOCANCEL;
        }
    }

    // set the callback so that the custom button names are installed
    g_window_hook = SetWindowsHookEx ( WH_CBT, &DialogCallback, 0, GetCurrentThreadId() );

    /*
     get the user's choice and translate that into a response that matches the equivalent
     choice on OS X
     */

    int button_clicked = MessageBox ( GetForegroundWindow(), message->c_str(), title->c_str(), type );

    unsigned long response = 0;

    switch ( button_clicked ) {

    case IDOK:
    case IDYES:
        response = kBE_OKButton;
        break;
    case IDCANCEL:
        response = kBE_CancelButton;
        break;
    case IDNO:
        response = kBE_AlternateButton;
        break;
    }

    return response;

} // DisplayDialog
Exemplo n.º 2
0
void ConfigHelper::ExpandDotDotDot(wstring& featPath, const wstring& scpPath, wstring& scpDirCached)
{
    wstring delim = L"/\\";

    if (scpDirCached.empty())
    {
        scpDirCached = scpPath;
        wstring tail;
        auto pos = scpDirCached.find_last_of(delim);
        if (pos != wstring::npos)
        {
            tail = scpDirCached.substr(pos + 1);
            scpDirCached.resize(pos);
        }
        if (tail.empty()) // nothing was split off: no dir given, 'dir' contains the filename
            scpDirCached.swap(tail);
    }
    size_t pos = featPath.find(L"...");
    if (pos != featPath.npos)
        featPath = featPath.substr(0, pos) + scpDirCached + featPath.substr(pos + 3);
}