Changeset 787


Ignore:
Timestamp:
Aug 19, 2007, 11:02:37 PM (18 years ago)
Author:
Steven Levine
Message:

Rework UM_FILLSETUPLIST IDM_SAVEDIRCNRSTATE and ..._setups() logic for ticket# 109 and #31
Add GetMSecTimer()
Use GetMSecTimer in DbgMsg
Tweak notebook.ipf scanning page
Move more #pragma alloc_text statements to end of files for OpenWatcom
Delete obsoletes
Revert ExpandAll() ShowTreeRec() DosSleeps to 0 - DosSleep(1) was slowing down inner loops
Drop afFilesToGet - use FilesToGet directly
Optimze ShowTreeRec() collapse logic - was really slow

Location:
trunk/dll
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r775 r787  
    799799        if (strlen(dcd->previous) > strlen(dcd->directory) &&
    800800            !strnicmp(dcd->directory, dcd->previous,
    801                       strlen(dcd->directory))) {
    802 
    803           PCNRITEM pci;
    804 
    805           pci = FindCnrRecord(dcd->hwndCnr,
    806                               dcd->previous, NULL, TRUE, FALSE, TRUE);
     801                      strlen(dcd->directory)))
     802        {
     803          PCNRITEM pci = FindCnrRecord(dcd->hwndCnr,
     804                                       dcd->previous,
     805                                       NULL, TRUE, FALSE, TRUE);
    807806          if (pci && (INT) pci != -1) {
    808             /* make found item current (cursored) item */
     807            // make found item current (cursored) item
    809808            WinSendMsg(dcd->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
    810809                       MPFROM2SHORT(TRUE, CRA_CURSORED));
     
    32503249          else if (*dcd->directory)
    32513250            OpenObject(dcd->directory, Default, hwnd);
    3252         }
    3253         break;
    3254       }
     3251        } // CN_ENTER
     3252        break;
     3253      } // switch mp1
    32553254      break;
    3256     }
     3255    } // if dcd
    32573256    return 0;
    32583257
     
    32603259    if (dcd && mp2) {
    32613260
    3262       HWND ret;
    3263 
    3264       ret = StartMLEEditor(dcd->hwndParent,
    3265                            (INT) mp1, (CHAR *) mp2, dcd->hwndFrame);
     3261      HWND ret = StartMLEEditor(dcd->hwndParent,
     3262                                (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    32663263      if (mp2)
    3267         free((CHAR *) mp2);
     3264        free((CHAR *)mp2);
    32683265      return MRFROMLONG(ret);
    32693266    }
  • trunk/dll/error.c

    r689 r787  
    2525  20 Apr 07 SHL Correct IDS_GENERR1TEXT formatting
    2626  23 Apr 07 SHL Add Win_Error_NoMsgBox.  Rework others
     27  14 Aug 07 SHL Add GetMSecTimer
     28  14 Aug 07 SHL Use GetMSecTimer in DbgMsg
    2729
    2830***********************************************************************/
     
    4244
    4345#pragma data_seg(DATA1)
    44 #pragma alloc_text(FMINPUT,Win_Error,Dos_Error,saymsg,showMsg)
     46
     47static PSZ pszSrcFile = __FILE__;
    4548
    4649static VOID formatWinError(PSZ pszBuf, UINT cBufBytes, HWND hwndErr, HWND hwndOwner,
     
    5558{
    5659  va_list va;
     60
     61#if 1 // fixme to be selectable
     62
     63  static ULONG ul1stMSec;
     64  // static ULONG ulLastMSec;
     65
     66  ULONG msec = GetMSecTimer();
     67  ULONG delta;
     68
     69  if (!ul1stMSec) {
     70    ul1stMSec = msec;
     71    // ulLastMSec = msec;                       // Avoid big delta 1st time
     72  }
     73
     74  delta = msec - ul1stMSec;
     75  // ulLastMSec = msec;
     76  fprintf(stderr, "%03lu.%03lu ", delta / 1000, delta % 1000);
     77
     78#endif
    5779
    5880  // OK for source file name to be null
     
    227249} // formatWinError
    228250
     251/**
     252 * Return millisecond timer value
     253 * Resolution is milliseconds, but accuracy will be less
     254 * depending on systems settings
     255 */
     256
     257ULONG GetMSecTimer(void)
     258{
     259  ULONG msec;
     260
     261  APIRET rc = DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT,
     262                              &msec, sizeof(msec));
     263  if (rc) {
     264    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     265              "DosQuerySysInfo");
     266    msec = 0;
     267  }
     268  return msec;
     269}
     270
    229271//== Runtime_Error: report runtime library error using passed message string ===
    230272
     
    363405
    364406} // Win_Error_NoMsgBox
     407
     408#pragma alloc_text(ERROR,Win_Error,Dos_Error,saymsg,showMsg,GetHiresTimeer)
  • trunk/dll/fm3dll.h

    r773 r787  
    5454  23 Jul 07 SHL More CNRITEM updates (ticket#24)
    5555  01 Aug 07 SHL More CNRITEM and ARCITEM updates (ticket#24)
     56  14 Aug 07 SHL Add GetMSecTimer
     57  14 Aug 07 SHL Delete obsoletes
     58  16 Aug 07 SHL Update for ticket# 109 - status update
     59  18 Aug 07 SHL Update for ticket# 31 - states length
    5660
    5761***********************************************************************/
     
    657661INT Dos_Error2(ULONG mb_type, ULONG ulRC, HWND hwndOwner, PCSZ pszSrcFile,
    658662               UINT uSrcLineNo, UINT idMsg);
     663ULONG GetMSecTimer(void);
    659664VOID Runtime_Error(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...);
    660665VOID Runtime_Error2(PCSZ pszSrcFile, UINT uSrcLineNo, UINT idMsg);
     
    718723                           CHAR * directory, CHAR * keyroot, DIRCNRDATA * dcd,
    719724                           BOOL compare);
    720 VOID FreeMallocedMem(VOID * mem);
    721 VOID FcloseFile(FILE * fp);
    722725VOID SetConditionalCascade(HWND hwndMenu, USHORT id, USHORT def);
    723726VOID SetSortChecks(HWND hwndMenu, INT sortflags);
     
    10281031VOID load_udirs(VOID);
    10291032VOID save_udirs(VOID);
    1030 BOOL add_udir(BOOL userdirs, CHAR * inpath);
    1031 BOOL remove_udir(CHAR * path);
    1032 BOOL remove_ldir(CHAR * path);
     1033BOOL add_udir(BOOL userdirs, PSZ inpath);
     1034BOOL remove_udir(PSZ path);
     1035BOOL remove_ldir(PSZ path);
     1036VOID fill_setups_list(VOID);
    10331037VOID load_setups(VOID);
    10341038VOID save_setups(VOID);
    1035 BOOL add_setup(CHAR * name);
    1036 BOOL remove_setup(CHAR * name);
    1037 VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, CHAR * path,
     1039INT add_setup(PSZ stateName);
     1040INT remove_setup(PSZ stateName);
     1041VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, PSZ path,
    10381042                     BOOL nounwriteable);
    10391043MRESULT EXPENTRY WalkDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     
    13621366  fNoTreeGap, fDummy, fVTreeOpensWPS, fUseQProcStat,
    13631367  fStartMinimized, fStartMaximized, fRemoteBug, fReminimize,
    1364   fDragndropDlg, fMinOnOpen, fUserComboBox, loadedsetups,
     1368  fDragndropDlg, fMinOnOpen, fUserComboBox,
    13651369  fQuickArcFind, fNoRemovableScan, fAutoView, fDataMin,
    13661370  fDataToFore, fDataShowDrives, fDataInclRemote,
     
    14341438#pragma data_seg(GLOBAL3)
    14351439#endif
    1436 #define MAXNUMSETUPS  100
    1437 DATADEF CHAR lastsetups[MAXNUMSETUPS][13];
    1438 DATADEF INT lastsetup;
    14391440DATADEF LONG standardcolors[16];
    14401441
  • trunk/dll/ipf/notebook.ipf

    r783 r787  
    323323all expanded branches in the tree before switching because of one of the
    324324two above switch events.
     325This option is will significantly slow down switching
     326if you a large number of directories in the Drive Tree.
    325327:p.
    326328:hp6.Expand curr. after switch:ehp6. causes the Drive Tree to expand
  • trunk/dll/mainwnd.c

    r775 r787  
    3737  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    3838  07 Aug 07 SHL Use BldQuotedFileName
     39  16 Aug 07 SHL Update IDM_SAVEDIRCNRSTATE logic for ticket# 109
     40  18 Aug 07 SHL Rework UM_FILLSETUPLIST for new setups storage
     41  19 Aug 07 SHL Move #pragma alloc_text to end of file for OpenWatcom
    3942
    4043***********************************************************************/
     
    4346#define INCL_WIN
    4447// #define INCL_WINERRORS
    45 #define INCL_SHLERRORS
     48#define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX
    4649#define INCL_WINHELP
    4750#define INCL_GPI
     
    6669
    6770static PSZ pszSrcFile = __FILE__;
    68 
    69 #pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow)
    70 #pragma alloc_text(MISC8,TopWindowName,CountDirCnrs)
    71 #pragma alloc_text(MAINWND,AdjustSizeOfClient,FillClient,ChildButtonProc)
    72 #pragma alloc_text(MAINWND,ToolBackProc,StatusProc)
    73 #pragma alloc_text(MAINWND,MoveChildrenAwayFromTree,ArrangeIcons,NextChild)
    74 #pragma alloc_text(MAINWND,ChildFrameButtonProc)
    75 #pragma alloc_text(MAINWND2,CloseChildren,CountChildren,GetNextWindowPos)
    76 #pragma alloc_text(MAINWND2,CascadeChildren,TileChildren,ResizeChildren)
    77 #pragma alloc_text(MAINWND2,MinResChildren,MainFrameWndProc,MainWndProc)
    78 #pragma alloc_text(MAINWND2,DropDownListProc)
    79 #pragma alloc_text(MAINWND3,RestoreDirCnrState,SaveDirCnrState)
    80 #pragma alloc_text(MAINWND3,CloseDirCnrChildren,TransformSwp)
    81 #pragma alloc_text(MAINWND3,ResizeTools,BuildTools,CommandLineProc)
    82 #pragma alloc_text(MAINWND4,DriveProc,DriveBackProc,BuildDriveBarButtons,ResizeDrives)
    83 #pragma alloc_text(MAINWND4,LEDProc,IdealButtonProc)
    84 #pragma alloc_text(MAINWND5,MainWMOnce)
    85 #pragma alloc_text(MAINWND6,MainWMCommand)
    86 #pragma alloc_text(BUBBLE,MakeBubble,BubbleProc,BubbleHelp)
    87 #pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin)
    8871
    8972static USHORT firsttool = 0;
     
    160143        bd = 3L;
    161144      *s = (CHAR) bd + '@';
    162       WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1L));
     145      WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
    163146      if (!mp1) {
    164147        s[3] = 0;
    165148        WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
    166149      }
    167       PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1L), MPFROMLONG(1L));
     150      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
    168151    }
    169152    return 0;
     
    26542637 */
    26552638
     2639#define STATE_NAME_MAX_BYTES    256
     2640
    26562641BOOL SaveDirCnrState(HWND hwndClient, PSZ pszStateName)
    26572642{
     
    26592644  HWND hwndChild, hwndDir, hwndC;
    26602645  ULONG numsaves = 0, flWindowAttr;
    2661   CHAR szPrefix[20];
    2662   CHAR s[80];
     2646  CHAR szPrefix[STATE_NAME_MAX_BYTES + 1];
     2647  CHAR szKey[STATE_NAME_MAX_BYTES + 80];
    26632648  CHAR szDir[CCHMAXPATH];
    26642649  SWP swp;
     
    26892674           if (driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN)
    26902675             continue;
    2691             sprintf(s, "%sDirCnrPos.%lu", szPrefix, numsaves);
    2692             PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & swp,
     2676            sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2677            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    26932678                                sizeof(SWP));
    26942679            dcd =
    26952680              WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    26962681            if (dcd) {
    2697               sprintf(s, "%sDirCnrSort.%lu", szPrefix, numsaves);
    2698               PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & dcd->sortFlags,
     2682              sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2683              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    26992684                                  sizeof(INT));
    2700               sprintf(s, "%sDirCnrFilter.%lu", szPrefix, numsaves);
    2701               PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & dcd->mask,
     2685              sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2686              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    27022687                                  sizeof(MASK));
    2703               sprintf(s, "%sDirCnrView.%lu", szPrefix, numsaves);
     2688              sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
    27042689              flWindowAttr = dcd->flWindowAttr;
    27052690              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     
    27182703                  flWindowAttr |= CV_NAME;
    27192704              }
    2720               PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & flWindowAttr,
     2705              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
    27212706                                  sizeof(ULONG));
    27222707            }
    2723             sprintf(s, "%sDirCnrDir.%lu", szPrefix, numsaves++);
    2724             PrfWriteProfileString(fmprof, FM3Str, s, szDir);
     2708            sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     2709            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
    27252710            fSaved = TRUE;
    27262711          }
     
    27332718  if (fSaved) {
    27342719    if (WinQueryWindowPos(hwndTree, &swp)) {
    2735       sprintf(s, "%sLastTreePos", szPrefix);
    2736       PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & swp, sizeof(SWP));
    2737     }
    2738     sprintf(s, "%sNumDirsLastTime", szPrefix);
    2739     PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & numsaves, sizeof(ULONG));
     2720      sprintf(szKey, "%sLastTreePos", szPrefix);
     2721      PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP));
     2722    }
     2723    sprintf(szKey, "%sNumDirsLastTime", szPrefix);
     2724    PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & numsaves, sizeof(ULONG));
    27402725    WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp);
    2741     sprintf(s, "%sMySizeLastTime", szPrefix);
    2742     PrfWriteProfileData(fmprof, FM3Str, s, (PVOID) & swp, sizeof(SWP));
     2726    sprintf(szKey, "%sMySizeLastTime", szPrefix);
     2727    PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP));
    27432728  }
    27442729
     
    27892774static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview)
    27902775{
    2791   CHAR s[80];
     2776  CHAR szKey[STATE_NAME_MAX_BYTES + 80];
    27922777  CHAR szDir[CCHMAXPATH];
    2793   CHAR szPrefix[20];
     2778  CHAR szPrefix[STATE_NAME_MAX_BYTES + 2];
    27942779  HWND hwndDir, hwndC;
    27952780  SWP swp, swpO, swpN;
     
    28102795
    28112796  size = sizeof(SWP);
    2812   sprintf(s, "%sMySizeLastTime", szPrefix);
     2797  sprintf(szKey, "%sMySizeLastTime", szPrefix);
    28132798  if (!PrfQueryProfileData(fmprof,
    28142799                           FM3Str,
    2815                            s,
     2800                           szKey,
    28162801                           (PVOID) & swpO,
    28172802                           &size) ||
     
    28212806  }
    28222807  if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2823     PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2808    PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    28242809  WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN);
    28252810  if (swpN.fl & (SWP_MINIMIZE | SWP_HIDE))
     
    28282813  ytrans = ((double)swpO.cy * 100.0) / (double)swpN.cy;
    28292814  size = sizeof(SWP);
    2830   sprintf(s, "%sLastTreePos", szPrefix);
    2831   if (PrfQueryProfileData(fmprof, FM3Str, s, (PVOID) & swp, &size)) {
     2815  sprintf(szKey, "%sLastTreePos", szPrefix);
     2816  if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, &size)) {
    28322817    if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2833       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2818      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    28342819    swp.hwnd = hwndTree;
    28352820    TransformSwp(&swp, xtrans, ytrans);
     
    28592844  }
    28602845  size = sizeof(ULONG);
    2861   sprintf(s, "%sNumDirsLastTime", szPrefix);
     2846  sprintf(szKey, "%sNumDirsLastTime", szPrefix);
    28622847  if (PrfQueryProfileData(fmprof,
    2863                           FM3Str, s, (PVOID) & numsaves, &size) && numsaves) {
     2848                          FM3Str, szKey, (PVOID) & numsaves, &size) && numsaves) {
    28642849    if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2865       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2850      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    28662851    for (x = 0; x < numsaves; x++) {
    2867       sprintf(s, "%sDirCnrPos.%lu", szPrefix, x);
     2852      sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, x);
    28682853      size = sizeof(SWP);
    2869       if (PrfQueryProfileData(fmprof, FM3Str, s, (PVOID) & swp, &size)) {
     2854      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, &size)) {
    28702855        if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2871           PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    2872         sprintf(s, "%sDirCnrDir.%lu", szPrefix, x);
     2856          PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     2857        sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
    28732858        size = sizeof(szDir);
    2874         if (PrfQueryProfileData(fmprof, FM3Str, s, (PVOID) szDir, &size)) {
     2859        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
    28752860          if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2876             PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2861            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    28772862          if (driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    2878             PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2863            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    28792864            continue;
    28802865          }
    28812866          hwndDir = (HWND) WinSendMsg(hwndClient,
    28822867                                      UM_SETDIR,
    2883                                       MPFROMP(szDir), MPFROMLONG(1L));
     2868                                      MPFROMP(szDir), MPFROMLONG(1));
    28842869          if (hwndDir) {
    28852870            hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
     
    28892874              if (dcd) {
    28902875                size = sizeof(INT);
    2891                 sprintf(s, "%sDirCnrSort.%lu", szPrefix, x);
     2876                sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
    28922877                if (PrfQueryProfileData(fmprof,
    28932878                                        FM3Str,
    2894                                         s,
     2879                                        szKey,
    28952880                                        (PVOID) & dcd->sortFlags,
    28962881                                        &size) && size == sizeof(INT)) {
     
    28992884                }
    29002885                if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2901                   PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2886                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    29022887                size = sizeof(MASK);
    2903                 sprintf(s, "%sDirCnrFilter.%lu", szPrefix, x);
     2888                sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
    29042889                if (PrfQueryProfileData(fmprof,
    29052890                                        FM3Str,
    2906                                         s,
     2891                                        szKey,
    29072892                                        (PVOID) & dcd->mask, &size) && size) {
    29082893                  if (*dcd->mask.szMask)
     
    29122897                *(dcd->mask.prompt) = 0;
    29132898                if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2914                   PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2899                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    29152900                size = sizeof(ULONG);
    2916                 sprintf(s, "%sDirCnrView.%lu", szPrefix, x);
     2901                sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
    29172902                if (!noview) {
    29182903                  if (PrfQueryProfileData(fmprof,
    29192904                                          FM3Str,
    2920                                           s,
     2905                                          szKey,
    29212906                                          (PVOID) & dcd->flWindowAttr,
    29222907                                          &size) && size == sizeof(ULONG)) {
     
    29392924                }
    29402925                if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    2941                   PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     2926                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    29422927              }
    29432928            }
     
    30132998    ulCnt = *ulCntR;
    30142999    ulNumMinChildren = *ulNumMinChildrenR;
    3015     if (ulCnt == (ULONG) - 1L) {
     3000    if (ulCnt == (ULONG) - 1) {
    30163001      ulCnt = CountChildren(hwndClient, &ulNumMinChildren);
    30173002      /* return these values to the caller for later use */
     
    31213106  }
    31223107  if (!fTileBackwards) {
    3123     ulNumCols = ulSquare - 1L;
     3108    ulNumCols = ulSquare - 1;
    31243109    ulNumRows = ulChildCnt / ulNumCols;
    31253110  }
    31263111  else {
    3127     ulNumRows = ulSquare - 1L;
     3112    ulNumRows = ulSquare - 1;
    31283113    ulNumCols = ulChildCnt / ulNumRows;
    31293114  }
     
    32053190                                 QWS_YRESTORE,
    32063191                                 (USHORT) (Rectl.yTop -
    3207                                            (ulHeight * (ulCurRow + 1L))));
     3192                                           (ulHeight * (ulCurRow + 1))));
    32083193              WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
    32093194              WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
     
    32133198                              HWND_TOP,
    32143199                              (ulWidth * ulCurCol) + Rectl.xLeft,
    3215                               Rectl.yTop - (ulHeight * (ulCurRow + 1L)),
     3200                              Rectl.yTop - (ulHeight * (ulCurRow + 1)),
    32163201                              ulWidth,
    32173202                              ulHeight,
     
    41804165  case IDM_DELETEDIRCNRSTATE:
    41814166    {
    4182       CHAR szStateName[14];
     4167      CHAR szStateName[STATE_NAME_MAX_BYTES + 1];
    41834168
    41844169      *szStateName = 0;
    4185       WinQueryWindowText(hwndStatelist, 13, szStateName);
     4170      WinQueryWindowText(hwndStatelist, STATE_NAME_MAX_BYTES, szStateName);
    41864171      bstrip(szStateName);
    41874172      // Ignore request if blank or attempting to using illegal name
     
    41904175          // Save
    41914176          if (SaveDirCnrState(hwnd, szStateName)) {
    4192             if (add_setup(szStateName)) {
     4177            INT ret = add_setup(szStateName);
     4178            if (ret == 0) {
    41934179              WinSendMsg(hwndStatelist, LM_INSERTITEM,
    41944180                         MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
    41954181              save_setups();
    41964182            }
    4197             else {
     4183            else if (ret != 1) {
    41984184              saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    41994185                     GetPString(IDS_WARNINGTEXT),
    4200                      GetPString(IDS_EXISTSASATEXT), szStateName, "state name");
     4186                     "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
    42014187              WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    42024188            }
     
    42124198          // Delete
    42134199          ULONG numsaves = 0, size, x;
    4214           CHAR s[80];
    4215 
    4216           if (remove_setup(szStateName))
     4200          CHAR s[STATE_NAME_MAX_BYTES + 80];
     4201
     4202          INT ret = remove_setup(szStateName);
     4203          if (ret == 1)
    42174204            save_setups();
    42184205          sprintf(s, "%s.NumDirsLastTime", szStateName);
    42194206          size = sizeof(ULONG);
    4220           if (!PrfQueryProfileData
    4221               (fmprof, FM3Str, s, (PVOID) & numsaves, &size)) {
     4207          if (!PrfQueryProfileData(fmprof,
     4208                                   FM3Str,
     4209                                   s,
     4210                                   (PVOID)&numsaves,
     4211                                   &size)) {
    42224212            saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    42234213                   GetPString(IDS_WARNINGTEXT),
     
    45654555                         MPFROMP(pci->pszFileName),
    45664556                         (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
    4567                          MPVOID : MPFROMLONG(1L));
     4557                         MPVOID : MPFROMLONG(1));
    45684558          }
    45694559        }
     
    50635053               EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    50645054    WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5065                EM_SETTEXTLIMIT, MPFROM2SHORT(13, 0), MPVOID);
     5055               EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
    50665056    WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    50675057               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     
    54545444
    54555445  case UM_FILLSETUPLIST:
    5456     WinSendMsg(hwndStatelist, LM_DELETEALL, MPVOID, MPVOID);
    5457     if (fUserComboBox) {
    5458       INT x;
    5459 
    5460       if (!loadedsetups)
    5461         load_setups();
    5462       for (x = 0; x < MAXNUMSETUPS; x++) {
    5463         if (*lastsetups[x])
    5464           WinSendMsg(hwndStatelist, LM_INSERTITEM,
    5465                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5466                      MPFROMP(lastsetups[x]));
    5467       }
    5468       WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    5469     }
     5446    fill_setups_list();
    54705447    return 0;
    54715448
     
    54835460      DosError(FERR_DISABLEHARDERR);
    54845461      hDir = HDIR_CREATE;
    5485       ulSearchCount = 1L;
     5462      ulSearchCount = 1;
    54865463      if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
    54875464                        &findbuf, sizeof(FILEFINDBUF3),
     
    55435520          DosError(FERR_DISABLEHARDERR);
    55445521          hDir = HDIR_CREATE;
    5545           ulSearchCount = 1L;
     5522          ulSearchCount = 1;
    55465523          if (!IsRoot(info->path))
    55475524            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     
    55855562          DosError(FERR_DISABLEHARDERR);
    55865563          hDir = HDIR_CREATE;
    5587           ulSearchCount = 1L;
     5564          ulSearchCount = 1;
    55885565          if (!IsRoot(info->path))
    55895566            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     
    56705647                                        SHORT1FROMMP(mp1));
    56715648          CHAR path[CCHMAXPATH];
     5649          ULONG ul;
     5650
     5651          switch (SHORT1FROMMP(mp1)) {
     5652          case MAIN_USERLIST:
     5653            ul = CCHMAXPATH;
     5654            break;
     5655          case MAIN_SETUPLIST:
     5656            ul = STATE_NAME_MAX_BYTES;
     5657            break;
     5658          default:
     5659            ul = 13;                    // fixme to not be hardcoded
     5660          }
    56725661
    56735662          SetShiftState();
    5674           WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT),
    5675                              ((SHORT1FROMMP(mp1) == MAIN_USERLIST) ?
    5676                               CCHMAXPATH : 13), path);
     5663          WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
    56775664          bstrip(path);
    56785665          if (*path) {
     
    57205707            else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
    57215708
    5722               CHAR s[80];
     5709              CHAR szKey[80];
    57235710              ULONG size, numsaves = 0;
    57245711
    57255712              SetShiftState();
    57265713              size = sizeof(ULONG);
    5727               sprintf(s, "%s.NumDirsLastTime", path);   // path is state name
    5728               if (!PrfQueryProfileData
    5729                   (fmprof, FM3Str, s, (PVOID) & numsaves, &size))
     5714              sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
     5715              if (!PrfQueryProfileData(fmprof,
     5716                                       FM3Str,
     5717                                       szKey,
     5718                                       (PVOID)&numsaves,
     5719                                       &size))
    57305720              {
    57315721                if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
     
    57515741                    if ((shiftstate & KC_SHIFT) != 0 || fAutoTile)
    57525742                      PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID,
    5753                               MPFROMLONG(1L));
     5743                              MPFROMLONG(1));
    57545744                  }
    57555745                  else {
     
    58545844  return WinDefWindowProc(hwnd, msg, mp1, mp2);
    58555845}
     5846
     5847#pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow)
     5848#pragma alloc_text(MISC8,TopWindowName,CountDirCnrs)
     5849#pragma alloc_text(MAINWND,AdjustSizeOfClient,FillClient,ChildButtonProc)
     5850#pragma alloc_text(MAINWND,ToolBackProc,StatusProc)
     5851#pragma alloc_text(MAINWND,MoveChildrenAwayFromTree,ArrangeIcons,NextChild)
     5852#pragma alloc_text(MAINWND,ChildFrameButtonProc)
     5853#pragma alloc_text(MAINWND2,CloseChildren,CountChildren,GetNextWindowPos)
     5854#pragma alloc_text(MAINWND2,CascadeChildren,TileChildren,ResizeChildren)
     5855#pragma alloc_text(MAINWND2,MinResChildren,MainFrameWndProc,MainWndProc)
     5856#pragma alloc_text(MAINWND2,DropDownListProc)
     5857#pragma alloc_text(MAINWND3,RestoreDirCnrState,SaveDirCnrState)
     5858#pragma alloc_text(MAINWND3,CloseDirCnrChildren,TransformSwp)
     5859#pragma alloc_text(MAINWND3,ResizeTools,BuildTools,CommandLineProc)
     5860#pragma alloc_text(MAINWND4,DriveProc,DriveBackProc,BuildDriveBarButtons,ResizeDrives)
     5861#pragma alloc_text(MAINWND4,LEDProc,IdealButtonProc)
     5862#pragma alloc_text(MAINWND5,MainWMOnce)
     5863#pragma alloc_text(MAINWND6,MainWMCommand)
     5864#pragma alloc_text(BUBBLE,MakeBubble,BubbleProc,BubbleHelp)
     5865#pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin)
     5866
  • trunk/dll/misc.c

    r775 r787  
    3131  06 Aug 07 GKY Increase Subject EA to 1024
    3232  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    33 
     33  14 Aug 07 SHL Delete obsoletes
     34  14 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    3435
    3536***********************************************************************/
     
    5657static PSZ pszSrcFile = __FILE__;
    5758
    58 #pragma alloc_text(MAINWND5,SetSysMenu)
    59 #pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
    60 #pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
    61 #pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
    62 #pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
    63 #pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
    64 #pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
    65 #pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
    66 #pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
    67 #pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
    68 #pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches)
    69 #pragma alloc_text(MISC3,FreeMallocedMem,FcloseFile)
    70 #pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
    71 #pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
    72 #pragma alloc_text(MISC_LIBPATH,LoadLibPath)
    73 #pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
    74 
    7559#ifndef BEGIN_LIBPATH
    7660#define BEGIN_LIBPATH            1
     
    135119    ptl.y = 1;
    136120    GpiMove(hps, &ptl);
    137     GpiSetColor(hps, ((on) ? CLR_BLACK : CLR_PALEGRAY));
     121    GpiSetColor(hps, on ? CLR_BLACK : CLR_PALEGRAY);
    138122    ptl.x = swp.cx - 2;
    139123    ptl.y = swp.cy - 2;
     
    150134
    151135  if (hps) {
    152     BoxWindow(hwnd, hps, ((on) ? CLR_BLACK : CLR_PALEGRAY));
     136    BoxWindow(hwnd, hps, on ? CLR_BLACK : CLR_PALEGRAY);
    153137    DrgReleasePS(hps);
    154138  }
     
    214198        do {
    215199          GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    216           if (aptl[TXTBOX_TOPRIGHT].x > (rcl.xRight - ((p != s) ? len : 0)))
     200          if (aptl[TXTBOX_TOPRIGHT].x > (rcl.xRight - (p != s ? len : 0)))
    217201            p++;
    218202          else
     
    410394    hasLongNames = FALSE;
    411395  }
    412   pBool = (dcd) ? &dcd->detailsladate : &detailsladate;
    413   AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE),
    414                   (*pBool) ? hasAccessDT : FALSE, FALSE);
    415   pBool = (dcd) ? &dcd->detailslatime : &detailslatime;
    416   AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME),
    417                   (*pBool) ? hasAccessDT : FALSE, FALSE);
    418   pBool = (dcd) ? &dcd->detailscrdate : &detailscrdate;
    419   AdjustCnrColVis(hwndCnr, GetPString(IDS_CRDATE),
    420                   (*pBool) ? hasCreateDT : FALSE, FALSE);
    421   pBool = (dcd) ? &dcd->detailscrtime : &detailscrtime;
    422   AdjustCnrColVis(hwndCnr, GetPString(IDS_CRTIME),
    423                   (*pBool) ? hasCreateDT : FALSE, FALSE);
    424   pBool = (dcd) ? &dcd->detailslongname : &detailslongname;
    425   AdjustCnrColVis(hwndCnr, GetPString(IDS_LNAME),
    426                   (*pBool) ? hasLongNames : FALSE, FALSE);
     396  pBool = dcd ? &dcd->detailsladate : &detailsladate;
     397  AdjustCnrColVis(hwndCnr,
     398                  GetPString(IDS_LADATE),
     399                  *pBool ? hasAccessDT : FALSE,
     400                  FALSE);
     401  pBool = dcd ? &dcd->detailslatime : &detailslatime;
     402  AdjustCnrColVis(hwndCnr,
     403                  GetPString(IDS_LATIME),
     404                  *pBool ? hasAccessDT : FALSE,
     405                  FALSE);
     406  pBool = dcd ? &dcd->detailscrdate : &detailscrdate;
     407  AdjustCnrColVis(hwndCnr,
     408                  GetPString(IDS_CRDATE),
     409                  *pBool ? hasCreateDT : FALSE,
     410                  FALSE);
     411  pBool = dcd ? &dcd->detailscrtime : &detailscrtime;
     412  AdjustCnrColVis(hwndCnr,
     413                  GetPString(IDS_CRTIME),
     414                  *pBool ? hasCreateDT : FALSE,
     415                  FALSE);
     416  pBool = dcd ? &dcd->detailslongname : &detailslongname;
     417  AdjustCnrColVis(hwndCnr,
     418                  GetPString(IDS_LNAME),
     419                  *pBool ? hasLongNames : FALSE,
     420                  FALSE);
    427421  WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
    428422}
     
    532526      pfi->flData |= CFA_FIREADONLY;
    533527    pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
    534     pfi->pTitleData = (isCompCnr) ? GetPString(IDS_STATUS) :
    535       GetPString(IDS_SUBJ);
     528    pfi->pTitleData = isCompCnr ? GetPString(IDS_STATUS) :
     529                                  GetPString(IDS_SUBJ);
    536530    pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
    537531
     
    701695          szSubject[retlen + 1] = 0;
    702696          //chop_at_crnl(szSubject);
    703           bstrip(szSubject);
    704           pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
     697          bstrip(szSubject);
     698          pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
    705699          WinSetWindowText(hwndMLE, szSubject);
    706700          len = strlen(szSubject);
     
    752746          retlen = WinQueryWindowText(hwndMLE, sizeof(longname), longname);
    753747          longname[retlen + 1] = 0;
    754           //chop_at_crnl(longname);
    755           pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
     748          //chop_at_crnl(longname);
     749          pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
    756750          WinSetWindowText(hwndMLE, longname);
    757751          pci->pszFileName = xrealloc(pci->pszFileName, retlen + 1, pszSrcFile, __LINE__);
    758752          return (MRESULT) WriteLongName(pci->pszFileName, longname);
    759753        }
    760         else {
    761           WinQueryWindowText(hwndMLE, sizeof(szData), szData);
     754        else {
     755          WinQueryWindowText(hwndMLE, sizeof(szData), szData);
    762756          if (strchr(szData, '?') ||
    763757              strchr(szData, '*') || IsRoot(pci->pszFileName))
     
    774768                return FALSE;
    775769            if (DosQueryPathInfo(pci->pszFileName,
    776                                 FIL_QUERYFULLNAME, szData, sizeof(szData))){
    777               pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
    778               strcpy(szData, pci->pszFileName);
    779             }
     770                                FIL_QUERYFULLNAME, szData, sizeof(szData))){
     771              pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
     772              strcpy(szData, pci->pszFileName);
     773            }
    780774            WinSetWindowText(hwndMLE, szData);
    781775            if (strcmp(szData, testname)) {
     
    859853{
    860854  if (toggle) {
    861     *bool = (*bool) ? FALSE : TRUE;
     855    *bool = *bool ? FALSE : TRUE;
    862856    if (savename && *savename)
    863857      PrfWriteProfileData(fmprof, appname, savename, bool, sizeof(BOOL));
     
    943937    lastflags = ex.flags;
    944938    return runemf2(ex.flags, hwnd, path,
    945                    (*ex.environment) ? ex.environment : NULL, "%s", cl) != -1;
     939                   *ex.environment ? ex.environment : NULL,
     940                   "%s", cl) != -1;
    946941  }
    947942  else if (ret != 0)
     
    10451040  }
    10461041  if (bool)
    1047     *bool = (*bool) ? FALSE : TRUE;
     1042    *bool = *bool ? FALSE : TRUE;
    10481043  if (*s && bool)
    10491044    PrfWriteProfileData(fmprof, appname, s, bool, sizeof(BOOL));
     
    11181113}
    11191114
    1120 VOID FreeMallocedMem(VOID * mem)
    1121 {
    1122   /* for use by apps that don't use the DLLs runtime library */
    1123   free(mem);
    1124 }
    1125 
    11261115VOID FcloseFile(FILE * fp)
    11271116{
     
    11671156                "%s%s%s",
    11681157                info->title,
    1169                 (x < 20) ? "\tCtrl + " : NullStr,
    1170                 (x < 20 && x > 9) ? "Shift + " : NullStr);
     1158                x < 20 ? "\tCtrl + " : NullStr,
     1159                x < 20 && x > 9 ? "Shift + " : NullStr);
    11711160        if (x < 20)
    11721161          sprintf(&s[strlen(s)], "%d",
    1173                   (((x % 10) + 1) == 10) ? 0 : (x % 10) + 1);
     1162                  ((x % 10) + 1) == 10 ? 0 : (x % 10) + 1);
    11741163        mi.id = IDM_COMMANDSTART + x;
    1175         mi.afAttribute = (((info->flags & ONCE) != 0) ?
    1176                           MIA_CHECKED : 0) |
    1177           (((info->flags & PROMPT) != 0) ? MIA_FRAMED : 0);
     1164        mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) |
     1165                         (info->flags & PROMPT ? MIA_FRAMED : 0);
    11781166        mi.afStyle = MIS_TEXT;
    11791167        if (!(x % 24) && x && info->next)
     
    13781366PMINIRECORDCORE CurrentRecord(HWND hwndCnr)
    13791367{
    1380   SHORT attrib = (fSelectedAlways) ? CRA_SELECTED : CRA_CURSORED;
     1368  SHORT attrib = fSelectedAlways ? CRA_SELECTED : CRA_CURSORED;
    13811369  PMINIRECORDCORE pmi;
    13821370
     
    13901378      break;
    13911379  }
    1392   return ((INT) pmi == -1) ? NULL : pmi;
     1380  return ((INT)pmi == -1) ? NULL : pmi;
    13931381}
    13941382
     
    14821470      list[0] = filename;
    14831471      list[1] = NULL;
    1484       ExecOnList(hwnd, viewer, WINDOWED | SEPARATE |
    1485                  ((fViewChild) ? CHILD : 0), NULL, list, NULL);
     1472      ExecOnList(hwnd, viewer,
     1473                 WINDOWED | SEPARATE | (fViewChild ? CHILD : 0),
     1474                 NULL, list, NULL);
    14861475      return;
    14871476    }
     
    16081597      SetConditionalCascade(DirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
    16091598      SetConditionalCascade(DirMenu, IDM_DELETESUBMENU,
    1610                             (fDefaultDeletePerm) ? IDM_PERMDELETE :
    1611                             IDM_DELETE);
     1599                            fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
    16121600      SetConditionalCascade(DirMenu, IDM_MISCSUBMENU, IDM_SIZES);
    16131601      SetConditionalCascade(DirMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
     
    16531641      SetConditionalCascade(FileMenu, IDM_COLLECTMENU, IDM_COLLECT);
    16541642      SetConditionalCascade(FileMenu, IDM_DELETESUBMENU,
    1655                             (fDefaultDeletePerm) ? IDM_PERMDELETE :
    1656                             IDM_DELETE);
     1643                            fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
    16571644      SetConditionalCascade(FileMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
    16581645      SetConditionalCascade(FileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
     
    16991686      SetConditionalCascade(CollectorFileMenu, IDM_EDITSUBMENU, IDM_EDIT);
    17001687      SetConditionalCascade(CollectorFileMenu, IDM_DELETESUBMENU,
    1701                             (fDefaultDeletePerm) ? IDM_PERMDELETE :
    1702                             IDM_DELETE);
     1688                            fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
    17031689      SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU,
    17041690                            IDM_OPENDEFAULT);
     
    17221708      SetConditionalCascade(CollectorDirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
    17231709      SetConditionalCascade(CollectorDirMenu, IDM_DELETESUBMENU,
    1724                             (fDefaultDeletePerm) ? IDM_PERMDELETE :
    1725                             IDM_DELETE);
     1710                            fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
    17261711      SetConditionalCascade(CollectorDirMenu, IDM_MISCSUBMENU, IDM_SIZES);
    17271712      SetConditionalCascade(CollectorDirMenu, IDM_OPENSUBMENU,
     
    18951880  if (s) {
    18961881    sprintf(s, "S:%s%s",
    1897             (sortflags & SORT_REVERSE) ? "^" : NullStr,
    1898             (sortflags & SORT_FIRSTEXTENSION) ? GetPString(IDS_FIRSTX) :
    1899             (sortflags & SORT_LASTEXTENSION) ? GetPString(IDS_LASTX) :
    1900             (sortflags & SORT_SIZE) ? "Size" :
    1901             (sortflags & SORT_EASIZE) ? (archive ==
    1902                                          0) ? GetPString(IDS_EASIZE) :
    1903             GetPString(IDS_CSIZE) : (sortflags & SORT_LWDATE) ? (archive
    1904                                                                  ==
    1905                                                                  0) ?
    1906             GetPString(IDS_LWDATE) : GetPString(IDS_DATE) : (sortflags &
    1907                                                              SORT_LADATE)
    1908             ? GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
    1909             GetPString(IDS_CRDATE) : (sortflags & SORT_PATHNAME) ?
    1910             GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
    1911             GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
    1912             GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
     1882            sortflags & SORT_REVERSE ? "^" : NullStr,
     1883            (sortflags & SORT_FIRSTEXTENSION) ?
     1884              GetPString(IDS_FIRSTX) : (sortflags & SORT_LASTEXTENSION) ?
     1885                GetPString(IDS_LASTX) : (sortflags & SORT_SIZE) ?
     1886                  "Size" : (sortflags & SORT_EASIZE) ?
     1887                    (archive == 0) ?
     1888                      GetPString(IDS_EASIZE) : GetPString(IDS_CSIZE) :
     1889                    (sortflags & SORT_LWDATE) ?
     1890                      (archive == 0) ?
     1891                        GetPString(IDS_LWDATE) : GetPString(IDS_DATE) :
     1892                        (sortflags & SORT_LADATE) ?
     1893                          GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
     1894                            GetPString(IDS_CRDATE) :
     1895                            (sortflags & SORT_PATHNAME) ?
     1896                              GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
     1897                                GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
     1898                                  GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
    19131899    WinSetWindowText(hwnd, s);
    19141900    free(s);
     
    20492035    register INT i;
    20502036
    2051     hwndTopFrame = (hwndTop) ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND) 0;
     2037    hwndTopFrame = hwndTop ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND)0;
    20522038    /* Get the switch list information */
    20532039    x = 0;
     
    21692155  return ret;
    21702156}
     2157
     2158#pragma alloc_text(MAINWND5,SetSysMenu)
     2159#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
     2160#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
     2161#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
     2162#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
     2163#pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
     2164#pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
     2165#pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
     2166#pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
     2167#pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
     2168#pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches)
     2169#pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
     2170#pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
     2171#pragma alloc_text(MISC_LIBPATH,LoadLibPath)
     2172#pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
     2173
  • trunk/dll/objcnr.c

    r783 r787  
    2020  13 Aug 07 SHL Avoid realloc - not needed; sanitize code
    2121  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
     22  14 Aug 07 SHL Revert ProcessDir DosSleep to 0
    2223
    2324***********************************************************************/
     
    185186        pffbFile = (PFILEFINDBUF3)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
    186187      } // for
    187       DosSleep(1);
     188      DosSleep(0);                      // Let's others at same priority get some work done
    188189      if (*stopflag)
    189190        break;
  • trunk/dll/seeall.c

    r783 r787  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2006 Steven H. Levine
     9  Copyright (c) 2001, 2007 Steven H. Levine
    1010
    1111  16 Oct 02 SHL Handle large partitions
     
    2727  13 Aug 07 SHL Sync code with other FilesToGet usage
    2828  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
     29  14 Aug 07 SHL Revert to DosSleep(0) to speed up inner loops
     30  14 Aug 07 SHL Drop afFilesToGet
    2931
    3032***********************************************************************/
     
    108110  ULONG affiles;
    109111  ULONG afalloc;
    110   ULONG afFilesToGet;
    111112  ULONG longest;
    112113  ULONG longestw;
     
    433434                         FM3ModHandle,
    434435                         ASEL_FRAME, (PVOID) & ad.info) || !ad.info) {
    435             /* we blew it */
     436            // we blew it
    436437            FreeList(list);
    437438            break;
     
    441442              !ad.info->createwdirs &&
    442443              !ad.info->movewdirs && !ad.info->createrecurse) {
     444            // 14 Aug 07 SHL fixme to tell user why we failed
    443445            FreeList(list);
    444446            break;
     
    448450            break;
    449451          }
    450           /* build the sucker */
     452          // Build archiver command line
    451453          strcpy(szBuffer, ad.command);
    452454          strcat(szBuffer, " ");
     
    489491                      HWND_DESKTOP, NULL, NULL,
    490492                      "%s", szBuffer);
    491               DosSleep(1);
     493              DosSleep(1);              // Let archiver get started
    492494              *p = 0;
    493495            }
    494496            strcat(szBuffer, " ");
    495           }
     497          } // while
    496498          AddToList(ad.arcname, &files, &numfiles, &numalloc);
    497499        }
     
    10621064        sprintf(message,
    10631065                GetPString(IDS_OPSCOMPLETETEXT),
    1064                 (SHORT1FROMMP(mp1) == IDM_MOVE) ?
    1065                 GetPString(IDS_MOVETEXT) :
    1066                 (SHORT1FROMMP(mp1) == IDM_COPY) ?
    1067                 GetPString(IDS_COPYTEXT) :
    1068                 (SHORT1FROMMP(mp1) == IDM_WPSMOVE) ?
    1069                 GetPString(IDS_WPSMOVETEXT) :
    1070                 (SHORT1FROMMP(mp1) == IDM_WPSCOPY) ?
    1071                 GetPString(IDS_WPSCOPYTEXT) :
    1072                 GetPString(IDS_RENAMETEXT),
     1066                SHORT1FROMMP(mp1) == IDM_MOVE ?
     1067                  GetPString(IDS_MOVETEXT) :
     1068                  SHORT1FROMMP(mp1) == IDM_COPY ?
     1069                    GetPString(IDS_COPYTEXT) :
     1070                    SHORT1FROMMP(mp1) == IDM_WPSMOVE ?
     1071                      GetPString(IDS_WPSMOVETEXT) :
     1072                      SHORT1FROMMP(mp1) == IDM_WPSCOPY ?
     1073                        GetPString(IDS_WPSCOPYTEXT) :
     1074                        GetPString(IDS_RENAMETEXT),
    10731075                &"s"[x == 1],
    1074                 (SHORT1FROMMP(mp1) == IDM_MOVE ||
    1075                  SHORT1FROMMP(mp1) == IDM_COPY ||
    1076                  SHORT1FROMMP(mp1) == IDM_WPSMOVE ||
    1077                  SHORT1FROMMP(mp1) == IDM_WPSCOPY) ?
    1078                 GetPString(IDS_TOTEXT) :
    1079                 NullStr,
    1080                 (SHORT1FROMMP(mp1) == IDM_MOVE ||
    1081                  SHORT1FROMMP(mp1) == IDM_COPY ||
    1082                  SHORT1FROMMP(mp1) == IDM_WPSMOVE ||
    1083                  SHORT1FROMMP(mp1) == IDM_WPSCOPY) ?
    1084                 path :
    1085                 NullStr,
    1086                 (x != 1) ? GetPString(IDS_ARETEXT) : GetPString(IDS_ISTEXT));
     1076                SHORT1FROMMP(mp1) == IDM_MOVE ||
     1077                SHORT1FROMMP(mp1) == IDM_COPY ||
     1078                SHORT1FROMMP(mp1) == IDM_WPSMOVE ||
     1079                SHORT1FROMMP(mp1) == IDM_WPSCOPY ?
     1080                  GetPString(IDS_TOTEXT) : NullStr,
     1081                SHORT1FROMMP(mp1) == IDM_MOVE ||
     1082                SHORT1FROMMP(mp1) == IDM_COPY ||
     1083                SHORT1FROMMP(mp1) == IDM_WPSMOVE ||
     1084                SHORT1FROMMP(mp1) == IDM_WPSCOPY ?
     1085                  path : NullStr,
     1086                x != 1 ? GetPString(IDS_ARETEXT) : GetPString(IDS_ISTEXT));
    10871087        WinSetWindowText(WinWindowFromID(hwndFrame, SEEALL_STATUS), message);
    10881088        if (toupper(*path) < 'C')
    10891089          DosBeep(1000, 25);
    1090         DosSleep(16);//05 Aug 07 GKY 33
     1090        DosSleep(16);                   // 05 Aug 07 GKY 33
    10911091        break;
    10921092
     
    16231623}
    16241624
    1625 VOID FindDupes(VOID * args)
     1625VOID FindDupesThread(VOID * args)
    16261626{
    16271627  register ULONG x, z;
     
    16541654              }
    16551655              for (z = 0; z < ad->affiles && !ad->stopflag; z++) {
    1656                 if (x != z
    1657                     && !(ad->afhead[z].flags & (AF_DUPE | AF_FILTERED))) {
     1656                if (x != z &&
     1657                    !(ad->afhead[z].flags & (AF_DUPE | AF_FILTERED)))
     1658                {
    16581659                  if (ad->dupeflags & DP_SIZES) {
    16591660                    if (ad->afhead[x].cbFile != ad->afhead[z].cbFile)
     
    17131714                        goto SkipNonDupe;
    17141715                    }
    1715                     DosSleep(1);
     1716                    DosSleep(0);
    17161717                  }
    17171718                  ad->afhead[x].flags |= AF_DUPE;
     
    17201721                  ;
    17211722                }
    1722               }
    1723               DosSleep(1);
    1724             }
    1725           }
     1723              } // for
     1724              DosSleep(0);
     1725            }
     1726          } // for
    17261727          for (x = 0; x < ad->affiles && !ad->stopflag; x++) {
    17271728            if (!(ad->afhead[x].flags & AF_DUPE))
     
    17351736    PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    17361737    DosReleaseMutexSem(ad->hmtxScan);
    1737   }                                     // if got sem
     1738  } // if got sem
    17381739  if (hmq2) {
    17391740    PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
     
    18981899    return;
    18991900
    1900   ulFindMax = ad->afFilesToGet;
     1901  ulFindMax = FilesToGet;
    19011902  if (fRemoteBug && isalpha(*pathname) && pathname[1] == ':' &&
    19021903      pathname[2] == '\\' &&
     
    20252026        WinCancelShutdown(hmq2, TRUE);
    20262027        IncrThreadUsage();
    2027         ad->afFilesToGet = FilesToGet;
    20282028        if (!*ad->szFindPath) {
    20292029          DosError(FERR_DISABLEHARDERR);
     
    38353835                                            MPFROM2SHORT(pAD->dupeflags, 0));
    38363836        if (pAD->dupeflags) {
    3837           if (_beginthread(FindDupes, NULL, 65536, (PVOID) hwnd) == -1)
     3837          if (_beginthread(FindDupesThread, NULL, 65536, (PVOID) hwnd) == -1)
    38383838            Runtime_Error(pszSrcFile, __LINE__,
    38393839                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
     
    42944294#pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark)
    42954295#pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList)
    4296 #pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupes,DupeDlgProc)
     4296#pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupesThread,DupeDlgProc)
    42974297#pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc)
    42984298#pragma alloc_text(SEEALL3,StartSeeAll)
  • trunk/dll/select.c

    r769 r787  
    2525               not use pszFileName since CNRITEM_EXISTS set implies
    2626               pszFileName not null
     27  14 Aug 07 SHL Revert ExpandAll DosSleep to 0
    2728
    2829***********************************************************************/
     
    251252              else
    252253                break;
    253             }
     254            } // while
    254255            fclose(inputFile);
    255256          }
     
    354355              else
    355356                break;
    356             }
     357            } // while
    357358            fclose(inputFile);
    358359          }
     
    545546                                MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    546547    if (pci)
    547       DosSleep(1);
     548      DosSleep(0);
    548549    while (pci && (INT)pci != -1) {
    549550      ExpandAll(hwndCnr, expand, pci);
     
    552553    }
    553554  }
    554   DosSleep(1);
     555  DosSleep(0);
    555556}
    556557
     
    638639                                   MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    639640    if (!(x % 500))
    640       DosSleep(1L);
     641      DosSleep(1);
    641642    // else if (!(x % 50))
    642     //  DosSleep(0L);
     643    //  DosSleep(0);
    643644  } // while
    644645
     
    668669                                   MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    669670    if (!(x % 500))
    670       DosSleep(1L);
     671      DosSleep(1);
    671672    // else if (!(x % 50))
    672     //  DosSleep(0L);
     673    //  DosSleep(0);
    673674  } // while
    674675
     
    737738      }
    738739      if (!(x % 500))
    739         DosSleep(1L);
     740        DosSleep(1);
    740741      // else if (!(x % 50))
    741       //        DosSleep(0L);
     742      //        DosSleep(0);
    742743    } // for
    743744  } // if reset
     
    760761      }
    761762      if (!(x % 500))
    762         DosSleep(1L);
     763        DosSleep(1);
    763764      // else if (!(x % 50))
    764       //        DosSleep(0L);
     765      //        DosSleep(0);
    765766    } // for
    766767    break;
     
    780781      }
    781782      if (!(x % 500))
    782         DosSleep(1L);
     783        DosSleep(1);
    783784      // else if (!(x % 50))
    784       //        DosSleep(0L);
     785      //        DosSleep(0);
    785786    }
    786787    break;
     
    866867      }
    867868      if (!(x % 500))
    868         DosSleep(1L);
     869        DosSleep(1);
    869870      // else if (!(x % 50))
    870       //        DosSleep(0L);
     871      //        DosSleep(0);
    871872    } // for
    872873    break;
     
    884885      }
    885886      if (!(x % 500))
    886         DosSleep(1L);
     887        DosSleep(1);
    887888      // else if (!(x % 50))
    888       //        DosSleep(0L);
     889      //        DosSleep(0);
    889890    }
    890891    break;
     
    906907      }
    907908      if (!(x % 500))
    908         DosSleep(1L);
     909        DosSleep(1);
    909910      // else if (!(x % 50))
    910       //        DosSleep(0L);
     911      //        DosSleep(0);
    911912    }
    912913    break;
     
    927928      }
    928929      if (!(x % 500))
    929         DosSleep(1L);
     930        DosSleep(1);
    930931      // else if (!(x % 50))
    931       //        DosSleep(0L);
     932      //        DosSleep(0);
    932933    }
    933934    break;
     
    948949      }
    949950      if (!(x % 500))
    950         DosSleep(1L);
     951        DosSleep(1);
    951952      // else if (!(x % 50))
    952       //        DosSleep(0L);
     953      //        DosSleep(0);
    953954    }
    954955    break;
     
    969970      }
    970971      if (!(x % 500))
    971         DosSleep(1L);
     972        DosSleep(1);
    972973      // else if (!(x % 50))
    973       //        DosSleep(0L);
     974      //        DosSleep(0);
    974975    }
    975976    break;
     
    990991      }
    991992      if (!(x % 500))
    992         DosSleep(1L);
     993        DosSleep(1);
    993994      // else if (!(x % 50))
    994       //        DosSleep(0L);
     995      //        DosSleep(0);
    995996    }
    996997    break;
     
    10081009      }
    10091010      if (!(x % 500))
    1010         DosSleep(1L);
     1011        DosSleep(1);
    10111012      // else if (!(x % 50))
    1012       //        DosSleep(0L);
     1013      //        DosSleep(0);
    10131014    }
    10141015    break;
     
    10291030      }
    10301031      if (!(x % 500))
    1031         DosSleep(1L);
     1032        DosSleep(1);
    10321033      // else if (!(x % 50))
    1033       //        DosSleep(0L);
     1034      //        DosSleep(0);
    10341035    }
    10351036    break;
     
    10501051      }
    10511052      if (!(x % 500))
    1052         DosSleep(1L);
     1053        DosSleep(1);
    10531054      // else if (!(x % 50))
    1054       //        DosSleep(0L);
     1055      //        DosSleep(0);
    10551056    }
    10561057    break;
     
    10711072      }
    10721073      if (!(x % 500))
    1073         DosSleep(1L);
     1074        DosSleep(1);
    10741075      // else if (!(x % 50))
    1075       //        DosSleep(0L);
     1076      //        DosSleep(0);
    10761077    }
    10771078    break;
     
    10921093      }
    10931094      if (!(x % 500))
    1094         DosSleep(1L);
     1095        DosSleep(1);
    10951096      // else if (!(x % 50))
    1096       //        DosSleep(0L);
     1097      //        DosSleep(0);
    10971098    }
    10981099    break;
     
    11131114      }
    11141115      if (!(x % 500))
    1115         DosSleep(1L);
     1116        DosSleep(1);
    11161117      // else if (!(x % 50))
    1117       //        DosSleep(0L);
     1118      //        DosSleep(0);
    11181119    }
    11191120    break;
  • trunk/dll/treecnr.c

    r775 r787  
    1919  15 Aug 06 SHL Rework SetMask args
    2020  31 Aug 06 JS  Add more partitioning menu items
    21   22 OCT 06 GKY Add NDFS32 support
     21  22 Oct 06 GKY Add NDFS32 support
    2222  29 Dec 06 GKY Fixed menu gray out for remote drives (added variable "remote")
    2323  29 Dec 06 GKY Enabled edit of drive flags on "not ready" drives
     
    3636  02 Aug 07 SHL Sync with CNRITEM mods
    3737  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
     38  14 Aug 07 SHL Revert ShowTreeRec DosSleep to 0
     39  14 Aug 07 SHL Optimze ShowTreeRec collapse - was really slow
    3840
    3941***********************************************************************/
     
    143145}
    144146
    145 VOID ShowTreeRec(HWND hwndCnr, CHAR * dirname, BOOL collapsefirst,
     147VOID ShowTreeRec(HWND hwndCnr,
     148                 CHAR *dirname,
     149                 BOOL collapsefirst,
    146150                 BOOL maketop)
    147151{
     
    153157  CHAR szDir[CCHMAXPATH], *p;
    154158
    155   /* is it already the current record? */
     159  // already positioned to requested record?
    156160  pci = WinSendMsg(hwndCnr,
    157161                   CM_QUERYRECORDEMPHASIS,
    158162                   MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
    159163  if (pci && (INT) pci != -1 && !stricmp(pci->pszFileName, dirname)) {
    160     quickbail = TRUE;
    161     goto MakeTop;                       /* skip lookup bullsh*t */
     164    // DbgMsg(pszSrcFile, __LINE__, "already at %s collapse %u maketop %u", dirname, collapsefirst, maketop);   // 14 Aug 07 SHL fixme
     165    quickbail = TRUE;                   // Bypass repositioning
     166    goto MakeTop;
    162167  }
    163168  WinEnableWindowUpdate(hwndCnr, FALSE);
     169  DbgMsg(pszSrcFile, __LINE__, "finding %s collapse %u maketop %u", dirname, collapsefirst, maketop);   // 14 Aug 07 SHL fixme
    164170  pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
    165171  if (!pci || (INT) pci == -1) {
     
    168174    szDir[2] = '\\';
    169175    szDir[3] = 0;
    170     p = szDir + 3;
     176    p = szDir + 3;                      // Point after root backslash
    171177    for (;;) {
    172178      pciP = FindCnrRecord(hwndCnr, szDir, NULL, TRUE, FALSE, TRUE);
    173179      if (pciP && (INT) pciP != -1) {
    174180        if (!stricmp(dirname, pciP->pszFileName))
    175           break;
    176         if (!(pciP->rc.flRecordAttr & CRA_EXPANDED))
     181          break;                        // Found it
     182        if (~pciP->rc.flRecordAttr & CRA_EXPANDED)
    177183          WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
    178184        strcpy(szDir, dirname);
    179185        if (p - szDir >= strlen(szDir))
    180           break;
     186          break;                        // Not root dir
    181187        p = strchr(p, '\\');
    182188        if (p) {
    183           *p = 0;
     189          *p = 0;                       // fixme?
    184190          p++;
    185191        }
     
    189195      else
    190196        break;
    191       DosSleep(1);
    192     }
     197      DosSleep(0);
     198    } // for
    193199    pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
    194200  }
     201  DbgMsg(pszSrcFile, __LINE__, "found");        // 14 Aug 07 SHL fixme
    195202  if (pci && (INT) pci != -1) {
    196     if (!(pci->rc.flRecordAttr & CRA_CURSORED)) {
     203    if (~pci->rc.flRecordAttr & CRA_CURSORED) {
    197204      if (collapsefirst) {
    198         /* collapse top level of all branches */
     205        DbgMsg(pszSrcFile, __LINE__, "collapsing");     // 14 Aug 07 SHL fixme
    199206        pciP = WinSendMsg(hwndCnr,
    200207                          CM_QUERYRECORD,
    201208                          MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    202209        while (pciP && (INT) pciP != -1) {
    203           if (toupper(*pciP->pszFileName) == toupper(*dirname))
    204             /* collapse all levels if branch is our drive */
    205             ExpandAll(hwndCnr, FALSE, pciP);
    206           else if (pciP->rc.flRecordAttr & CRA_EXPANDED)
     210#if 1
     211          if (pciP->rc.flRecordAttr & CRA_EXPANDED) {
     212            // collapse top level of all branches
    207213            WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
     214          }
     215#else // fixme to be gone
     216          if (toupper(*pciP->pszFileName) == toupper(*dirname)) {
     217            // collapse all levels if branch is our drive
     218            if (pciP->rc.flRecordAttr & CRA_EXPANDED)
     219              ExpandAll(hwndCnr, FALSE, pciP);
     220          }
     221          else if (pciP->rc.flRecordAttr & CRA_EXPANDED) {
     222            // collapse top level of all branches
     223            WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
     224          }
     225#endif
    208226          pciP = WinSendMsg(hwndCnr,
    209227                            CM_QUERYRECORD,
    210228                            MPFROMP(pciP),
    211229                            MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    212         }
     230        } // while
    213231      }
    214232      /* expand all parent branches */
     233      DbgMsg(pszSrcFile, __LINE__, "expanding parents");        // 14 Aug 07 SHL fixme
    215234      pciToSelect = pci;
    216235      for (;;) {
     
    226245        else
    227246          break;
    228         DosSleep(1);
    229       }
     247        DosSleep(1);                    // Let GUI update
     248      } // for
    230249    }
    231250    /* make record visible */
    232251  MakeTop:
     252    DbgMsg(pszSrcFile, __LINE__, "moving into view");   // 14 Aug 07 SHL fixme
    233253    pciToSelect = pci;
    234254    if (pciToSelect && (INT) pciToSelect != -1) {
    235       if (fTopDir || maketop)
     255      if (fTopDir || maketop) {
    236256        ShowCnrRecord(hwndCnr, (PMINIRECORDCORE) pciToSelect);
    237       if (fSwitchTreeExpand && !(pciToSelect->rc.flRecordAttr & CRA_EXPANDED))
     257      }
     258      if (fSwitchTreeExpand && ~pciToSelect->rc.flRecordAttr & CRA_EXPANDED) {
     259        DbgMsg(pszSrcFile, __LINE__, "expanding current");      // 14 Aug 07 SHL fixme
    238260        WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciToSelect), MPVOID);
    239       if (quickbail) {
    240         WinEnableWindowUpdate(hwndCnr, TRUE);
    241         return;
    242       }
    243       WinSendMsg(hwndCnr,
    244                  CM_SETRECORDEMPHASIS,
    245                  MPFROMP(pciToSelect),
    246                  MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED));
     261        DbgMsg(pszSrcFile, __LINE__, "expanded");       // 14 Aug 07 SHL fixme
     262      }
     263      if (!quickbail) {
     264        WinSendMsg(hwndCnr,
     265                   CM_SETRECORDEMPHASIS,
     266                   MPFROMP(pciToSelect),
     267                   MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED));
     268      }
    247269    }
    248270  }
     271  DbgMsg(pszSrcFile, __LINE__, "done"); // 14 Aug 07 SHL fixme
    249272  WinEnableWindowUpdate(hwndCnr, TRUE);
     273  DosSleep(1);                  // Let GUI update
    250274}
    251275
     
    517541
    518542  case UM_SHOWME:
     543    // DbgMsg(pszSrcFile, __LINE__, "UM_SHOWME mp1 %p mp2 %p", mp1, mp2);       // 14 Aug 07 SHL fixme
    519544    if (mp1) {
    520545      dcd = INSTDATA(hwnd);
     546      // DbgMsg(pszSrcFile, __LINE__, "UM_SHOWME dcd %p", dcd); // 14 Aug 07 SHL fixme
    521547      if (dcd) {
    522548        BOOL tempsusp, tempfollow, temptop;
  • trunk/dll/walkem.c

    r766 r787  
    1818  22 Mar 07 GKY Use QWL_USER
    1919  20 Apr 07 SHL Avoid spurious add_udir error reports
     20  16 Aug 07 SHL Update add_setups for ticket# 109
    2021
    2122***********************************************************************/
     
    2425#define INCL_DOS
    2526#define INCL_DOSERRORS
     27#define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX
    2628#include <os2.h>
    2729
     
    6264static ULONG WalkFontSize = sizeof(WalkFont);
    6365
     66/**
     67 * States names management
     68 */
     69
     70static BOOL fSetupsLoaded;
     71static LINKDIRS *pFirstSetup;
     72static const PSZ pszLastSetups = "LastSetups";
     73// // 18 Aug 07 SHL fixme to stop supporting old style 1 year from now?
     74static const ULONG ulOldSetupsBytes = 100 * 13; // Prior to 3.0.7
     75
     76/**
     77 * Fill States drop down list with known state names
     78 */
     79
     80VOID fill_setups_list(VOID)
     81{
     82  WinSendMsg(hwndStatelist, LM_DELETEALL, MPVOID, MPVOID);
     83  if (fUserComboBox) {
     84    LINKDIRS *pld;
     85    load_setups();
     86    for (pld = pFirstSetup; pld; pld = pld->next) {
     87      // DbgMsg(pszSrcFile, __LINE__, "Inserted %s", pld->path);
     88      WinSendMsg(hwndStatelist,
     89                 LM_INSERTITEM,
     90                 MPFROM2SHORT(LIT_SORTASCENDING, 0),
     91                 MPFROMP(pld->path));
     92    }
     93    WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     94  }
     95}
     96
     97/**
     98 * Lookup setup and do requested action
     99 * @param - action, Support old/new style storage method
     100 * @return 1 if found and action OK, 0 if not found and action OK, -1 if error during action
     101 */
     102
     103#define LS_FIND         0
     104#define LS_ADD          1
     105#define LS_DELETE       2
     106
     107static INT lookup_setup(PSZ name, UINT action)
     108{
     109  LINKDIRS *pld;
     110  LINKDIRS *pldLast = NULL;
     111
     112  if (!name || !*name) {
     113    Runtime_Error(pszSrcFile, __LINE__, "no data");
     114    return -1;
     115  }
     116
     117  load_setups();
     118
     119  for (pld = pFirstSetup; pld; pld = pld->next) {
     120    if (!stricmp(pld->path, name)) {
     121      if (action == LS_DELETE) {
     122        if (pldLast)
     123          pldLast->next = pld->next;
     124        else
     125          pFirstSetup = pld->next;
     126        xfree(pld->path);
     127        xfree(pld);
     128      }
     129      return 1;                         // Found or added
     130    }
     131    pldLast = pld;                      // In case deleting
     132  } // for
     133
     134  // Not found
     135  if (action == LS_ADD) {
     136    pld = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
     137    if (!pld)
     138      return -1;
     139    pld->path = xstrdup(name, pszSrcFile, __LINE__);
     140    if (!pld->path) {
     141      xfree(pld);
     142      return -1;
     143    }
     144    // Insert at front of list - drop down will sort
     145    pld->next = pFirstSetup;
     146    pFirstSetup = pld;
     147    return 0;
     148  }
     149
     150  return FALSE;                         // Not found
     151}
     152
     153/**
     154 * Load state names from ini
     155 * Support old/new style storage method
     156 */
     157
    64158VOID load_setups(VOID)
    65159{
    66   ULONG len = sizeof(lastsetups);
    67 
    68   memset(lastsetups, 0, len);
    69   PrfQueryProfileData(fmprof, FM3Str, "LastSetups", lastsetups, &len);
    70   len = sizeof(INT);
    71   lastsetup = 0;
    72   PrfQueryProfileData(fmprof, FM3Str, "LastSetup", &lastsetup, &len);
    73   loadedsetups = TRUE;
     160  ULONG ulDataBytes;
     161  ULONG l;
     162  PSZ pszBuf;
     163  PSZ psz;
     164  LINKDIRS *pld;
     165
     166  if (fSetupsLoaded)
     167    return;
     168
     169  if (!PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes)) {
     170    // fixme to use generic hab
     171    ERRORID eid = WinGetLastError((HAB)0);
     172    if ((eid & 0xffff) != PMERR_NOT_IN_IDX) {
     173      Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileSize returned %u", eid);
     174      return;
     175    }
     176  }
     177
     178  if (ulDataBytes == 0) {
     179    Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileSize reported 0 bytes");
     180    return;
     181  }
     182
     183  pszBuf = xmalloc(ulDataBytes + 1, pszSrcFile, __LINE__);      // One extra for end marker
     184  if (!pszBuf)
     185    return;
     186  l = ulDataBytes;
     187  if (!PrfQueryProfileData(fmprof, FM3Str, pszLastSetups, pszBuf, &l)) {
     188    Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, "PrfQueryProfileData");
     189    xfree(pszBuf);
     190    return;
     191  }
     192
     193  if (ulDataBytes != l) {
     194    Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileData reported %u expected %u", l, ulDataBytes);
     195    xfree(pszBuf);
     196    return;
     197  }
     198
     199  *(pszBuf + ulDataBytes) = 0;                  // Insert end marker
     200
     201  psz = pszBuf;
     202  if (!*psz && ulDataBytes == ulOldSetupsBytes)
     203    psz += 13;                  // Rarely used 1st fixed width entry prior to 3.0.7
     204
     205  while (*psz) {
     206    pld = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
     207    if (!pld) {
     208      xfree(pszBuf);
     209      return;
     210    }
     211    pld->path = xstrdup(psz, pszSrcFile, __LINE__);
     212    if (!pld->path) {
     213      xfree(pszBuf);
     214      xfree(pld);
     215      return;
     216    }
     217
     218    // Insert at front of list - drop down will sort
     219    pld->next = pFirstSetup;
     220    pFirstSetup = pld;
     221    // DbgMsg(pszSrcFile, __LINE__, "Inserted %s", pld->path);
     222
     223    if (ulDataBytes == ulOldSetupsBytes)
     224      psz += 13;                        // Buffers fixed width prior to 3.0.7
     225    else
     226      psz += strlen(psz) + 1;
     227  } // while
     228
     229  xfree(pszBuf);
     230
     231  fSetupsLoaded = TRUE;
    74232}
    75233
    76234VOID save_setups(VOID)
    77235{
    78   if (!loadedsetups)
     236  ULONG ulBufBytes;
     237  ULONG ulFillBytes;
     238  ULONG l;
     239  PSZ pszBuf;
     240  PSZ psz;
     241  LINKDIRS *pld;
     242
     243  if (!fSetupsLoaded)
    79244    return;
    80   PrfWriteProfileData(fmprof,
    81                       FM3Str,
    82                       "LastSetups", lastsetups, (ULONG) sizeof(lastsetups));
    83   PrfWriteProfileData(fmprof,
    84                       FM3Str, "LastSetup", &lastsetup, (ULONG) sizeof(INT));
    85 }
    86 
    87 BOOL add_setup(CHAR * name)
    88 {
    89   INT x;
    90 
    91   if (!name || !*name)
    92     return FALSE;
    93   if (!loadedsetups)
    94     load_setups();
    95   for (x = 0; x < MAXNUMSETUPS; x++) {
    96     if (!stricmp(lastsetups[x], name))
    97       return FALSE;
    98   }
    99   lastsetup++;
    100   if (lastsetup >= MAXNUMSETUPS)
    101     lastsetup = 0;
    102   strcpy(lastsetups[lastsetup], name);
    103   return TRUE;
    104 }
    105 
    106 BOOL remove_setup(CHAR * name)
    107 {
    108   INT x, y;
    109 
    110   if (!name || !*name)
    111     return FALSE;
    112   if (!loadedsetups)
    113     load_setups();
    114   for (x = 0; x < MAXNUMSETUPS; x++) {
    115     if (!stricmp(lastsetups[x], name)) {
    116       *lastsetups[x] = 0;
    117       for (y = x + 1; y < MAXNUMSETUPS; y++)
    118         strcpy(lastsetups[y - 1], lastsetups[y]);
    119       *lastsetups[MAXNUMSETUPS - 1] = 0;
    120       if (lastsetup >= x)
    121         lastsetup--;
    122       return TRUE;
    123     }
    124   }
    125   return FALSE;
     245
     246  ulBufBytes = 0;
     247  for (pld = pFirstSetup; pld; pld = pld->next) {
     248    ulBufBytes += strlen(pld->path) + 1;
     249  } // for
     250
     251  if (!ulBufBytes)
     252    pszBuf = NULL;
     253  else {
     254    // Ensure different than size prior to 3.0.7
     255    ulFillBytes = ulBufBytes == ulOldSetupsBytes ? 1 : 0;
     256    pszBuf = xmalloc(ulBufBytes + ulFillBytes, pszSrcFile, __LINE__);
     257    if (!pszBuf)
     258      return;
     259
     260    psz = pszBuf;
     261    for (pld = pFirstSetup; pld; pld = pld->next) {
     262      l = strlen(pld->path) + 1;
     263      memcpy(psz, pld->path, l);
     264      psz += l;
     265    } // for
     266    if (ulFillBytes)
     267      *psz = 0;
     268  }
     269
     270  if (!PrfWriteProfileData(fmprof,
     271                           FM3Str,
     272                            pszLastSetups, pszBuf, ulBufBytes)) {
     273    // Win_Error(pszSrcFile, __LINE__, HWND_DESKTOP, HWND_DESKTOP, "PrfWriteProfileData");
     274    ERRORID eid = WinGetLastError((HAB)0);
     275    if ((eid & 0xffff) != PMERR_NOT_IN_IDX)
     276      Runtime_Error(pszSrcFile, __LINE__, "PrfWriteProfileData returned %u", eid);
     277  }
     278
     279  // Delete obsolete INI entry
     280  PrfWriteProfileData(fmprof, FM3Str, "LastSetup", NULL, 0);
     281}
     282
     283/**
     284 * Add named state to setups list
     285 * @return same as lookup_setup
     286 */
     287
     288INT add_setup(PSZ name)
     289{
     290  return lookup_setup(name, LS_ADD);
     291}
     292
     293/**
     294 * Delete named state from setups list
     295 * @return same as lookup_setup
     296 */
     297
     298INT remove_setup(PSZ name)
     299{
     300  return lookup_setup(name, LS_DELETE);
    126301}
    127302
Note: See TracChangeset for help on using the changeset viewer.