int BBMessageBox(int flg, const char *fmt, ...) { const char *caption = BBAPPNAME; const char *message; char *p, *q; int r; va_list args; static int (WINAPI *pMessageBoxIndirectW)(CONST MSGBOXPARAMSW*); va_start(args, fmt); message = p = m_formatv(fmt, args); if ('#' == p[0] && NULL != (q = strchr(p+1, p[0]))) // "#Title#Message" is wanted *q = 0, caption = p+1, message = q+1; #ifdef BBTINY r = MessageBox (NULL, message, caption, flg | MB_SYSTEMMODAL); #else MessageBeep(0); if (usingNT && load_imp(&pMessageBoxIndirectW, "user32.dll", "MessageBoxIndirectW")) { MSGBOXPARAMSW mp; int lc = 1+strlen(caption); int lm = 1+strlen(message); WCHAR *wcaption = (WCHAR*)m_alloc(lc * sizeof (WCHAR)); WCHAR *wmessage = (WCHAR*)m_alloc(lm * sizeof (WCHAR)); bbMB2WC(caption, wcaption, lc); bbMB2WC(message, wmessage, lm); memset(&mp, 0, sizeof mp); mp.cbSize = sizeof mp; mp.hInstance = hMainInstance; //mp.hwndOwner = NULL; mp.lpszText = wmessage; mp.lpszCaption = wcaption; mp.dwStyle = flg | MB_USERICON | MB_SYSTEMMODAL; mp.lpszIcon = MAKEINTRESOURCEW(IDI_BLACKBOX); r = pMessageBoxIndirectW(&mp); m_free(wcaption); m_free(wmessage); } else { MSGBOXPARAMSA mp; memset(&mp, 0, sizeof mp); mp.cbSize = sizeof mp; mp.hInstance = hMainInstance; //mp.hwndOwner = NULL; mp.lpszText = message; mp.lpszCaption = caption; mp.dwStyle = flg | MB_USERICON | MB_SYSTEMMODAL; mp.lpszIcon = MAKEINTRESOURCE(IDI_BLACKBOX); r = MessageBoxIndirectA(&mp); } #endif m_free(p); return r; }
void Settings::ReadRCSettings () { // NOTE: make a 0.8.3 compatible RC file const char *default_commands[] = { "/prev", "/play", "/playpause", "/stop", "/next", "/command:\"Activate or hide\"", "/command:\"Volume up\"", "/command:\"Volume down\"", "/command:\"Open...\"" }; const char *default_altcommands[] = { "", "/rand", "", "", "", "", "", "", "/command:\"Add files...\"" }; TCHAR pluginDir[MAX_LINE_LENGTH]; int nLen; // First we extract the plugin directory... GetModuleFileName(hInstance, pluginDir, sizeof(pluginDir)); nLen = _tcslen(pluginDir)-1; while (nLen >0 && pluginDir[nLen] != '\\') nLen--; pluginDir[nLen + 1] = 0; // ...then we search for the bbfoomp.rc config file... // (-> $UserAppData$\Blackbox -> plugin directory -> Blackbox directory) _tcscpy(rcpath, ConfigFileExists("bbfoomp.rc", pluginDir)); if (!_tcslen(rcpath)) strcpy(rcpath, ConfigFileExists("bbfoomprc", pluginDir)); if (!_tcslen(rcpath)) { // If bbfoomp.rc could not be found we create a new // config file in the same folder as the plugin... _tcscpy(rcpath, pluginDir); _tcscat(rcpath, "bbfoomp.rc"); WriteDefaultRCSettings(); } //==================== // Read bbfoomp settings from config file... #if defined _WIN64 _tcscpy(FooPath, ReadString(rcpath, "bbfoomp.foobar.path:", "C:\\Program Files (x86)\\foobar2000\\foobar2000.exe")); #else _tcscpy(FooPath, ReadString(rcpath, "bbfoomp.foobar.path:", "C:\\Progra~1\\foobar2000\\foobar2000.exe")); #endif const char * def_text = ReadString(rcpath, "bbfoomp.DefaultText:", "Nothing is playing"); bbMB2WC(def_text, NoInfoText, MAX_LINE_LENGTH); FooWidth = ReadInt(rcpath, "bbfoomp.foowidth:" , 200); height = ReadInt(rcpath, "bbfoomp.height:", 20); FooMode = ReadInt(rcpath, "bbfoomp.displaytype:", 2); InnerStyleIndex = ReadInt(rcpath, "bbfoomp.InnerStyle:", 2); OuterStyleIndex = ReadInt(rcpath, "bbfoomp.OuterStyle:", 4); FooOnTop = ReadBool(rcpath, "bbfoomp.OnTop:", false); transparencyAlpha = ReadInt(rcpath, "bbfoomp.transparencyAlpha:", 220); BorderWidth = ReadInt(rcpath, "bbfoomp.borderwidth:", 3); FooTrans = ReadBool(rcpath, "bbfoomp.transparency:", false); FooAlign = ReadBool(rcpath, "bbfoomp.MegaLeftAlign:", true); FooShadowsEnabled = ReadBool(rcpath, "bbfoomp.Shadows:", false); FooScrollSpeed = ReadInt(rcpath, "bbfoomp.ScrollSpeed:", 5); for (int i = 0; i < e_last_button_item; ++i) { FoompButton &b = buttons[i]; char picname[100], cmdname[100], altcmdname[100]; sprintf(picname,"bbfoomp.button%d.image:",i+1); sprintf(cmdname,"bbfoomp.button%d.command:",i+1); sprintf(altcmdname,"bbfoomp.button%d.altcommand:",i+1); b.type = ButtonType(ReadInt(rcpath, picname, i)); _tcscpy(b.cmdarg, ReadString(rcpath, cmdname, default_commands[i])); _tcscpy(b.altcmdarg, ReadString(rcpath, altcmdname, default_altcommands[i])); } xpos = ReadInt(rcpath, "bbfoomp.xpos:", 10); if (xpos >= GetSystemMetrics(SM_CXSCREEN)) xpos = 0; ypos = ReadInt(rcpath, "bbfoomp.ypos:", 10); if (ypos >= GetSystemMetrics(SM_CYSCREEN)) ypos = 0; if (SlitExists) FooDockedToSlit = ReadBool(rcpath, "bbfoomp.dockedtoslit:", false); else FooDockedToSlit = false; // Minimum settings checks. if (height < (15 + BorderWidth) || width < 0 || BorderWidth < 0) { MessageBox(0, TEXT("The value you have inputted for either: \nheight, width or border-width is below the minimum.\nThe values will default. Please consult the Readme for the minimums."), "ERROR: Illegal value set.", MB_OK | MB_TOPMOST | MB_SETFOREGROUND); FooWidth = 200; height = 22; BorderWidth = 3; } }