Beispiel #1
0
BOOL Subsets_SaveSubset (LPTSTR pszCell, LPTSTR pszSubset, LPSUBSET sub)
{
   BOOL rc = FALSE;

   if (sub && pszSubset && *pszSubset)
      {
      HKEY hk;
      if ((hk = OpenSubsetsSubKey (pszCell, pszSubset, TRUE)) != NULL)
         {
         DWORD dwMonitored = (sub->pszMonitored) ? 1 : 0;
         RegSetValueEx (hk, REGVAL_INCLUSIVE, 0, REG_DWORD, (LPBYTE)&dwMonitored, sizeof(DWORD));

         for (LPTSTR psz = (sub->pszMonitored) ? sub->pszMonitored : sub->pszUnmonitored;
              psz && *psz;
              psz += 1+lstrlen(psz))
            {
            RegSetValueEx (hk, psz, 0, REG_SZ, (PBYTE)TEXT("X"), sizeof(TCHAR)*2);
            }

         rc = TRUE;

         RegCloseKey (hk);
         }
      }

   return rc;
}
Beispiel #2
0
void Subsets_OpenSave_OnDelete (HWND hDlg)
{
   HWND hList = GetDlgItem (hDlg, IDC_SUBSET_LIST);
   short idxSelected = LV_GetSelected (hList);

   if (idxSelected != -1)
      {
      TCHAR szSubset[ cchNAME ];
      LV_GetItemText (hList, idxSelected, 0, szSubset);

      if (Message (MB_ICONASTERISK | MB_YESNO, IDS_SUBSET_DELETE_TITLE, IDS_SUBSET_DELETE_DESC, TEXT("%s"), szSubset) == IDYES)
         {
         (void)OpenSubsetsSubKey (NULL, szSubset, 2); // 0=open,1=create,2=delete
         Subsets_OpenSave_Populate (hDlg);
         }
      }
}
Beispiel #3
0
LPSUBSET Subsets_LoadSubset (LPTSTR pszCell, LPTSTR pszSubset)
{
   LPSUBSET sub = NULL;

   HKEY hk;
   if ((hk = OpenSubsetsSubKey (pszCell, pszSubset, FALSE)) != NULL)
      {
      DWORD dwMonitored;
      DWORD dwSize;
      DWORD dwType;
      dwSize = sizeof(dwMonitored);
      if (RegQueryValueEx (hk, REGVAL_INCLUSIVE, 0, &dwType, (LPBYTE)&dwMonitored, &dwSize) == 0)
         {
         sub = New (SUBSET);
         memset (sub, 0x00, sizeof(SUBSET));
         lstrcpy (sub->szSubset, pszSubset);
         sub->fModified = FALSE;

         LPTSTR *ppsz;
         ppsz = (dwMonitored) ? &sub->pszMonitored : &sub->pszUnmonitored;

         for (size_t iIndex = 0; ; ++iIndex)
            {
            TCHAR szServer[ cchNAME ];
            dwSize = sizeof(szServer);

            if (RegEnumValue (hk, (DWORD)iIndex, szServer, &dwSize, 0, NULL, NULL, NULL) != 0)
               break;

            if (szServer[0] && lstrcmpi (szServer, REGVAL_INCLUSIVE))
               FormatMultiString (ppsz, FALSE, TEXT("%1"), TEXT("%s"), szServer);
            }

         if (dwMonitored && !sub->pszMonitored)
            {
            sub->pszMonitored = AllocateString(2);
            sub->pszMonitored[0] = TEXT('\0');
            sub->pszMonitored[1] = TEXT('\0');
            }
         }

      RegCloseKey (hk);
      }

   return sub;
}
Beispiel #4
0
HKEY OpenSubsetsKey (LPTSTR pszCell, BOOL fCreate)
{
   return OpenSubsetsSubKey (pszCell, NULL, fCreate);
}
Beispiel #5
0
BOOL CALLBACK Subsets_OpenSave_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
   static BOOL fEditing = FALSE;

   if (msg == WM_INITDIALOG)
      SetWindowLongPtr (hDlg, DWLP_USER, lp);

   LPSUBSET_OPENSAVE_PARAMS lpp;
   if ((lpp = (LPSUBSET_OPENSAVE_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
      {
      switch (msg)
         {
         case WM_INITDIALOG:
            fEditing = FALSE;
            Subsets_OpenSave_OnInitDialog (hDlg, lpp);
            break;

         case WM_COMMAND:
            if (!fEditing)
               {
               switch (LOWORD(wp))
                  {
                  case IDCANCEL:
                     EndDialog (hDlg, IDCANCEL);
                     break;

                  case IDOK:
                     GetDlgItemText (hDlg, IDC_SUBSET_NAME, lpp->szSubset, cchNAME);
                     if (lpp->szSubset[0] != TEXT('\0'))
                        {
                        BOOL fClose = TRUE;

                        if (!lpp->fOpen)
                           {
                           HKEY hk;
                           if ((hk = OpenSubsetsSubKey (NULL, lpp->szSubset, FALSE)) != NULL)
                              {
                              RegCloseKey (hk);

                              int rc = Message (MB_YESNO | MB_ICONASTERISK, IDS_SUBSET_SAVE_TITLE, IDS_SUBSET_SAVE_DESC, TEXT("%s"), lpp->szSubset);
                              if (rc != IDYES)
                                 fClose = FALSE;
                              }
                           }

                        if (fClose)
                           EndDialog (hDlg, IDOK);
                        }
                     break;

                  case IDC_SUBSET_DELETE:
                     Subsets_OpenSave_OnDelete (hDlg);
                     break;

                  case IDC_SUBSET_RENAME:
                     Subsets_OpenSave_OnRename (hDlg);
                     break;
                  }
               }
            break;

         case WM_NOTIFY:
            switch (((LPNMHDR)lp)->code)
               {
               case LVN_ITEMCHANGED:
                  if (!fEditing)
                     {
                     if ( ((LPNM_LISTVIEW)lp)->uNewState & LVIS_SELECTED )
                        Subsets_OpenSave_OnSelect (hDlg);
                     }
                  break;

               case NM_DBLCLK:
                  if (!fEditing)
                     {
                     if (((LPNMHDR)lp)->hwndFrom == GetDlgItem (hDlg, IDC_SUBSET_LIST))
                        {
                        Subsets_OpenSave_OnSelect (hDlg);
                        PostMessage (hDlg, WM_COMMAND, IDOK, 0);
                        }
                     }
                  break;

               case LVN_BEGINLABELEDIT:
                  fEditing = TRUE;
                  return FALSE;  // okay to edit label

               case LVN_ENDLABELEDIT:
                  LV_DISPINFO *plvdi;
                  if ((plvdi = (LV_DISPINFO*)lp) != NULL)
                     {
                     if ((plvdi->item.iItem != -1) &&
                         (plvdi->item.pszText != NULL))
                        {
                        HWND hList = GetDlgItem (hDlg, IDC_SUBSET_LIST);
                        TCHAR szOldName[ cchNAME ];
                        LV_GetItemText (hList, plvdi->item.iItem, 0, szOldName);

                        if (lstrcmpi (szOldName, plvdi->item.pszText))
                           {
                           BOOL fRename = TRUE;
                           BOOL fRepopulate = FALSE;

                           HKEY hk;
                           if ((hk = OpenSubsetsSubKey (NULL, plvdi->item.pszText, FALSE)) != NULL)
                              {
                              RegCloseKey (hk);

                              int rc = Message (MB_YESNO | MB_ICONASTERISK, IDS_SUBSET_SAVE_TITLE, IDS_SUBSET_SAVE_DESC, TEXT("%s"), lpp->szSubset);
                              if (rc != IDYES)
                                 fRename = FALSE;
                              else
                                 fRepopulate = TRUE;
                              }

                           if (fRename)
                              {
                              LPSUBSET subRename;
                              if ((subRename = Subsets_LoadSubset (NULL, szOldName)) != NULL)
                                 {
                                 if (Subsets_SaveSubset (NULL, plvdi->item.pszText, subRename))
                                    {
                                    (void)OpenSubsetsSubKey (NULL, szOldName, 2); // 0=open,1=create,2=delete

                                    if (fRepopulate)
                                       Subsets_OpenSave_Populate (hDlg);
                                    else
                                       {
                                       LV_SetItemText (hList, plvdi->item.iItem, 0, plvdi->item.pszText);
                                       Subsets_OpenSave_OnSelect (hDlg);
                                       }

                                    Subsets_FreeSubset (subRename);
                                    }
                                 }
                              }
                           }
                        }
                     }

                  fEditing = FALSE;
                  break;
               }
            break;
         }
      }

   return FALSE;
}