diff options
-rw-r--r-- | src/modules/database/database.cpp | 3 | ||||
-rw-r--r-- | src/modules/database/dbini.cpp | 244 | ||||
-rw-r--r-- | src/modules/database/profilemanager.cpp | 282 |
3 files changed, 255 insertions, 274 deletions
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index ae2a0d8cd4..377ec31933 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -354,7 +354,6 @@ int tryOpenDatabase(const TCHAR *tszProfile) db_setCurrent(currDb = pDb);
return 0;
}
- delete pDb;
}
else {
switch (err) {
@@ -468,7 +467,7 @@ int LoadDatabaseModule(void) mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda was unable to open '%s', it's in an unknown format.\nThis profile might also be damaged, please run DbChecker which should be installed."), p ? ++p : szProfile);
MessageBox(0, buf, TranslateT("Miranda can't understand that profile"), MB_OK | MB_ICONERROR);
}
- else if ( !FindMirandaForProfile(szProfile)) {
+ else if (!FindMirandaForProfile(szProfile)) {
TCHAR buf[256];
TCHAR* p = _tcsrchr(szProfile, '\\');
mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda was unable to open '%s'\nIt's inaccessible or used by other application or Miranda instance"), p ? ++p : szProfile);
diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp index d10e98131d..672350084e 100644 --- a/src/modules/database/dbini.cpp +++ b/src/modules/database/dbini.cpp @@ -31,42 +31,43 @@ extern TCHAR mirandabootini[MAX_PATH]; static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SetDlgItemText(hwndDlg, IDC_ININAME, (TCHAR*)lParam);
+ switch (message) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetDlgItemText(hwndDlg, IDC_ININAME, (TCHAR*)lParam);
+ {
+ TCHAR szSecurity[11];
+ const TCHAR *pszSecurityInfo;
+
+ GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini);
+ if (!lstrcmpi(szSecurity, _T("all")))
+ pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before every change that is made.");
+ else if (!lstrcmpi(szSecurity, _T("onlyunsafe")))
+ pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before changes that are known to be unsafe.");
+ else if (!lstrcmpi(szSecurity, _T("none")))
+ pszSecurityInfo = LPGENT("Security systems to prevent malicious changes have been disabled. You will receive no further warnings.");
+ else pszSecurityInfo = NULL;
+ if (pszSecurityInfo) SetDlgItemText(hwndDlg, IDC_SECURITYINFO, TranslateTS(pszSecurityInfo));
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_VIEWINI:
{
- TCHAR szSecurity[11];
- const TCHAR *pszSecurityInfo;
-
- GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini);
- if ( !lstrcmpi(szSecurity, _T("all")))
- pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before every change that is made.");
- else if ( !lstrcmpi(szSecurity, _T("onlyunsafe")))
- pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before changes that are known to be unsafe.");
- else if ( !lstrcmpi(szSecurity, _T("none")))
- pszSecurityInfo = LPGENT("Security systems to prevent malicious changes have been disabled. You will receive no further warnings.");
- else pszSecurityInfo = NULL;
- if (pszSecurityInfo) SetDlgItemText(hwndDlg, IDC_SECURITYINFO, TranslateTS(pszSecurityInfo));
- }
- return TRUE;
-
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_VIEWINI:
- {
- TCHAR szPath[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_ININAME, szPath, SIZEOF(szPath));
- ShellExecute(hwndDlg, _T("open"), szPath, NULL, NULL, SW_SHOW);
- break;
- }
- case IDOK:
- case IDCANCEL:
- case IDC_NOTOALL:
- EndDialog(hwndDlg, LOWORD(wParam));
- break;
+ TCHAR szPath[MAX_PATH];
+ GetDlgItemText(hwndDlg, IDC_ININAME, szPath, SIZEOF(szPath));
+ ShellExecute(hwndDlg, _T("open"), szPath, NULL, NULL, SW_SHOW);
}
break;
+
+ case IDOK:
+ case IDCANCEL:
+ case IDC_NOTOALL:
+ EndDialog(hwndDlg, LOWORD(wParam));
+ break;
+ }
+ break;
}
return FALSE;
}
@@ -80,11 +81,12 @@ static bool IsInSpaceSeparatedList(const char *szWord, const char *szList) szEnd = strchr(szItem, ' ');
if (szEnd == NULL)
return !lstrcmpA(szItem, szWord);
- if (szEnd - szItem == wordLen) {
- if ( !strncmp(szItem, szWord, wordLen))
+
+ if (szEnd - szItem == wordLen)
+ if (!strncmp(szItem, szWord, wordLen))
return true;
- }
- szItem = szEnd+1;
+
+ szItem = szEnd + 1;
}
}
@@ -100,10 +102,10 @@ struct warnSettingChangeInfo_t { static INT_PTR CALLBACK WarnIniChangeDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- static struct warnSettingChangeInfo_t *warnInfo;
+ static warnSettingChangeInfo_t *warnInfo;
switch(message) {
- case WM_INITDIALOG:
+ case WM_INITDIALOG:
{
char szSettingName[256];
const TCHAR *pszSecurityInfo;
@@ -122,63 +124,62 @@ static INT_PTR CALLBACK WarnIniChangeDlgProc(HWND hwndDlg, UINT message, WPARAM else
pszSecurityInfo = LPGENT("This change is not known to be safe.");
SetDlgItemText(hwndDlg, IDC_SECURITYINFO, TranslateTS(pszSecurityInfo));
- return TRUE;
}
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDCANCEL:
- warnInfo->cancel = 1;
- case IDYES:
- case IDNO:
- warnInfo->warnNoMore = IsDlgButtonChecked(hwndDlg, IDC_WARNNOMORE);
- EndDialog(hwndDlg, LOWORD(wParam));
- break;
- }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ warnInfo->cancel = 1;
+ case IDYES:
+ case IDNO:
+ warnInfo->warnNoMore = IsDlgButtonChecked(hwndDlg, IDC_WARNNOMORE);
+ EndDialog(hwndDlg, LOWORD(wParam));
break;
+ }
+ break;
}
return FALSE;
}
static INT_PTR CALLBACK IniImportDoneDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SetDlgItemText(hwndDlg, IDC_ININAME, (TCHAR*)lParam);
- SetDlgItemText(hwndDlg, IDC_NEWNAME, (TCHAR*)lParam);
- return TRUE;
- case WM_COMMAND:
- {
- TCHAR szIniPath[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_ININAME, szIniPath, SIZEOF(szIniPath));
- switch(LOWORD(wParam)) {
- case IDC_DELETE:
- DeleteFile(szIniPath);
- case IDC_LEAVE:
- EndDialog(hwndDlg, LOWORD(wParam));
- break;
- case IDC_RECYCLE:
- {
- SHFILEOPSTRUCT shfo = {0};
- shfo.wFunc = FO_DELETE;
- shfo.pFrom = szIniPath;
- szIniPath[lstrlen(szIniPath)+1] = '\0';
- shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
- SHFileOperation(&shfo);
- }
- EndDialog(hwndDlg, LOWORD(wParam));
- break;
- case IDC_MOVE:
- {
- TCHAR szNewPath[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_NEWNAME, szNewPath, SIZEOF(szNewPath));
- MoveFile(szIniPath, szNewPath);
- }
- EndDialog(hwndDlg, LOWORD(wParam));
- break;
+ TCHAR szIniPath[MAX_PATH];
+
+ switch (message) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetDlgItemText(hwndDlg, IDC_ININAME, (TCHAR*)lParam);
+ SetDlgItemText(hwndDlg, IDC_NEWNAME, (TCHAR*)lParam);
+ return TRUE;
+
+ case WM_COMMAND:
+ GetDlgItemText(hwndDlg, IDC_ININAME, szIniPath, SIZEOF(szIniPath));
+ switch (LOWORD(wParam)) {
+ case IDC_DELETE:
+ DeleteFile(szIniPath);
+ case IDC_LEAVE:
+ EndDialog(hwndDlg, LOWORD(wParam));
+ break;
+ case IDC_RECYCLE:
+ {
+ SHFILEOPSTRUCT shfo = { 0 };
+ shfo.wFunc = FO_DELETE;
+ shfo.pFrom = szIniPath;
+ szIniPath[lstrlen(szIniPath) + 1] = '\0';
+ shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
+ SHFileOperation(&shfo);
}
+ EndDialog(hwndDlg, LOWORD(wParam));
+ break;
+ case IDC_MOVE:
+ TCHAR szNewPath[MAX_PATH];
+ GetDlgItemText(hwndDlg, IDC_NEWNAME, szNewPath, SIZEOF(szNewPath));
+ MoveFile(szIniPath, szNewPath);
+ EndDialog(hwndDlg, LOWORD(wParam));
break;
}
+ break;
}
return FALSE;
}
@@ -204,13 +205,13 @@ static void ConvertBackslashes(char *str, UINT fileCp) char *pstr;
for (pstr = str; *pstr; pstr = CharNextExA(fileCp, pstr, 0)) {
if (*pstr == '\\') {
- switch(pstr[1]) {
+ switch (pstr[1]) {
case 'n': *pstr = '\n'; break;
case 't': *pstr = '\t'; break;
case 'r': *pstr = '\r'; break;
default: *pstr = pstr[1]; break;
}
- memmove(pstr+1, pstr+2, strlen(pstr+2) + 1);
+ memmove(pstr + 1, pstr + 2, strlen(pstr + 2) + 1);
}
}
}
@@ -224,27 +225,27 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf bool warnThisSection = false;
char szSection[128]; szSection[0] = 0;
- while ( !feof(fp)) {
+ while (!feof(fp)) {
char szLine[2048];
if (fgets(szLine, sizeof(szLine), fp) == NULL)
break;
LBL_NewLine:
int lineLength = lstrlenA(szLine);
- while (lineLength && (BYTE)(szLine[lineLength-1]) <= ' ')
+ while (lineLength && (BYTE)(szLine[lineLength - 1]) <= ' ')
szLine[--lineLength] = '\0';
if (szLine[0] == ';' || szLine[0] <= ' ')
continue;
if (szLine[0] == '[') {
- char *szEnd = strchr(szLine+1, ']');
+ char *szEnd = strchr(szLine + 1, ']');
if (szEnd == NULL)
continue;
if (szLine[1] == '!')
szSection[0] = '\0';
else {
- lstrcpynA(szSection, szLine+1, min(sizeof(szSection), (int)(szEnd-szLine)));
+ lstrcpynA(szSection, szLine + 1, min(sizeof(szSection), (int)(szEnd - szLine)));
switch (secur) {
case 0:
warnThisSection = false;
@@ -312,7 +313,7 @@ LBL_NewLine: warnThisSection = 0;
}
- switch(szValue[0]) {
+ switch (szValue[0]) {
case 'b':
case 'B':
db_set_b(NULL, szSection, szName, (BYTE)strtol(szValue+1, NULL, 0));
@@ -339,28 +340,25 @@ LBL_NewLine: break;
case 'g':
case 'G':
- {
- char *pstr;
- for (pstr = szValue+1;*pstr;pstr++) {
- if (*pstr == '\\') {
- switch(pstr[1]) {
- case 'n': *pstr = '\n'; break;
- case 't': *pstr = '\t'; break;
- case 'r': *pstr = '\r'; break;
- default: *pstr = pstr[1]; break;
- }
- MoveMemory(pstr+1, pstr+2, lstrlenA(pstr+2)+1);
+ for (char *pstr = szValue + 1; *pstr; pstr++) {
+ if (*pstr == '\\') {
+ switch (pstr[1]) {
+ case 'n': *pstr = '\n'; break;
+ case 't': *pstr = '\t'; break;
+ case 'r': *pstr = '\r'; break;
+ default: *pstr = pstr[1]; break;
}
+ MoveMemory(pstr + 1, pstr + 2, lstrlenA(pstr + 2) + 1);
}
}
case 'u':
case 'U':
- db_set_utf(NULL, szSection, szName, szValue+1);
+ db_set_utf(NULL, szSection, szName, szValue + 1);
break;
case 'm':
case 'M':
{
- CMStringA memo(szValue+1);
+ CMStringA memo(szValue + 1);
memo.Append("\r\n");
while (fgets(szLine, sizeof(szLine), fp) != NULL) {
switch (szLine[0]) {
@@ -371,7 +369,7 @@ LBL_NewLine: goto LBL_NewLine;
}
- memo.Append(rtrim(szLine+1));
+ memo.Append(rtrim(szLine + 1));
memo.Append("\r\n");
}
db_set_utf(NULL, szSection, szName, memo);
@@ -385,8 +383,8 @@ LBL_NewLine: int len;
char *pszValue, *pszEnd;
- PBYTE buf = (PBYTE)mir_alloc(lstrlenA(szValue+1));
- for (len = 0, pszValue = szValue+1;;len++) {
+ PBYTE buf = (PBYTE)mir_alloc(lstrlenA(szValue + 1));
+ for (len = 0, pszValue = szValue + 1;; len++) {
buf[len] = (BYTE)strtol(pszValue, &pszEnd, 0x10);
if (pszValue == pszEnd)
break;
@@ -397,7 +395,7 @@ LBL_NewLine: }
break;
default:
- TCHAR buf[ 250 ];
+ TCHAR buf[250];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("Invalid setting type for '%s'. The first character of every value must be b, w, d, l, s, e, u, g, h or n."), _A2T(szName));
MessageBox(NULL, buf, TranslateT("Install database settings"), MB_ICONWARNING | MB_OK);
break;
@@ -414,26 +412,26 @@ static void DoAutoExec(void) int secur;
GetPrivateProfileString(_T("AutoExec"), _T("Use"), _T("prompt"), szUse, SIZEOF(szUse), mirandabootini);
- if ( !lstrcmpi(szUse, _T("no"))) return;
+ if (!lstrcmpi(szUse, _T("no"))) return;
GetPrivateProfileString(_T("AutoExec"), _T("Safe"), _T("CLC Icons CLUI CList SkinSounds PluginUpdater"), buf, SIZEOF(buf), mirandabootini);
szSafeSections = mir_t2a(buf);
GetPrivateProfileString(_T("AutoExec"), _T("Unsafe"), _T("AIM Facebook GG ICQ IRC JABBER MRA MSN SKYPE Tlen TWITTER XFire"), buf, SIZEOF(buf), mirandabootini);
szUnsafeSections = mir_t2a(buf);
GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini);
- if ( !lstrcmpi(szSecurity, _T("none"))) secur = 0;
- else if ( !lstrcmpi(szSecurity, _T("notsafe"))) secur = 1;
- else if ( !lstrcmpi(szSecurity, _T("onlyunsafe"))) secur = 2;
+ if (!lstrcmpi(szSecurity, _T("none"))) secur = 0;
+ else if (!lstrcmpi(szSecurity, _T("notsafe"))) secur = 1;
+ else if (!lstrcmpi(szSecurity, _T("onlyunsafe"))) secur = 2;
GetPrivateProfileString(_T("AutoExec"), _T("OverrideSecurityFilename"), _T(""), szOverrideSecurityFilename, SIZEOF(szOverrideSecurityFilename), mirandabootini);
GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, SIZEOF(szOnCreateFilename), mirandabootini);
GetPrivateProfileString(_T("AutoExec"), _T("Glob"), _T("autoexec_*.ini"), szFindPath, SIZEOF(szFindPath), mirandabootini);
if (g_bDbCreated && szOnCreateFilename[0]) {
- PathToAbsoluteT( VARST(szOnCreateFilename), szIniPath);
+ PathToAbsoluteT(VARST(szOnCreateFilename), szIniPath);
ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, 0, 1);
}
- PathToAbsoluteT( VARST(szFindPath), szFindPath);
+ PathToAbsoluteT(VARST(szFindPath), szFindPath);
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(szFindPath, &fd);
@@ -451,7 +449,7 @@ static void DoAutoExec(void) bool secFN = lstrcmpi(fd.cFileName, szOverrideSecurityFilename) == 0;
mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName);
- if ( !lstrcmpi(szUse, _T("prompt")) && !secFN) {
+ if (!lstrcmpi(szUse, _T("prompt")) && !secFN) {
int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath);
if (result == IDC_NOTOALL) break;
if (result == IDCANCEL) continue;
@@ -464,17 +462,17 @@ static void DoAutoExec(void) else {
TCHAR szOnCompletion[8];
GetPrivateProfileString(_T("AutoExec"), _T("OnCompletion"), _T("recycle"), szOnCompletion, SIZEOF(szOnCompletion), mirandabootini);
- if ( !lstrcmpi(szOnCompletion, _T("delete")))
+ if (!lstrcmpi(szOnCompletion, _T("delete")))
DeleteFile(szIniPath);
- else if ( !lstrcmpi(szOnCompletion, _T("recycle"))) {
- SHFILEOPSTRUCT shfo = {0};
+ else if (!lstrcmpi(szOnCompletion, _T("recycle"))) {
+ SHFILEOPSTRUCT shfo = { 0 };
shfo.wFunc = FO_DELETE;
shfo.pFrom = szIniPath;
- szIniPath[lstrlen(szIniPath)+1] = 0;
+ szIniPath[lstrlen(szIniPath) + 1] = 0;
shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
SHFileOperation(&shfo);
}
- else if ( !lstrcmpi(szOnCompletion, _T("rename"))) {
+ else if (!lstrcmpi(szOnCompletion, _T("rename"))) {
TCHAR szRenamePrefix[MAX_PATH];
TCHAR szNewPath[MAX_PATH];
GetPrivateProfileString(_T("AutoExec"), _T("RenamePrefix"), _T("done_"), szRenamePrefix, SIZEOF(szRenamePrefix), mirandabootini);
@@ -483,7 +481,7 @@ static void DoAutoExec(void) lstrcat(szNewPath, fd.cFileName);
MoveFile(szIniPath, szNewPath);
}
- else if ( !lstrcmpi(szOnCompletion, _T("ask")))
+ else if (!lstrcmpi(szOnCompletion, _T("ask")))
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INIIMPORTDONE), NULL, IniImportDoneDlgProc, (LPARAM)szIniPath);
}
}
@@ -519,7 +517,7 @@ int InitIni(void) void UninitIni(void)
{
- if ( !bModuleInitialized)
+ if (!bModuleInitialized)
return;
CallService(MS_SYSTEM_REMOVEWAIT, (WPARAM)hIniChangeNotification, 0);
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 356d16277b..561f2a5e15 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -171,11 +171,11 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA // what, no plugins?!
if (arDbPlugins.getCount() == 0) {
EnableWindow(hwndCombo, FALSE);
- EnableWindow( GetDlgItem(hwndDlg, IDC_PROFILENAME), FALSE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NODBDRIVERS), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), FALSE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_NODBDRIVERS), TRUE);
}
else {
- for (int i=0; i < arDbPlugins.getCount(); i++) {
+ for (int i = 0; i < arDbPlugins.getCount(); i++) {
DATABASELINK* p = arDbPlugins[i];
LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(p->szFullName));
SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)p);
@@ -197,7 +197,7 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA TCHAR *p = _tcsrchr(profile, '.');
TCHAR c = 0;
- if (p) { c = *p; *p = 0; }
+ if (p) { c = *p; *p = 0; }
SetDlgItemText(hwndDlg, IDC_PROFILENAME, profile);
if (c) *p = c;
@@ -208,12 +208,12 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA return TRUE;
case WM_FOCUSTEXTBOX:
- SetFocus( GetDlgItem(hwndDlg, IDC_PROFILENAME));
+ SetFocus(GetDlgItem(hwndDlg, IDC_PROFILENAME));
break;
case WM_INPUTCHANGED: // when input in the edit box changes
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- EnableWindow(dat->hwndOK, GetWindowTextLength( GetDlgItem(hwndDlg, IDC_PROFILENAME)) > 0);
+ EnableWindow(dat->hwndOK, GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PROFILENAME)) > 0);
break;
case WM_SHOWWINDOW:
@@ -225,24 +225,22 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA break;
case WM_NOTIFY:
- {
- NMHDR *hdr = (NMHDR*)lParam;
- if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) {
- TCHAR szName[MAX_PATH];
- LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0);
- if (curSel == CB_ERR) break; // should never happen
- GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF(szName));
- if (szName[0] == 0)
- break;
+ NMHDR *hdr = (NMHDR*)lParam;
+ if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) {
+ TCHAR szName[MAX_PATH];
+ LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0);
+ if (curSel == CB_ERR) break; // should never happen
+ GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF(szName));
+ if (szName[0] == 0)
+ break;
- // profile placed in "profile_name" subfolder
- mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName);
- dat->pd->newProfile = 1;
- dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0);
+ // profile placed in "profile_name" subfolder
+ mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName);
+ dat->pd->newProfile = 1;
+ dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0);
- if ( CreateProfile(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0)
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- }
+ if (CreateProfile(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0)
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
}
break;
}
@@ -272,11 +270,11 @@ BOOL EnumProfilesForList(TCHAR *fullpath, TCHAR *profile, LPARAM lParam) if (_tstat(fullpath, &statbuf) == 0) {
if (statbuf.st_size > 1000000) {
mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0);
- _tcscpy(sizeBuf+5, _T(" MB"));
+ _tcscpy(sizeBuf + 5, _T(" MB"));
}
else {
mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0);
- _tcscpy(sizeBuf+5, _T(" KB"));
+ _tcscpy(sizeBuf + 5, _T(" KB"));
}
bFileExists = TRUE;
bFileLocked = !fileExist(fullpath);
@@ -325,12 +323,12 @@ void CheckProfile(HWND hwndList, int iItem, DlgProfData *dat) return;
TCHAR profile[MAX_PATH], fullName[MAX_PATH];
- LVITEM item = {0};
+ LVITEM item = { 0 };
item.mask = LVIF_TEXT;
item.iItem = iItem;
item.pszText = profile;
item.cchTextMax = SIZEOF(profile);
- if ( !ListView_GetItem(hwndList, &item))
+ if (!ListView_GetItem(hwndList, &item))
return;
mir_sntprintf(fullName, SIZEOF(fullName), _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, profile, profile);
@@ -342,14 +340,14 @@ void DeleteProfile(HWND hwndList, int iItem, DlgProfData *dat) if (iItem < 0)
return;
- TCHAR profile[MAX_PATH], profilef[MAX_PATH*2];
+ TCHAR profile[MAX_PATH], profilef[MAX_PATH * 2];
- LVITEM item = {0};
+ LVITEM item = { 0 };
item.mask = LVIF_TEXT;
item.iItem = iItem;
item.pszText = profile;
item.cchTextMax = SIZEOF(profile);
- if ( !ListView_GetItem(hwndList, &item))
+ if (!ListView_GetItem(hwndList, &item))
return;
mir_sntprintf(profilef, SIZEOF(profilef), TranslateT("Are you sure you want to remove profile \"%s\"?"), profile);
@@ -359,7 +357,7 @@ void DeleteProfile(HWND hwndList, int iItem, DlgProfData *dat) mir_sntprintf(profilef, SIZEOF(profilef), _T("%s\\%s%c"), dat->pd->szProfileDir, profile, 0);
- SHFILEOPSTRUCT sf = {0};
+ SHFILEOPSTRUCT sf = { 0 };
sf.wFunc = FO_DELETE;
sf.pFrom = profilef;
sf.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_ALLOWUNDO;
@@ -377,7 +375,7 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, TranslateDialogDefault(hwndDlg);
EnsureCheckerLoaded(true);
{
- dat = (DlgProfData*) lParam;
+ dat = (DlgProfData*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
// set columns
@@ -403,7 +401,7 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, // LV will destroy the image list
SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE) | LVS_SORTASCENDING);
ListView_SetImageList(hwndList, hImgList, LVSIL_SMALL);
- ListView_SetExtendedListViewStyle(hwndList,
+ ListView_SetExtendedListViewStyle(hwndList,
ListView_GetExtendedListViewStyle(hwndList) | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
// find all the profiles
@@ -411,9 +409,8 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, findProfiles(dat->pd->szProfileDir, EnumProfilesForList, (LPARAM)&ped);
PostMessage(hwndDlg, WM_FOCUSTEXTBOX, 0, 0);
- dat->hFileNotify = FindFirstChangeNotification(dat->pd->szProfileDir, TRUE,
- FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE);
- if (dat->hFileNotify != INVALID_HANDLE_VALUE)
+ dat->hFileNotify = FindFirstChangeNotification(dat->pd->szProfileDir, TRUE, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE);
+ if (dat->hFileNotify != INVALID_HANDLE_VALUE)
SetTimer(hwndDlg, 0, 1200, NULL);
return TRUE;
}
@@ -448,15 +445,15 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_CONTEXTMENU:
{
- LVHITTESTINFO lvht = {0};
- lvht.pt.x = GET_X_LPARAM(lParam);
- lvht.pt.y = GET_Y_LPARAM(lParam);
+ LVHITTESTINFO lvht = { 0 };
+ lvht.pt.x = GET_X_LPARAM(lParam);
+ lvht.pt.y = GET_Y_LPARAM(lParam);
ScreenToClient(hwndList, &lvht.pt);
if (ListView_HitTest(hwndList, &lvht) < 0)
break;
- lvht.pt.x = GET_X_LPARAM(lParam);
- lvht.pt.y = GET_Y_LPARAM(lParam);
+ lvht.pt.x = GET_X_LPARAM(lParam);
+ lvht.pt.y = GET_Y_LPARAM(lParam);
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1, TranslateT("Run"));
@@ -481,69 +478,61 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, break;
}
DestroyMenu(hMenu);
- break;
}
+ break;
case WM_NOTIFY:
- {
- LPNMHDR hdr = (LPNMHDR) lParam;
- if (hdr && hdr->code == PSN_INFOCHANGED)
- break;
+ LPNMHDR hdr = (LPNMHDR)lParam;
+ if (hdr && hdr->code == PSN_INFOCHANGED)
+ break;
- if (hdr && hdr->idFrom == IDC_PROFILELIST) {
- switch (hdr->code) {
- case LVN_ITEMCHANGED:
- EnableWindow(dat->hwndOK, ListView_GetSelectedCount(hwndList) == 1);
-
- case NM_DBLCLK:
- if (dat != NULL) {
- TCHAR profile[MAX_PATH];
- LVITEM item = {0};
- item.mask = LVIF_TEXT;
- item.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL);
- item.pszText = profile;
- item.cchTextMax = SIZEOF(profile);
-
- if (ListView_GetItem(hwndList, &item)) {
- // profile is placed in "profile_name" subfolder
- TCHAR tmpPath[MAX_PATH];
- mir_sntprintf(tmpPath, SIZEOF(tmpPath), _T("%s\\%s.dat"), dat->pd->szProfileDir, profile);
- HANDLE hFile = CreateFile(tmpPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, profile, profile);
- else
- _tcscpy(dat->pd->szProfile, tmpPath);
- CloseHandle(hFile);
- if (hdr->code == NM_DBLCLK) EndDialog(GetParent(hwndDlg), 1);
- }
- }
- return TRUE;
-
- case LVN_KEYDOWN:
- {
- LPNMLVKEYDOWN hdrk = (LPNMLVKEYDOWN) lParam;
- if (hdrk->wVKey == VK_DELETE)
- DeleteProfile(hwndList, ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL), dat);
- break;
+ if (hdr && hdr->idFrom == IDC_PROFILELIST) {
+ switch (hdr->code) {
+ case LVN_ITEMCHANGED:
+ EnableWindow(dat->hwndOK, ListView_GetSelectedCount(hwndList) == 1);
+
+ case NM_DBLCLK:
+ if (dat != NULL) {
+ TCHAR profile[MAX_PATH];
+ LVITEM item = { 0 };
+ item.mask = LVIF_TEXT;
+ item.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL);
+ item.pszText = profile;
+ item.cchTextMax = SIZEOF(profile);
+
+ if (ListView_GetItem(hwndList, &item)) {
+ // profile is placed in "profile_name" subfolder
+ TCHAR tmpPath[MAX_PATH];
+ mir_sntprintf(tmpPath, SIZEOF(tmpPath), _T("%s\\%s.dat"), dat->pd->szProfileDir, profile);
+ HANDLE hFile = CreateFile(tmpPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, profile, profile);
+ else
+ _tcscpy(dat->pd->szProfile, tmpPath);
+ CloseHandle(hFile);
+ if (hdr->code == NM_DBLCLK) EndDialog(GetParent(hwndDlg), 1);
}
- case LVN_GETINFOTIP:
- {
- NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
- if (pInfoTip != NULL)
- {
- TCHAR profilename[MAX_PATH], fullpath[MAX_PATH];
- struct _stat statbuf;
- ListView_GetItemText(hwndList, pInfoTip->iItem, 0, profilename, MAX_PATH);
- mir_sntprintf(fullpath, SIZEOF(fullpath), _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, profilename, profilename);
- _tstat(fullpath, &statbuf);
- mir_sntprintf(pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s\n%s: %s\n%s: %s"), fullpath, TranslateT("Created"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_ctime))), TranslateT("Modified"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_mtime))));
- }
- }
- break;
+ }
+ return TRUE;
+
+ case LVN_KEYDOWN:
+ if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
+ DeleteProfile(hwndList, ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL), dat);
+ break;
+
+ case LVN_GETINFOTIP:
+ NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
+ if (pInfoTip != NULL) {
+ TCHAR profilename[MAX_PATH], fullpath[MAX_PATH];
+ struct _stat statbuf;
+ ListView_GetItemText(hwndList, pInfoTip->iItem, 0, profilename, MAX_PATH);
+ mir_sntprintf(fullpath, SIZEOF(fullpath), _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, profilename, profilename);
+ _tstat(fullpath, &statbuf);
+ mir_sntprintf(pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s\n%s: %s\n%s: %s"), fullpath, TranslateT("Created"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_ctime))), TranslateT("Modified"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_mtime))));
}
}
- break;
}
+ break;
}
return FALSE;
@@ -579,7 +568,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, TCITEM tci;
tci.mask = TCIF_TEXT;
- for (int i=0; i < dat->pageCount; i++) {
+ for (int i = 0; i < dat->pageCount; i++) {
dat->opd[i].pTemplate = (DLGTEMPLATE *)LockResource(LoadResource(odp[i].hInstance, FindResourceA(odp[i].hInstance, odp[i].pszTemplate, MAKEINTRESOURCEA(5))));
dat->opd[i].dlgProc = odp[i].pfnDlgProc;
dat->opd[i].hInst = odp[i].hInstance;
@@ -588,17 +577,17 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, tci.pszText = (TCHAR*)odp[i].ptszTitle;
if (dat->prof->pd->noProfiles || shouldAutoCreate(dat->prof->pd->szProfile))
dat->currentPage = 1;
- TabCtrl_InsertItem( GetDlgItem(hwndDlg, IDC_TABS), i, &tci);
+ TabCtrl_InsertItem(GetDlgItem(hwndDlg, IDC_TABS), i, &tci);
}
- GetWindowRect( GetDlgItem(hwndDlg, IDC_TABS), &dat->rcDisplay);
- TabCtrl_AdjustRect( GetDlgItem(hwndDlg, IDC_TABS), FALSE, &dat->rcDisplay);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_TABS), &dat->rcDisplay);
+ TabCtrl_AdjustRect(GetDlgItem(hwndDlg, IDC_TABS), FALSE, &dat->rcDisplay);
- POINT pt = {0, 0};
+ POINT pt = { 0, 0 };
ClientToScreen(hwndDlg, &pt);
OffsetRect(&dat->rcDisplay, -pt.x, -pt.y);
- TabCtrl_SetCurSel( GetDlgItem(hwndDlg, IDC_TABS), dat->currentPage);
+ TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TABS), dat->currentPage);
dat->opd[dat->currentPage].hwnd = CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst, dat->opd[dat->currentPage].pTemplate, hwndDlg, dat->opd[dat->currentPage].dlgProc, (LPARAM)dat->prof);
ThemeDialogBackground(dat->opd[dat->currentPage].hwnd);
SetWindowPos(dat->opd[dat->currentPage].hwnd, HWND_TOP, dat->rcDisplay.left, dat->rcDisplay.top, 0, 0, SWP_NOSIZE);
@@ -612,15 +601,15 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, // service mode combobox
if (servicePlugins.getCount() == 0) {
- ShowWindow( GetDlgItem(hwndDlg, IDC_SM_LABEL), FALSE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_SM_COMBO), FALSE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SM_LABEL), FALSE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SM_COMBO), FALSE);
}
else {
HWND hwndCombo = GetDlgItem(hwndDlg, IDC_SM_COMBO);
LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)_T(""));
SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)-1);
SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
- for (int i=0; i < servicePlugins.getCount(); i++) {
+ for (int i = 0; i < servicePlugins.getCount(); i++) {
pluginEntry* p = servicePlugins[i];
index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(p->pluginname));
SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)i);
@@ -648,7 +637,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, pshn.hdr.code = PSN_INFOCHANGED;
pshn.hdr.idFrom = 0;
pshn.lParam = 0;
- for (int i=0; i < dat->pageCount; i++) {
+ for (int i = 0; i < dat->pageCount; i++) {
pshn.hdr.hwndFrom = dat->opd[i].hwnd;
if (dat->opd[i].hwnd != NULL)
SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
@@ -657,14 +646,12 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, break;
case WM_NOTIFY:
- switch(wParam) {
+ switch (wParam) {
case IDC_TABS:
- switch(((LPNMHDR)lParam)->code) {
+ switch (((LPNMHDR)lParam)->code) {
case TCN_SELCHANGING:
- {
+ if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) {
PSHNOTIFY pshn;
- if (dat->currentPage == -1 || dat->opd[dat->currentPage].hwnd == NULL)
- break;
pshn.hdr.code = PSN_KILLACTIVE;
pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd;
pshn.hdr.idFrom = 0;
@@ -678,9 +665,9 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, case TCN_SELCHANGE:
if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL)
- ShowWindow(dat->opd[ dat->currentPage ].hwnd, SW_HIDE);
+ ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE);
- dat->currentPage = TabCtrl_GetCurSel( GetDlgItem(hwndDlg, IDC_TABS));
+ dat->currentPage = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TABS));
if (dat->currentPage != -1) {
if (dat->opd[dat->currentPage].hwnd == NULL) {
PSHNOTIFY pshn;
@@ -702,14 +689,14 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
{
PSHNOTIFY pshn;
pshn.hdr.idFrom = 0;
pshn.lParam = 0;
pshn.hdr.code = PSN_RESET;
- for (int i=0; i < dat->pageCount; i++) {
+ for (int i = 0; i < dat->pageCount; i++) {
if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed)
continue;
@@ -721,43 +708,40 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, break;
case IDC_REMOVE:
- if ( !dat->prof->pd->noProfiles) {
+ if (!dat->prof->pd->noProfiles) {
HWND hwndList = GetDlgItem(dat->opd[0].hwnd, IDC_PROFILELIST);
DeleteProfile(hwndList, ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL), dat->prof);
}
break;
case IDOK:
- {
- PSHNOTIFY pshn;
- pshn.hdr.idFrom = 0;
- pshn.lParam = 0;
- if (dat->currentPage != -1) {
- pshn.hdr.code = PSN_KILLACTIVE;
- pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd;
- if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn))
- break;
- }
+ PSHNOTIFY pshn;
+ pshn.hdr.idFrom = 0;
+ pshn.lParam = 0;
+ if (dat->currentPage != -1) {
+ pshn.hdr.code = PSN_KILLACTIVE;
+ pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd;
+ if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn))
+ break;
+ }
- pshn.hdr.code = PSN_APPLY;
- for (int i=0; i < dat->pageCount; i++) {
- if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed)
- continue;
+ pshn.hdr.code = PSN_APPLY;
+ for (int i = 0; i < dat->pageCount; i++) {
+ if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed)
+ continue;
- pshn.hdr.hwndFrom = dat->opd[i].hwnd;
- SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
- if (GetWindowLongPtr(dat->opd[i].hwnd, DWLP_MSGRESULT) == PSNRET_INVALID_NOCHANGEPAGE) {
- TabCtrl_SetCurSel( GetDlgItem(hwndDlg, IDC_TABS), i);
- if (dat->currentPage != -1)
- ShowWindow(dat->opd[ dat->currentPage ].hwnd, SW_HIDE);
- dat->currentPage = i;
- ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW);
- return 0;
- }
+ pshn.hdr.hwndFrom = dat->opd[i].hwnd;
+ SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
+ if (GetWindowLongPtr(dat->opd[i].hwnd, DWLP_MSGRESULT) == PSNRET_INVALID_NOCHANGEPAGE) {
+ TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TABS), i);
+ if (dat->currentPage != -1)
+ ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE);
+ dat->currentPage = i;
+ ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW);
+ return 0;
}
- EndDialog(hwndDlg, 1);
- break;
}
+ EndDialog(hwndDlg, 1);
}
break;
@@ -772,11 +756,11 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
DeleteObject(dat->hBoldFont);
- {
- for (int i=0; i < dat->pageCount; i++)
- if (dat->opd[i].hwnd != NULL)
- DestroyWindow(dat->opd[i].hwnd);
- }
+
+ for (int i = 0; i < dat->pageCount; i++)
+ if (dat->opd[i].hwnd != NULL)
+ DestroyWindow(dat->opd[i].hwnd);
+
mir_free(dat->opd);
mir_free(dat);
break;
@@ -789,7 +773,7 @@ static int AddProfileManagerPage(struct DetailsPageInit *opi, OPTIONSDIALOGPAGE if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE))
return 1;
- opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1));
+ opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount + 1));
OPTIONSDIALOGPAGE* p = opi->odp + opi->pageCount++;
p->cbSize = sizeof(OPTIONSDIALOGPAGE);
@@ -826,7 +810,7 @@ int getProfileManager(PROFILEMANAGERDATA * pd) PROPSHEETHEADER psh = { 0 };
psh.dwSize = sizeof(psh);
- psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW;
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.nPages = opi.pageCount;
psh.ppsp = (PROPSHEETPAGE*)opi.odp;
@@ -835,7 +819,7 @@ int getProfileManager(PROFILEMANAGERDATA * pd) prof.psh = &psh;
int rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PROFILEMANAGER), NULL, DlgProfileManager, (LPARAM)&prof);
if (rc != -1)
- for (int i=0; i < opi.pageCount; i++) {
+ for (int i = 0; i < opi.pageCount; i++) {
mir_free((char*)opi.odp[i].pszTitle);
mir_free(opi.odp[i].pszGroup);
if ((DWORD_PTR)opi.odp[i].pszTemplate & 0xFFFF0000)
|