Changeset 1409 for trunk/dll/mainwnd.c


Ignore:
Timestamp:
Mar 20, 2009, 12:35:30 AM (17 years ago)
Author:
Gregg Young
Message:

Rename some container ini keys consolidate inline code in WriteDetailsSwitches, LoadDetailsSwitches and RemoveCnrSwitches (Ticket 343, 345, 347) Save changes to detail switches for compare directories (Ticket 346). Move additional messages to PCSZs (Ticket 6). Comments and minor code clean up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd.c

    r1402 r1409  
    8383  08 Mar 09 GKY Additional strings move to PCSZs & String Table
    8484  08 Mar 09 GKY Add WriteDetailsSwitches and use LoadDetailsSwitches to replace in line code
     85  19 Mar 09 GKY Moved DeletePresParams to presparam.c
    8586
    8687***********************************************************************/
     
    167168static BOOL CloseDirCnrChildren(HWND hwndClient);
    168169static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview);
    169 static VOID DeletePresParams(PSZ pszKeyroot);
    170170static VOID BuildTools(HWND hwndT, BOOL resize);
    171171
     
    29192919  ULONG previous_numsaves, ulTemp = sizeof(ULONG);
    29202920  CHAR szPrefix[STATE_NAME_MAX_BYTES + 1];
    2921   CHAR szKey[STATE_NAME_MAX_BYTES + 80];
     2921  CHAR szKey[STATE_NAME_MAX_BYTES + 80], szKeyBase[STATE_NAME_MAX_BYTES + 80], *eos;
    29222922  CHAR szDir[CCHMAXPATH];
    29232923  SWP swp;
     
    29632963              continue;
    29642964            }
    2965             sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2965            sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, numsaves);
     2966            strcpy(szKey, szKeyBase);
     2967            strcat(szKey, ".");
     2968            eos = &szKey[strlen(szKey)];
     2969            strcpy(eos, "Pos");
    29662970            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    29672971                                sizeof(SWP));
    29682972            dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    2969             if (dcd) {
    2970               sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2973            if (dcd) {
     2974              strcpy(eos, "Sort");
    29712975              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    2972                                   sizeof(INT));
    2973               sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2976                                  sizeof(INT));
     2977              strcpy(eos, "Filter");
    29742978              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    2975                                   sizeof(MASK));
    2976               sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
     2979                                  sizeof(MASK));
     2980              strcpy(eos, "View");
    29772981              flWindowAttr = dcd->flWindowAttr;
    29782982              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     
    29912995                  flWindowAttr |= CV_NAME;
    29922996              }
    2993               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
     2997              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &flWindowAttr,
    29942998                                  sizeof(ULONG));
    2995               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    2996               WriteDetailsSwitches(szKey, &dcd->ds);
    2997               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    2998               SavePresParams(hwndDir, szKey);
    2999             }
    3000             sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     2999              WriteDetailsSwitches(szKeyBase, &dcd->ds, TRUE);
     3000              SavePresParams(hwndDir, szKeyBase);
     3001            }
     3002            strcpy(eos, "Dir");
    30013003            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
     3004            numsaves++;
    30023005          }
    30033006        }
     
    30103013  if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &previous_numsaves, &ulTemp))
    30113014    for (ulTemp = numsaves; ulTemp < previous_numsaves; ulTemp++) {
    3012       sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, ulTemp);
    3013       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(SWP));
    3014       sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, ulTemp);
    3015       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(INT));
    3016       sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, ulTemp);
    3017       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(MASK));
    3018       sprintf(szKey, "%sDirCnrView.%lu", szPrefix, ulTemp);
    3019       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(ULONG));
    3020 
    3021       sprintf(szKey, "%sDirCnr.%lu", szPrefix, ulTemp);
    3022       WriteDetailsSwitches(szKey, NULL);
    3023       sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, ulTemp);
    3024       PrfWriteProfileString(fmprof, FM3Str, szKey, NULL);
    3025       sprintf(szKey, "%sDirCnr.%lu.", szPrefix, ulTemp);
    3026       DeletePresParams(szKey);
     3015      sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, ulTemp);
     3016      RemoveCnrSwitches(szKeyBase, NULL);
    30273017    }
    30283018  sprintf(szKey, "%sNumDirsLastTime", szPrefix);
    30293019  if (numsaves) {
    3030     PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & numsaves, sizeof(ULONG));
     3020    PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, sizeof(ULONG));
    30313021    WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp);
    30323022    sprintf(szKey, "%sMySizeLastTime", szPrefix);
    3033     PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP));
     3023    PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, sizeof(SWP));
    30343024    if (WinQueryWindowPos(hwndTree, &swp)) {
    30353025      sprintf(szKey, "%sLastTreePos", szPrefix);
    3036       PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP));
     3026      PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, sizeof(SWP));
    30373027    }
    30383028  }
    30393029  else if (fIsShutDownState) {
    3040     PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & numsaves, sizeof(ULONG));
    3041   }
    3042 
     3030    PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, sizeof(ULONG));
     3031  }
    30433032  return numsaves;
    30443033}
     
    30883077static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview)
    30893078{
    3090   CHAR szKey[STATE_NAME_MAX_BYTES + 80];
     3079  CHAR szKey[STATE_NAME_MAX_BYTES + 80], szKeyBase[STATE_NAME_MAX_BYTES + 80];
    30913080  CHAR szDir[CCHMAXPATH];
    30923081  CHAR szPrefix[STATE_NAME_MAX_BYTES + 2];
     
    31933182      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    31943183    for (x = numsaves - 1; x >= 0; x--) {
    3195       sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, x);
     3184      CHAR *eos = szKey;
     3185
     3186      sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, x);
     3187      strcpy(szKey, szKeyBase);
     3188      strcat(szKey, ".");
     3189      eos = &szKey[strlen(szKey)];
     3190      strcpy(eos, "Pos");
    31963191      size = sizeof(SWP);
    31973192      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
    3198         if (fDeleteState)
    3199           PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3200         sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
     3193        strcpy(eos, "Dir"); ;
    32013194        size = sizeof(szDir);
    32023195        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
     
    32053198          if (fIsShutDownState &&
    32063199              driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    3207             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3208             sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3209             WriteDetailsSwitches(szKey, NULL);
     3200            RemoveCnrSwitches(szKeyBase, NULL);
    32103201            continue;
    32113202          }
    3212           if (fDeleteState)
    3213             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3214           sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3215           LoadDetailsSwitches(szKey, &localdcd.ds);
    3216           if (fDeleteState)
    3217             WriteDetailsSwitches(szKey, NULL);
     3203          LoadDetailsSwitches(szKeyBase, &localdcd.ds, TRUE);
    32183204          hwndDir = (HWND) WinSendMsg(hwndClient,
    32193205                                      UM_SETDIR,
     
    32383224                RestorePresParams(hwndPPSave, PCSZ_DIRCNR);
    32393225              }
    3240               //sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3241               RestorePresParams(hwndCnr, szKey);
     3226              RestorePresParams(hwndCnr, szKeyBase);
    32423227              dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
    32433228              if (dcd) {
     
    32533238                dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
    32543239                dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
    3255                 dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
    3256                 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
     3240                dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
     3241                strcpy(eos, "Sort");
    32573242                size = sizeof(INT);
    32583243                if (PrfQueryProfileData(fmprof,
     
    32643249                    dcd->sortFlags = SORT_PATHNAME;
    32653250                }
    3266                 if (fDeleteState)
    3267                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3268                 size = sizeof(MASK);
    3269                 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
     3251                size = sizeof(MASK);
     3252                strcpy(eos, "Filter");
    32703253                if (PrfQueryProfileData(fmprof,
    32713254                                        FM3Str,
     
    32773260                }
    32783261                *(dcd->mask.prompt) = 0;
    3279                 if (fDeleteState)
    3280                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3281                 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
     3262                strcpy(eos, "View");
    32823263                if (!noview) {
    32833264                  size = sizeof(ULONG);
     
    33043285                  }
    33053286                }
    3306                 if (fDeleteState)
    3307                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    33083287                if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    33093288                  WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     
    33303309                              SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
    33313310                              SWP_ACTIVATE);
    3332           }
     3311          }
     3312          if (fDeleteState)
     3313            RemoveCnrSwitches(szKeyBase, pszStateName);
    33333314        }
    33343315      }
     
    45694550  case IDM_DELETEDIRCNRSTATE:
    45704551    {
    4571       CHAR szStateName[STATE_NAME_MAX_BYTES + 1];
     4552      CHAR szStateName[STATE_NAME_MAX_BYTES + 1], szKeyBase[STATE_NAME_MAX_BYTES + 1];
    45724553
    45734554      *szStateName = 0;
     
    46214602            // Delete
    46224603            ULONG numsaves = 0, size, x;
    4623             CHAR s[STATE_NAME_MAX_BYTES + 80];
     4604            CHAR szKey[STATE_NAME_MAX_BYTES + 80];
    46244605
    46254606            INT ret = remove_setup(szStateName);
    46264607            if (ret == 1)
    46274608              save_setups();
    4628             sprintf(s, "%s.NumDirsLastTime", szStateName);
     4609            sprintf(szKey, "%s.NumDirsLastTime", szStateName);
    46294610            size = sizeof(ULONG);
    46304611            if (!PrfQueryProfileData(fmprof,
    46314612                                     FM3Str,
    4632                                      s,
     4613                                     szKey,
    46334614                                     (PVOID)&numsaves,
    46344615                                     &size)) {
     
    46404621              Runtime_Error(pszSrcFile, __LINE__, NULL);
    46414622            else {
    4642               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    4643               for (x = 0; x < numsaves; x++) {
    4644                 sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
    4645                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4646                 sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
    4647                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4648                 sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
    4649                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4650                 sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
    4651                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4652                 sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
    4653                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4654 
    4655                 sprintf(s, "%s.DirCnr.%lu", szStateName, x);
    4656                 WriteDetailsSwitches(s, NULL);
    4657                 sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
    4658                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4659                 sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
    4660                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4623              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     4624              for (x = 0; x < numsaves; x++) {
     4625                sprintf(szKeyBase, "%s.DirCnr.%lu", szStateName, x);
     4626                RemoveCnrSwitches(szKeyBase, szStateName);
    46614627              }
    4662               sprintf(s, "%s.LastTreePos", szStateName);
    4663               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4664               sprintf(s, "%s.MySizeLastTime", szStateName);
    4665               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    46664628            }
    46674629            PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     
    63546316}
    63556317
    6356 VOID DeletePresParams(CHAR * pchKeyroot)
    6357 // This code assumes that pchKeyroot points to a buffer large enough to
    6358 // hold the full INI key: The state name.dircnr-number.PPName. The
    6359 // PPNames are listed below.
    6360 {
    6361   PSZ apszPPNames[] =
    6362   {
    6363     "Backgroundcolor",
    6364     "Foregroundcolor",
    6365     "Hilitebackgroundcolor",
    6366     "Hiliteforegroundcolor",
    6367     "Bordercolor",
    6368     "Fontnamesize"
    6369   };
    6370 
    6371   ULONG ulSize, ulArraySize = sizeof(apszPPNames) / sizeof(PSZ), x;
    6372   CHAR * eos = pchKeyroot + strlen(pchKeyroot);
    6373 
    6374   for (x = 0; x < ulArraySize; x++)
    6375   {
    6376     strcpy(eos, apszPPNames[x]);
    6377     if (PrfQueryProfileSize(fmprof, appname, pchKeyroot, &ulSize) && ulSize)
    6378     {
    6379       PrfWriteProfileData(fmprof, appname, pchKeyroot, NULL, ulSize);
    6380     }
    6381   }
    6382 }
    6383 
    63846318#pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow)
    63856319#pragma alloc_text(MISC8,TopWindowName,CountDirCnrs)
Note: See TracChangeset for help on using the changeset viewer.