Changeset 551 for trunk/dll/killproc.c


Ignore:
Timestamp:
Feb 28, 2007, 2:33:51 AM (19 years ago)
Author:
Gregg Young
Message:

Indentation cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/killproc.c

    r533 r551  
    4141#pragma alloc_text(KILLPROC,FillKillListThread,FillKillListThread2,GetDosPgmName,KillDlgProc)
    4242
    43 CHAR *GetDosPgmName (PID pid,CHAR *string)
     43CHAR *GetDosPgmName(PID pid, CHAR * string)
    4444{
    4545  HSWITCH hs;
    4646  SWCNTRL swctl;
    47   PCH     pch;
     47  PCH pch;
    4848
    4949  *string = 0;
    50   hs = WinQuerySwitchHandle(0,pid);
    51   if(hs) {
    52     WinQuerySwitchEntry(hs,&swctl);
     50  hs = WinQuerySwitchHandle(0, pid);
     51  if (hs) {
     52    WinQuerySwitchEntry(hs, &swctl);
    5353    pch = swctl.szSwtitle;
    54     while(*pch) {
    55       if(*pch < 0x10)
    56         if(pch != swctl.szSwtitle && *(pch - 1) == 0x20)
    57           memmove(pch,pch + 1,strlen(pch));
    58         else {
    59           *pch = 0x20;
    60           pch++;
    61         }
     54    while (*pch) {
     55      if (*pch < 0x10)
     56        if (pch != swctl.szSwtitle && *(pch - 1) == 0x20)
     57          memmove(pch, pch + 1, strlen(pch));
     58        else {
     59          *pch = 0x20;
     60          pch++;
     61        }
    6262      else
    63         pch++;
    64     }
    65     strcpy(string,swctl.szSwtitle);
    66   }
    67   if(!*string)
    68     strcpy(string,GetPString(IDS_UNKNOWNDOSPROCTEXT));
     63        pch++;
     64    }
     65    strcpy(string, swctl.szSwtitle);
     66  }
     67  if (!*string)
     68    strcpy(string, GetPString(IDS_UNKNOWNDOSPROCTEXT));
    6969  return string;
    7070}
    7171
    72 
    73 static VOID FillKillListThread2 (VOID *arg)
     72static VOID FillKillListThread2(VOID * arg)
    7473{
    75   HWND          hwnd = *(HWND *)arg;
    76   CHAR          s[1036];
    77   HAB           thab;
    78   HMQ           thmq;
    79   INT           rc;
    80   PROCESSINFO  *ppi;
    81   BUFFHEADER   *pbh;
    82   MODINFO      *pmi;
     74  HWND hwnd = *(HWND *) arg;
     75  CHAR s[1036];
     76  HAB thab;
     77  HMQ thmq;
     78  INT rc;
     79  PROCESSINFO *ppi;
     80  BUFFHEADER *pbh;
     81  MODINFO *pmi;
    8382
    8483  thab = WinInitialize(0);
    85   thmq = WinCreateMsgQueue(thab,0);
    86   WinCancelShutdown(thmq,TRUE);
     84  thmq = WinCreateMsgQueue(thab, 0);
     85  WinCancelShutdown(thmq, TRUE);
    8786  IncrThreadUsage();
    8887
    89   WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_DELETEALL,MPVOID,MPVOID);
    90   rc = DosAllocMem((PVOID)&pbh,USHRT_MAX + 4096,
    91                     PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
     88  WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
     89  rc = DosAllocMem((PVOID) & pbh, USHRT_MAX + 4096,
     90                   PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
    9291  if (rc)
    93     Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
     92    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     93              GetPString(IDS_OUTOFMEMORY));
    9494  else {
    95     rc = DosQProcStatus(pbh,USHRT_MAX);
     95    rc = DosQProcStatus(pbh, USHRT_MAX);
    9696    if (!rc) {
    9797      ppi = pbh->ppi;
    98       while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) {
    99         if(ppi->pid != mypid) {
    100           pmi = pbh->pmi;
    101           while(pmi && ppi->hModRef != pmi->hMod)
    102             pmi = pmi->pNext;
    103           if(pmi) {
    104             sprintf(s,"%04x ",ppi->pid);
    105             if(!stricmp(pmi->szModName,"SYSINIT"))
    106               GetDosPgmName(ppi->pid,s + strlen(s));
    107             else {
    108               if(*pmi->szModName)
    109                 strcat(s,pmi->szModName);
    110               else
    111                 strcat(s,GetPString(IDS_UNKNOWNPROCTEXT));
    112             }
    113             if (WinIsWindow(thab,hwnd)) {
    114               WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_INSERTITEM,
    115                                 MPFROM2SHORT(LIT_SORTASCENDING,0),
    116                                              MPFROMP(s));
     98      while (ppi->ulEndIndicator != PROCESS_END_INDICATOR) {
     99        if (ppi->pid != mypid) {
     100          pmi = pbh->pmi;
     101          while (pmi && ppi->hModRef != pmi->hMod)
     102            pmi = pmi->pNext;
     103          if (pmi) {
     104            sprintf(s, "%04x ", ppi->pid);
     105            if (!stricmp(pmi->szModName, "SYSINIT"))
     106              GetDosPgmName(ppi->pid, s + strlen(s));
     107            else {
     108              if (*pmi->szModName)
     109                strcat(s, pmi->szModName);
     110              else
     111                strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
    117112            }
    118             else
    119               break;
    120           }
    121         }
    122         ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount);
    123       } // while
     113            if (WinIsWindow(thab, hwnd)) {
     114              WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_INSERTITEM,
     115                                MPFROM2SHORT(LIT_SORTASCENDING, 0),
     116                                MPFROMP(s));
     117            }
     118            else
     119              break;
     120          }
     121        }
     122        ppi = (PPROCESSINFO) (ppi->ptiFirst + ppi->usThreadCount);
     123      }                                 // while
    124124    }
    125125    DosFreeMem(pbh);
    126126  }
    127127
    128   if(WinIsWindow(thab,hwnd))
    129     PostMsg(hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
     128  if (WinIsWindow(thab, hwnd))
     129    PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
    130130  WinDestroyMsgQueue(thmq);
    131131  DecrThreadUsage();
     
    133133}
    134134
    135 
    136 static VOID FillKillListThread (VOID *arg)
     135static VOID FillKillListThread(VOID * arg)
    137136{
    138   HWND  hwnd = *(HWND *)arg;
    139   CHAR  s[1036],progname[1027],*p;
    140   HAB   thab;
    141   HMQ   thmq;
     137  HWND hwnd = *(HWND *) arg;
     138  CHAR s[1036], progname[1027], *p;
     139  HAB thab;
     140  HMQ thmq;
    142141  FILE *fp;
    143   BOOL  foundstart = FALSE;
    144   INT   rc;
     142  BOOL foundstart = FALSE;
     143  INT rc;
    145144  CHAR *startstring = "Process and Thread Information";
    146145  CHAR *endstring = "System Semaphore Information";
    147   PID   pid;
    148   HFILE oldstdout,newstdout;
     146  PID pid;
     147  HFILE oldstdout, newstdout;
    149148
    150149  DosError(FERR_DISABLEHARDERR);
    151150
    152151  thab = WinInitialize(0);
    153   thmq = WinCreateMsgQueue(thab,0);
    154   WinCancelShutdown(thmq,TRUE);
     152  thmq = WinCreateMsgQueue(thab, 0);
     153  WinCancelShutdown(thmq, TRUE);
    155154  IncrThreadUsage();
    156155
    157   WinSendDlgItemMsg(hwnd,
    158                     KILL_LISTBOX,
    159                     LM_DELETEALL,
    160                     MPVOID,
    161                     MPVOID);
    162   strcpy(s,"$PSTAT#$.#$#");
    163   unlinkf("%s",s);
    164   fp = fopen(s,"w");
    165   if(!fp) {
    166     Win_Error(NULLHANDLE,HWND_DESKTOP,__FILE__,__LINE__,
    167               GetPString(IDS_REDIRECTERRORTEXT));
     156  WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
     157  strcpy(s, "$PSTAT#$.#$#");
     158  unlinkf("%s", s);
     159  fp = fopen(s, "w");
     160  if (!fp) {
     161    Win_Error(NULLHANDLE, HWND_DESKTOP, __FILE__, __LINE__,
     162              GetPString(IDS_REDIRECTERRORTEXT));
    168163    goto Abort;
    169164  }
    170165  else {
    171166    newstdout = -1;
    172     rc = DosDupHandle(fileno(stdout),&newstdout);
     167    rc = DosDupHandle(fileno(stdout), &newstdout);
    173168    if (rc)
    174       Dos_Error(MB_CANCEL,rc,hwnd,__FILE__,__LINE__,"DosDupHandle");
     169      Dos_Error(MB_CANCEL, rc, hwnd, __FILE__, __LINE__, "DosDupHandle");
    175170    oldstdout = fileno(stdout);
    176     DosDupHandle(fileno(fp),&oldstdout);
     171    DosDupHandle(fileno(fp), &oldstdout);
    177172    rc = runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
    178                  hwnd,
    179                  NULL,
    180                  NULL,
    181                  "%s",
    182                  "PSTAT.EXE /C");
     173                 hwnd, NULL, NULL, "%s", "PSTAT.EXE /C");
    183174    oldstdout = fileno(stdout);
    184     DosDupHandle(newstdout,&oldstdout);
     175    DosDupHandle(newstdout, &oldstdout);
    185176    DosClose(newstdout);
    186177    fclose(fp);
    187178    // fixme to be gone?
    188     if(rc == -1) {
     179    if (rc == -1) {
    189180      saymsg(MB_CANCEL,
    190              hwnd,
    191              GetPString(IDS_ARGHTEXT),
    192              GetPString(IDS_CANTRUNPSTATTEXT));
     181             hwnd,
     182             GetPString(IDS_ARGHTEXT), GetPString(IDS_CANTRUNPSTATTEXT));
    193183      goto Abort;
    194184    }
    195185  }
    196   fp = fopen(s,"r");
     186  fp = fopen(s, "r");
    197187  if (fp) {
    198188    while (!feof(fp)) {
    199       strset(s,0);
    200       if (!xfgets(s,1025,fp,pszSrcFile,__LINE__))
    201         break;
     189      strset(s, 0);
     190      if (!xfgets(s, 1025, fp, pszSrcFile, __LINE__))
     191        break;
    202192      if (!foundstart) {
    203         if (*s == ' ' && strstr(s,startstring))
    204           foundstart = TRUE;
     193        if (*s == ' ' && strstr(s, startstring))
     194          foundstart = TRUE;
    205195      }
    206196      else {
    207         if(*s == ' ' && strstr(s,endstring))
    208           break;
    209         if(*s == ' ' && s[5] == ' ' && isxdigit(s[1]) &&
    210            isxdigit(s[2]) && isxdigit(s[3]) && isxdigit(s[4])) {
    211           p = &s[1];
    212           pid = strtol(&s[1],&p,16);
    213           if(pid && pid != mypid) {
    214             strcpy(progname,&s[30]);
    215             p = strchr(progname,' ');
    216             if(p)
    217               *p = 0;
    218             if(!stristr(progname,"\\PSTAT.EXE")) {
    219               sprintf(s,"%04x %s",pid,progname);
    220               WinSendDlgItemMsg(hwnd,
    221                                 KILL_LISTBOX,
    222                                 LM_INSERTITEM,
    223                                 MPFROM2SHORT(LIT_SORTASCENDING,0),
    224                                 MPFROMP(s));
    225             }
    226           }
    227         }
     197        if (*s == ' ' && strstr(s, endstring))
     198          break;
     199        if (*s == ' ' && s[5] == ' ' && isxdigit(s[1]) &&
     200            isxdigit(s[2]) && isxdigit(s[3]) && isxdigit(s[4])) {
     201          p = &s[1];
     202          pid = strtol(&s[1], &p, 16);
     203          if (pid && pid != mypid) {
     204            strcpy(progname, &s[30]);
     205            p = strchr(progname, ' ');
     206            if (p)
     207              *p = 0;
     208            if (!stristr(progname, "\\PSTAT.EXE")) {
     209              sprintf(s, "%04x %s", pid, progname);
     210              WinSendDlgItemMsg(hwnd,
     211                                KILL_LISTBOX,
     212                                LM_INSERTITEM,
     213                                MPFROM2SHORT(LIT_SORTASCENDING, 0),
     214                                MPFROMP(s));
     215            }
     216          }
     217        }
    228218      }
    229219    }
     
    232222Abort:
    233223  DosForceDelete("$PSTAT#$.#$#");
    234   PostMsg(hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
     224  PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
    235225  WinDestroyMsgQueue(thmq);
    236226  DecrThreadUsage();
     
    238228}
    239229
    240 
    241 MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     230MRESULT EXPENTRY KillDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    242231{
    243   SHORT           sSelect;
    244   PID             pid;
    245   static BOOL     listdone;
    246   static HPOINTER hptrIcon = (HPOINTER)0;
    247 
    248   switch(msg) {
    249     case WM_INITDLG:
    250       hptrIcon = WinLoadPointer(HWND_DESKTOP,
    251                                 FM3ModHandle,
    252                                 KILL_FRAME);
    253       WinDefDlgProc(hwnd,
    254                     WM_SETICON,
    255                     MPFROMLONG(hptrIcon),
    256                     MPVOID);
    257       WinCheckButton(hwnd,
    258                      KILL_CHECKBOX,
    259                      fUseQProcStat);
    260       PostMsg(hwnd,
    261               WM_COMMAND,
    262               MPFROM2SHORT(KILL_RESCAN,0),
    263               MPVOID);
    264       break;
    265 
    266     case UM_CONTAINER_FILLED:
    267       listdone = TRUE;
    268       if((SHORT)WinSendDlgItemMsg(hwnd,
    269                                   KILL_LISTBOX,
    270                                   LM_QUERYITEMCOUNT,
    271                                   MPVOID,
    272                                   MPVOID) == 0) {
    273         if(!fUseQProcStat)
    274           saymsg(MB_CANCEL,
    275                  hwnd,
    276                  GetPString(IDS_ICHOKEDTEXT),
    277                  GetPString(IDS_ISPSTATTHERETEXT));
    278         else
    279           saymsg(MB_CANCEL,
    280                  hwnd,
    281                  GetPString(IDS_ICHOKEDTEXT),
    282                  GetPString(IDS_DOSQPROCSTATFAILEDTEXT));
    283       }
     232  SHORT sSelect;
     233  PID pid;
     234  static BOOL listdone;
     235  static HPOINTER hptrIcon = (HPOINTER) 0;
     236
     237  switch (msg) {
     238  case WM_INITDLG:
     239    hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, KILL_FRAME);
     240    WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID);
     241    WinCheckButton(hwnd, KILL_CHECKBOX, fUseQProcStat);
     242    PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(KILL_RESCAN, 0), MPVOID);
     243    break;
     244
     245  case UM_CONTAINER_FILLED:
     246    listdone = TRUE;
     247    if ((SHORT) WinSendDlgItemMsg(hwnd,
     248                                  KILL_LISTBOX,
     249                                  LM_QUERYITEMCOUNT, MPVOID, MPVOID) == 0) {
     250      if (!fUseQProcStat)
     251        saymsg(MB_CANCEL,
     252               hwnd,
     253               GetPString(IDS_ICHOKEDTEXT), GetPString(IDS_ISPSTATTHERETEXT));
     254      else
     255        saymsg(MB_CANCEL,
     256               hwnd,
     257               GetPString(IDS_ICHOKEDTEXT),
     258               GetPString(IDS_DOSQPROCSTATFAILEDTEXT));
     259    }
     260    return 0;
     261
     262  case WM_CONTROL:
     263    switch (SHORT1FROMMP(mp1)) {
     264    case KILL_CHECKBOX:
     265      fUseQProcStat = WinQueryButtonCheckstate(hwnd, KILL_CHECKBOX);
     266      PrfWriteProfileData(fmprof,
     267                          FM3Str,
     268                          "UseQProcStat", &fUseQProcStat, sizeof(BOOL));
     269      PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(KILL_RESCAN, 0), MPVOID);
     270      break;
     271
     272    case KILL_LISTBOX:
     273      switch (SHORT2FROMMP(mp2)) {
     274      case LN_ENTER:
     275        WinSendDlgItemMsg(hwnd, DID_OK, BM_CLICK, MPFROMSHORT(TRUE), MPVOID);
     276        break;
     277      }
     278      break;
     279
     280    default:
     281      break;
     282    }
     283    return 0;
     284
     285  case WM_ADJUSTWINDOWPOS:
     286    PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
     287    break;
     288
     289  case UM_STRETCH:
     290    {
     291      SWP swpC, swp, swpH;
     292
     293      WinQueryWindowPos(hwnd, &swp);
     294      if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
     295        WinQueryWindowPos(WinWindowFromID(hwnd, KILL_LISTBOX), &swpC);
     296        WinQueryWindowPos(WinWindowFromID(hwnd, KILL_HDR), &swpH);
     297        WinSetWindowPos(WinWindowFromID(hwnd, KILL_LISTBOX), HWND_TOP,
     298                        SysVal(SV_CXSIZEBORDER),
     299                        swpC.y,
     300                        swp.cx - (SysVal(SV_CXSIZEBORDER) * 2),
     301                        ((swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) +
     302                                              SysVal(SV_CYSIZEBORDER)) -
     303                         (swpH.cy + 8)), SWP_MOVE | SWP_SIZE);
     304        WinSetWindowPos(WinWindowFromID(hwnd, KILL_HDR), HWND_TOP,
     305                        SysVal(SV_CXSIZEBORDER) + 4,
     306                        swpC.y + ((swp.cy - swpC.y) -
     307                                  (SysVal(SV_CYTITLEBAR) +
     308                                   SysVal(SV_CYSIZEBORDER)) -
     309                                  (swpH.cy + 4)), swpH.cx, swpH.cy, SWP_MOVE);
     310      }
     311    }
     312    return 0;
     313
     314  case WM_COMMAND:
     315    switch (SHORT1FROMMP(mp1)) {
     316    case KILL_RESCAN:
     317      listdone = FALSE;
     318      if (fUseQProcStat) {
     319        if (_beginthread(FillKillListThread2,
     320                         NULL, 65536, (PVOID) & hwnd) != -1)
     321          DosSleep(250L);
     322        else
     323          WinDismissDlg(hwnd, 0);
     324      }
     325      else {
     326        if (_beginthread(FillKillListThread,
     327                         NULL, 65536, (PVOID) & hwnd) != -1)
     328          DosSleep(250L);
     329        else
     330          WinDismissDlg(hwnd, 0);
     331      }
     332      break;
     333
     334    case KILL_SHOW:
     335    case DID_OK:
     336      sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
     337                                           KILL_LISTBOX,
     338                                           LM_QUERYSELECTION,
     339                                           MPFROMSHORT(LIT_FIRST), MPVOID);
     340      if (sSelect >= 0) {
     341
     342        CHAR s[31], *p;
     343        APIRET error;
     344
     345        *s = 0;
     346        WinSendDlgItemMsg(hwnd,
     347                          KILL_LISTBOX,
     348                          LM_QUERYITEMTEXT,
     349                          MPFROM2SHORT(sSelect, 30), MPFROMP(s));
     350        if (*s) {
     351          p = s;
     352          pid = strtol(s, &p, 16);
     353          if (pid) {
     354            if (SHORT1FROMMP(mp1) == DID_OK) {
     355              error = DosKillProcess(DKP_PROCESS, pid);
     356              if (error && error != ERROR_INVALID_PROCID) {
     357                Dos_Error(MB_CANCEL,
     358                          error,
     359                          hwnd,
     360                          __FILE__,
     361                          __LINE__, GetPString(IDS_DOSKILLFAILEDTEXT));
     362              }
     363              else
     364                WinSendDlgItemMsg(hwnd,
     365                                  KILL_LISTBOX,
     366                                  LM_DELETEITEM,
     367                                  MPFROM2SHORT(sSelect, 0), MPVOID);
     368            }
     369            else if (!ShowSession(hwnd, pid))
     370              Notify(GetPString(IDS_SORRYCANTSHOWTEXT));
     371          }
     372        }
     373      }
     374      break;
     375
     376    case DID_CANCEL:
     377      if (!listdone)
     378        Runtime_Error(pszSrcFile, __LINE__, "busy");
     379      else
     380        WinDismissDlg(hwnd, 0);
     381      break;
     382
     383    case IDM_HELP:
     384      saymsg(MB_ENTER | MB_ICONASTERISK,
     385             hwnd,
     386             GetPString(IDS_KILLPROCHELPTITLETEXT),
     387             GetPString(IDS_KILLPROCHELPTEXT));
     388      break;
     389    }
     390    return 0;
     391
     392  case WM_CLOSE:
     393    if (!listdone) {
     394      Runtime_Error(pszSrcFile, __LINE__, "busy");
    284395      return 0;
    285 
    286     case WM_CONTROL:
    287       switch(SHORT1FROMMP(mp1)) {
    288         case KILL_CHECKBOX:
    289           fUseQProcStat = WinQueryButtonCheckstate(hwnd,
    290                                                    KILL_CHECKBOX);
    291           PrfWriteProfileData(fmprof,
    292                               FM3Str,
    293                               "UseQProcStat",
    294                               &fUseQProcStat,
    295                               sizeof(BOOL));
    296           PostMsg(hwnd,
    297                   WM_COMMAND,
    298                   MPFROM2SHORT(KILL_RESCAN,0),
    299                   MPVOID);
    300           break;
    301 
    302         case KILL_LISTBOX:
    303           switch(SHORT2FROMMP(mp2)) {
    304             case LN_ENTER:
    305               WinSendDlgItemMsg(hwnd,
    306                                 DID_OK,
    307                                 BM_CLICK,
    308                                 MPFROMSHORT(TRUE),
    309                                 MPVOID);
    310               break;
    311           }
    312           break;
    313 
    314         default:
    315           break;
    316       }
    317       return 0;
    318 
    319     case WM_ADJUSTWINDOWPOS:
    320       PostMsg(hwnd,
    321               UM_STRETCH,
    322               MPVOID,
    323               MPVOID);
    324       break;
    325 
    326     case UM_STRETCH:
    327       {
    328         SWP swpC,swp,swpH;
    329 
    330         WinQueryWindowPos(hwnd,&swp);
    331         if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
    332           WinQueryWindowPos(WinWindowFromID(hwnd,KILL_LISTBOX),&swpC);
    333           WinQueryWindowPos(WinWindowFromID(hwnd,KILL_HDR),&swpH);
    334           WinSetWindowPos(WinWindowFromID(hwnd,KILL_LISTBOX),HWND_TOP,
    335                           SysVal(SV_CXSIZEBORDER),
    336                           swpC.y,
    337                           swp.cx - (SysVal(SV_CXSIZEBORDER) * 2),
    338                           ((swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) +
    339                                                SysVal(SV_CYSIZEBORDER)) -
    340                            (swpH.cy + 8)),
    341                           SWP_MOVE | SWP_SIZE);
    342           WinSetWindowPos(WinWindowFromID(hwnd,KILL_HDR),HWND_TOP,
    343                           SysVal(SV_CXSIZEBORDER) + 4,
    344                           swpC.y + ((swp.cy - swpC.y) -
    345                                     (SysVal(SV_CYTITLEBAR) +
    346                                      SysVal(SV_CYSIZEBORDER)) -
    347                                     (swpH.cy + 4)),
    348                           swpH.cx,
    349                           swpH.cy,
    350                           SWP_MOVE);
    351         }
    352       }
    353       return 0;
    354 
    355     case WM_COMMAND:
    356       switch(SHORT1FROMMP(mp1)) {
    357         case KILL_RESCAN:
    358           listdone = FALSE;
    359           if(fUseQProcStat) {
    360             if(_beginthread(FillKillListThread2,
    361                             NULL,
    362                             65536,
    363                             (PVOID)&hwnd) != -1)
    364               DosSleep(250L);
    365             else
    366               WinDismissDlg(hwnd,0);
    367           }
    368           else {
    369             if(_beginthread(FillKillListThread,
    370                             NULL,
    371                             65536,
    372                             (PVOID)&hwnd) != -1)
    373               DosSleep(250L);
    374             else
    375               WinDismissDlg(hwnd,0);
    376           }
    377           break;
    378 
    379         case KILL_SHOW:
    380         case DID_OK:
    381           sSelect = (USHORT)WinSendDlgItemMsg(hwnd,
    382                                               KILL_LISTBOX,
    383                                               LM_QUERYSELECTION,
    384                                               MPFROMSHORT(LIT_FIRST),
    385                                               MPVOID);
    386           if(sSelect >= 0) {
    387 
    388             CHAR   s[31],*p;
    389             APIRET error;
    390 
    391             *s = 0;
    392             WinSendDlgItemMsg(hwnd,
    393                               KILL_LISTBOX,
    394                               LM_QUERYITEMTEXT,
    395                               MPFROM2SHORT(sSelect,30),
    396                               MPFROMP(s));
    397             if(*s) {
    398               p = s;
    399               pid = strtol(s,&p,16);
    400               if(pid) {
    401                 if(SHORT1FROMMP(mp1) == DID_OK) {
    402                   error = DosKillProcess(DKP_PROCESS,pid);
    403                   if(error && error != ERROR_INVALID_PROCID) {
    404                     Dos_Error(MB_CANCEL,
    405                               error,
    406                               hwnd,
    407                               __FILE__,
    408                               __LINE__,
    409                               GetPString(IDS_DOSKILLFAILEDTEXT));
    410                   }
    411                   else
    412                     WinSendDlgItemMsg(hwnd,
    413                                       KILL_LISTBOX,
    414                                       LM_DELETEITEM,
    415                                       MPFROM2SHORT(sSelect,0),
    416                                       MPVOID);
    417                 }
    418                 else if(!ShowSession(hwnd,pid))
    419                   Notify(GetPString(IDS_SORRYCANTSHOWTEXT));
    420               }
    421             }
    422           }
    423           break;
    424 
    425         case DID_CANCEL:
    426           if(!listdone)
    427             Runtime_Error(pszSrcFile, __LINE__, "busy");
    428           else
    429             WinDismissDlg(hwnd,0);
    430           break;
    431 
    432         case IDM_HELP:
    433           saymsg(MB_ENTER | MB_ICONASTERISK,
    434                  hwnd,
    435                  GetPString(IDS_KILLPROCHELPTITLETEXT),
    436                  GetPString(IDS_KILLPROCHELPTEXT));
    437           break;
    438       }
    439       return 0;
    440 
    441     case WM_CLOSE:
    442       if(!listdone) {
    443         Runtime_Error(pszSrcFile, __LINE__, "busy");
    444         return 0;
    445       }
    446       break;
    447 
    448     case WM_DESTROY:
    449       if(hptrIcon)
    450         WinDestroyPointer(hptrIcon);
    451       hptrIcon = (HPOINTER)0;
    452       break;
    453   }
    454   return WinDefDlgProc(hwnd,msg,mp1,mp2);
     396    }
     397    break;
     398
     399  case WM_DESTROY:
     400    if (hptrIcon)
     401      WinDestroyPointer(hptrIcon);
     402    hptrIcon = (HPOINTER) 0;
     403    break;
     404  }
     405  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    455406}
    456 
Note: See TracChangeset for help on using the changeset viewer.