Changeset 212 for trunk/dll/arccnrs.c


Ignore:
Timestamp:
Jun 18, 2005, 5:50:20 AM (20 years ago)
Author:
root
Message:

Drop obsolete, localize
Correct last sort logic
Use QWL_USER

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r172 r212  
    1515  25 May 05 SHL Rename comnam to szCommonName and fix typo
    1616  25 May 05 SHL Use ULONGLONG and CommaFmtULL
     17  05 Jun 05 SHL Drop obsolete, localize
     18  05 Jun 05 SHL Correct last sort logic
     19  05 Jun 05 SHL Use QWL_USER
    1720
    1821***********************************************************************/
     
    4649#pragma alloc_text(STARTUP,StartArcCnr)
    4750
    48 INT arcsortFlags = 0;
    49 
    50 
    51 MRESULT EXPENTRY ArcErrProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     51static INT DefArcSortFlags;
     52
     53static MRESULT EXPENTRY ArcErrProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
    5254{
    5355  ARCDUMP *ad;
     
    138140
    139141
    140 SHORT APIENTRY ArcSort (PMINIRECORDCORE p1,PMINIRECORDCORE p2,PVOID pStorage)
     142static SHORT APIENTRY ArcSort (PMINIRECORDCORE pmrc1,PMINIRECORDCORE pmrc2,PVOID pStorage)
    141143{
    142   PARCITEM    p = (PARCITEM)p1,pp = (PARCITEM)p2;
    143   DIRCNRDATA *dcd = (DIRCNRDATA *)pStorage;
     144  PARCITEM    pai1 = (PARCITEM)pmrc2;
     145  PARCITEM    pai2 = (PARCITEM)pmrc2;
     146  DIRCNRDATA *pdcd = (DIRCNRDATA *)pStorage;
    144147  SHORT       ret = 0;
    145148  CHAR       *pext,*ppext;
    146 
    147   if(dcd)
    148     arcsortFlags = dcd->sortFlags;
    149   if(arcsortFlags) {
    150     switch(arcsortFlags & (~SORT_REVERSE)) {
     149  INT        sortFlags;
     150
     151  if (!pdcd)
     152  {
     153    HWND hwndCnr = pai1->hwndCnr;
     154    pdcd = (DIRCNRDATA *)WinQueryWindowPtr(hwndCnr,QWL_USER);
     155    // fixme debug
     156    if (!pdcd)
     157    {
     158      saymsg(0,NULLHANDLE,"*Debug*","dcd NULL %s %u",__FILE__, __LINE__);
     159      return ret;
     160    }
     161  }
     162
     163  sortFlags = pdcd->sortFlags;          // Optimize
     164
     165  if(sortFlags) {
     166    switch(sortFlags & (~SORT_REVERSE)) {
    151167      case SORT_FIRSTEXTENSION:
    152         pext = strchr(p->szFileName,'.');
    153         ppext = strchr(pp->szFileName,'.');
     168        pext = strchr(pai1->szFileName,'.');
     169        ppext = strchr(pai2->szFileName,'.');
    154170        if(!pext)
    155171          pext = NullStr;
     
    160176
    161177      case SORT_LASTEXTENSION:
    162         pext = strrchr(p->szFileName,'.');
    163         ppext = strrchr(pp->szFileName,'.');
     178        pext = strrchr(pai1->szFileName,'.');
     179        ppext = strrchr(pai2->szFileName,'.');
    164180        if(!pext)
    165181          pext = NullStr;
     
    170186
    171187      case SORT_LWDATE:
    172         ret = (p->date.year < pp->date.year) ? 1 :
    173               (p->date.year > pp->date.year) ? -1 :
    174               (p->date.month < pp->date.month) ? 1 :
    175               (p->date.month > pp->date.month) ? -1 :
    176               (p->date.day < pp->date.day) ? 1 :
    177               (p->date.day > pp->date.day) ? -1 :
    178               (p->time.hours < pp->time.hours) ? 1 :
    179               (p->time.hours > pp->time.hours) ? -1 :
    180               (p->time.minutes < pp->time.minutes) ? 1 :
    181               (p->time.minutes > pp->time.minutes) ? -1 :
    182               (p->time.seconds < pp->time.seconds) ? 1 :
    183               (p->time.seconds > pp->time.seconds) ? -1 : 0;
     188        ret = (pai1->date.year < pai2->date.year) ? 1 :
     189              (pai1->date.year > pai2->date.year) ? -1 :
     190              (pai1->date.month < pai2->date.month) ? 1 :
     191              (pai1->date.month > pai2->date.month) ? -1 :
     192              (pai1->date.day < pai2->date.day) ? 1 :
     193              (pai1->date.day > pai2->date.day) ? -1 :
     194              (pai1->time.hours < pai2->time.hours) ? 1 :
     195              (pai1->time.hours > pai2->time.hours) ? -1 :
     196              (pai1->time.minutes < pai2->time.minutes) ? 1 :
     197              (pai1->time.minutes > pai2->time.minutes) ? -1 :
     198              (pai1->time.seconds < pai2->time.seconds) ? 1 :
     199              (pai1->time.seconds > pai2->time.seconds) ? -1 : 0;
    184200        break;
    185201
    186202      case SORT_SIZE:
    187         ret = (p->cbFile < pp->cbFile) ? 1 : (p->cbFile == pp->cbFile) ?
     203        ret = (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile == pai2->cbFile) ?
    188204              0 : -1;
    189205        if(!ret)
    190           ret = (p->cbComp < pp->cbComp) ? 1 : (p->cbComp == pp->cbComp) ?
     206          ret = (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp == pai2->cbComp) ?
    191207                0 : -1;
    192208        break;
    193209
    194210      case SORT_EASIZE:
    195         ret = (p->cbComp < pp->cbComp) ? 1 : (p->cbComp == pp->cbComp) ?
     211        ret = (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp == pai2->cbComp) ?
    196212              0 : -1;
    197213        if(!ret)
    198           ret = (p->cbFile < pp->cbFile) ? 1 : (p->cbFile == pp->cbFile) ?
     214          ret = (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile == pai2->cbFile) ?
    199215                0 : -1;
    200216        break;
    201217    }
    202218    if(!ret)
    203       ret = (SHORT)stricmp(p->szFileName,pp->szFileName);
    204     if(ret && (arcsortFlags & SORT_REVERSE))
     219      ret = (SHORT)stricmp(pai1->szFileName,pai2->szFileName);
     220    if(ret && (sortFlags & SORT_REVERSE))
    205221      ret = (ret > 0) ? -1 : 1;
    206222    return ret;
    207223  }
    208   return (SHORT)stricmp(p->szFileName,pp->szFileName);
     224  return (SHORT)stricmp(pai1->szFileName,pai2->szFileName);
    209225}
    210226
    211227
    212 INT APIENTRY ArcFilter (PMINIRECORDCORE rmini,PVOID arg)
     228static INT APIENTRY ArcFilter (PMINIRECORDCORE rmini,PVOID arg)
    213229{
    214230  DIRCNRDATA   *dcd = (DIRCNRDATA *)arg;
     
    246262
    247263
    248 MRESULT EXPENTRY ArcFrameWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     264static MRESULT EXPENTRY ArcFrameWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
    249265{
    250266  return CommonFrameWndProc(ARC_CNR,hwnd,msg,mp1,mp2);
     
    252268
    253269
    254 BOOL IsArcThere (HWND hwnd, CHAR *arcname)
     270static BOOL IsArcThere (HWND hwnd, CHAR *arcname)
    255271{
    256272  if(arcname) {
     
    695711                dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
    696712                                                        QW_PARENT),
    697                                         ARC_CNR),
    698                                         0);
     713                                                        ARC_CNR),
     714                                        QWL_USER);
    699715                if(id == DIR_SORT) {
    700716                  if(dcd)
     
    11391155
    11401156  switch(msg) {
    1141     case WM_CREATE:
    1142       break;
    1143 
    11441157    case DM_PRINTOBJECT:
    11451158    case DM_DISCARDOBJECT:
     
    19932006
    19942007
    1995 MRESULT EXPENTRY ArcCnrWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     2008static MRESULT EXPENTRY ArcCnrWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
    19962009{
    19972010  DIRCNRDATA *dcd = WinQueryWindowPtr(hwnd,QWL_USER);
     
    24332446                  dcd->sortFlags,
    24342447                  TRUE);
     2448          DefArcSortFlags = dcd->sortFlags;     // Remember for new windows
    24352449        }
    24362450      }
     
    28872901                    dcd->sortFlags,
    28882902                    TRUE);
     2903            DefArcSortFlags = dcd->sortFlags;   // Remember for new windows
    28892904            break;
    28902905
     
    35103525
    35113526HWND StartArcCnr (HWND hwndParent,HWND hwndCaller,CHAR *arcname,INT flags,
    3512                   ARC_TYPE *sinfo) {
    3513 
     3527                  ARC_TYPE *sinfo)
     3528{
    35143529  /*
    35153530   * bitmapped flags:
     
    36253640        dcd->dontclose = ((flags & 4) != 0);
    36263641        dcd->info = info;
     3642        dcd->sortFlags = DefArcSortFlags;
    36273643        {
    36283644          PFNWP oldproc;
     
    36313647                                      (PFNWP)ArcFrameWndProc);
    36323648          WinSetWindowPtr(hwndFrame,
    3633                           0,
     3649                          QWL_USER,
    36343650                          (PVOID)oldproc);
    36353651        }
     
    36513667        if(dcd->hwndCnr) {
    36523668          WinSetWindowPtr(dcd->hwndCnr,
    3653                           0,
     3669                          QWL_USER,
    36543670                          (PVOID)dcd);
    36553671          {
     
    37903806  return hwndFrame;
    37913807}
    3792 
Note: See TracChangeset for help on using the changeset viewer.