-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskPage.cpp
More file actions
executable file
·2561 lines (1936 loc) · 64.2 KB
/
Copy pathTaskPage.cpp
File metadata and controls
executable file
·2561 lines (1936 loc) · 64.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "taskmgr.h"
#include ".\taskpage.h"
BOOL InsertIntoSortedArray(CPtrArray * pArray, CTaskInfo * pTask);
BOOL ResortTaskArray(CPtrArray ** ppArray);
//----------------------------------------------------------------------------------------------
//
// Active Columns
//
TASKCOLUMNID g_ActiveTaskCol[NUM_TASK_COLUMN + 1] =
{
COL_TASKNAME,
// COL_TASKDESKTOP,
COL_TASKSTATUS,
(TASKCOLUMNID) -1
};
DWORD g_cTasks = 0;
// Controls which are enabled only for any selection
static const UINT g_aSingleIDs[] =
{
IDC_ENDTASK,
IDC_SWITCHTO,
};
//
// Column Default Info
//
struct
{
INT Format;
INT Width;
} TaskColumnDefaults[NUM_TASK_COLUMN] =
{
{ LVCFMT_LEFT, 250}, // COL_TASKNAME
{ LVCFMT_LEFT, 97 }, // COL_TASKSTATUS
{ LVCFMT_LEFT, 70 }, // COL_TASKWINSTATION
{ LVCFMT_LEFT, 70 }, // COL_TASKDESKTOP
};
static const INT aTaskControls[] =
{
IDC_SWITCHTO,
IDC_ENDTASK,
IDM_RUN
};
//--------------------------------------------------------------------------------------------
//
//CTaskInfo类相关函数和变量
//
//--------------------------------------------------------------------------------------------
TASKCOLUMNID g_iTaskSortColumnID = COL_TASKNAME;
INT g_iTaskSortDirection = 1; // 1 = asc, -1 = desc
//--------------------------------------------------------------------------------------------
/*++ class CTaskInfo::Compare
Class Description:
Compares this CTaskInfo object to another, and returns its ranking
based on the g_iTaskSortColumnID field.
Note that if the objects are equal based on the current sort column,
the HWND is used as a secondary sort key to prevent items from
jumping around in the listview
Arguments:
pOther - the CTaskInfo object to compare this to
Return Value:
< 0 - This CTaskInfo is "less" than the other
0 - Equal (Can't happen, since HWND is secondary sort)
> 0 - This CTaskInfo is "greater" than the other
Revision History:
Nov-29-95 Davepl Created
--*/
INT CTaskInfo::Compare(CTaskInfo * pOther)
{
INT iRet;
switch (g_iTaskSortColumnID)
{
case COL_TASKNAME:
iRet = lstrcmpi(this->m_pszWindowTitle, pOther->m_pszWindowTitle);
break;
case COL_TASKWINSTATION:
iRet = lstrcmpi(this->m_lpWinsta, pOther->m_lpWinsta);
break;
case COL_TASKDESKTOP:
iRet = lstrcmpi(this->m_lpDesktop, pOther->m_lpDesktop);
break;
case COL_TASKSTATUS:
iRet = Compare64(this->m_fHung, pOther->m_fHung);
break;
default:
Assert(0 && "Invalid task sort column");
iRet = 0;
}
// If objects look equal, compare on HWND as secondary sort column
// so that items don't jump around in the listview
if (0 == iRet)
{
iRet = Compare64((LPARAM)this->m_hwnd, (LPARAM)pOther->m_hwnd);
}
return (iRet * g_iTaskSortDirection);
}
/*++ class CTaskInfo::SetData
Class Description:
Updates (or initializes) the info about a running task
Arguments:
hwnd - taks's hwnd
lpTitle - Window title
uPassCount- Current passcount, used to timestamp the last update of
this object
lpDesktop - task's current desktop
lpWinsta - task's current windowstation
fUpdate - only worry about information that can change during a
task's lifetime
Return Value:
HRESULT
Revision History:
Nov-16-95 Davepl Created
--*/
HRESULT CTaskInfo::SetData(HWND hwnd,
LPTSTR lpTitle,
LPTSTR lpWinsta,
LPTSTR lpDesktop,
LARGE_INTEGER uPassCount,
BOOL fUpdateOnly)
{
HRESULT hr = S_OK;
// Touch this CTaskInfo to indicate that it's still alive
m_uPassCount.QuadPart = uPassCount.QuadPart;
//
// For each of the fields, we check to see if anything has changed, and if
// so, we mark that particular column as having changed, and update the value.
// This allows me to opimize which fields of the listview to repaint, since
// repainting an entire listview column causes flicker and looks bad in
// general
//
// Window Station
if (!fUpdateOnly || lstrcmp(m_lpWinsta, lpWinsta))
{
if (m_lpWinsta)
LocalFree(m_lpWinsta);
m_lpWinsta = (LPTSTR) LocalAlloc( 0, (lstrlen(lpWinsta) + 1) * sizeof(TCHAR));
if (NULL == m_lpWinsta)
{
return E_OUTOFMEMORY;
}
else
{
lstrcpy(m_lpWinsta, lpWinsta);
}
m_fDirty_COL_WINSTA = TRUE;
// dprintf(TEXT("Winsta changed: %s from %s to %s\n"), m_pszWindowTitle, m_lpWinsta, lpWinsta);
}
// Desktop
if (!fUpdateOnly || lstrcmp(m_lpDesktop, lpDesktop))
{
if (m_lpDesktop)
LocalFree(m_lpDesktop);
m_lpDesktop = (LPTSTR) LocalAlloc( 0, (lstrlen(lpDesktop) + 1) * sizeof(TCHAR));
if (NULL == m_lpDesktop)
{
return E_OUTOFMEMORY;
}
else
{
lstrcpy(m_lpDesktop, lpDesktop);
}
m_fDirty_COL_DESKTOP = TRUE;
// dprintf(TEXT("Desktop changed: %s from %s to %s\n"), m_pszWindowTitle, m_lpDesktop, lpDesktop);
}
// Title
if (!fUpdateOnly || lstrcmp(m_pszWindowTitle, lpTitle))
{
if (m_pszWindowTitle)
LocalFree(m_pszWindowTitle);
m_pszWindowTitle = (LPTSTR) LocalAlloc( 0, (lstrlen(lpTitle) + 1) * sizeof(TCHAR));
if (NULL == m_pszWindowTitle)
{
return E_OUTOFMEMORY;
}
else
{
lstrcpy(m_pszWindowTitle, lpTitle);
}
m_fDirty_COL_TITLE = TRUE;
// dprintf(TEXT("Title changed: %s from %s to %s\n"), m_pszWindowTitle, m_pszWindowTitle, lpTitle);
}
// App status (hung / not hung)
BOOL fHung = fpnIsHungAppWindow(hwnd);
if (fHung != m_fHung)
{
m_fHung = fHung;
m_fDirty_COL_STATUS = TRUE;
// dprintf(TEXT("Status changed: %s\n"), m_pszWindowTitle);
}
// Window handle
if (m_hwnd != hwnd)
{
m_hwnd = hwnd;
m_fDirty_COL_HWND = TRUE;
// dprintf(TEXT("Handle changed: %s\n"), m_pszWindowTitle);
}
// Icons
#define ICON_FETCH_TIMEOUT 100
if (!fUpdateOnly)
{
m_hSmallIcon = NULL;
m_hLargeIcon = NULL;
if (!SendMessageTimeout(hwnd, WM_GETICON, 0, 0,
SMTO_BLOCK | SMTO_ABORTIFHUNG, ICON_FETCH_TIMEOUT, (PULONG_PTR) &m_hSmallIcon)
|| NULL == m_hSmallIcon)
{
m_hSmallIcon = (HICON)(LONG_PTR)GetClassLongPtr(hwnd, GCLP_HICONSM);
}
if (!SendMessageTimeout(hwnd, WM_GETICON, 1, 0,
SMTO_BLOCK | SMTO_ABORTIFHUNG, ICON_FETCH_TIMEOUT, (PULONG_PTR) &m_hLargeIcon)
|| NULL == m_hLargeIcon)
{
m_hLargeIcon = (HICON)(LONG_PTR)GetClassLongPtr(hwnd, GCLP_HICON);
}
}
return S_OK;
}
//--------------------------------------------------------------------------------------------
CTaskPage::CTaskPage(void)
{
m_hPage = NULL;
m_hwndTabs = NULL;
m_fPaused = FALSE;
m_pTaskArray = NULL;
m_himlSmall = NULL;
m_himlLarge = NULL;
m_hEventChild = NULL;
m_hEventParent = NULL;
m_hThread = NULL;
m_vmViewMode = g_Options.m_vmViewMode;
m_cSelected = 0;
}
CTaskPage::~CTaskPage(void)
{
RemoveAllTasks();
delete m_pTaskArray;
}
//------------------------------------------------------------------全局函数-------------------------------------------
// REVIEW (Davepl) The next three functions have very close parallels
// in the process page code. Consider generalizing them to eliminate
// duplication
/*++ InsertIntoSortedArray
Class Description:
Sticks a CTaskInfo ptr into the ptrarray supplied at the
appropriate location based on the current sort column (which
is used by the Compare member function)
Arguments:
pArray - The CPtrArray to add to
pProc - The CTaskInfo object to add to the array
Return Value:
TRUE if successful, FALSE if fails
Revision History:
Nov-20-95 Davepl Created
--*/
// REVIEW (davepl) Use binary insert here, not linear
BOOL InsertIntoSortedArray(CPtrArray * pArray, CTaskInfo * pTask)
{
INT cItems = pArray->GetSize();
for (INT iIndex = 0; iIndex < cItems; iIndex++)
{
CTaskInfo * pTmp = (CTaskInfo *) pArray->GetAt(iIndex);
if (pTask->Compare(pTmp) < 0)
{
return pArray->InsertAt(iIndex, pTask);
}
}
return pArray->Add(pTask);
}
/*++ ResortTaskArray
Function Description:
Creates a new ptr array sorted in the current sort order based
on the old array, and then replaces the old with the new
Arguments:
ppArray - The CPtrArray to resort
Return Value:
TRUE if successful, FALSE if fails
Revision History:
Nov-21-95 Davepl Created
--*/
BOOL ResortTaskArray(CPtrArray ** ppArray)
{
// Create a new array which will be sorted in the new
// order and used to replace the existing array
CPtrArray * pNew = new CPtrArray(GetProcessHeap());
if (NULL == pNew)
{
return FALSE;
}
// Insert each of the existing items in the old array into
// the new array in the correct spot
INT cItems = (*ppArray)->GetSize();
for (int i = 0; i < cItems; i++)
{
CTaskInfo * pItem = (CTaskInfo *) (*ppArray)->GetAt(i);
if (FALSE == InsertIntoSortedArray(pNew, pItem))
{
delete pNew;
return FALSE;
}
}
// Kill off the old array, replace it with the new
delete (*ppArray);
(*ppArray) = pNew;
return TRUE;
}
//------------------------------------------------------------回调函数----------------------------------------------------
/*++
Routine Description:
Callback function for windowstation enumeration.
Arguments:
lpstr - windowstation name
lParam - ** not used **
Return Value:
TRUE - continues the enumeration
--*/
BOOL CALLBACK EnumWindowStationsFunc(LPTSTR lpstr, LPARAM lParam)
{
PTASK_LIST_ENUM te = (PTASK_LIST_ENUM)lParam;
HWINSTA hwinsta;
HWINSTA hwinstaSave;
DWORD ec;
//
// open the windowstation
//
hwinsta = OpenWindowStation( lpstr, FALSE, MAXIMUM_ALLOWED );
if (!hwinsta)
{
// If we fail because we don't have sufficient access to this
// desktop, we should continue the enumeration anyway.
return TRUE;
}
//
// save the current windowstation
//
hwinstaSave = GetProcessWindowStation();
//
// change the context to the new windowstation
//
if (!SetProcessWindowStation( hwinsta ))
{
ec = GetLastError();
SetProcessWindowStation( hwinstaSave );
CloseWindowStation( hwinsta );
if (hwinsta != hwinstaSave)
CloseWindowStation( hwinstaSave );
return TRUE;
}
//
// Update the windowstation in the enumerator
//
if (te->lpWinsta)
{
LocalFree(te->lpWinsta);
}
te->lpWinsta = (LPTSTR) LocalAlloc( 0, (lstrlen(lpstr) + 1) * sizeof(TCHAR));
if (NULL == te->lpWinsta)
{
if (hwinsta != hwinstaSave)
{
SetProcessWindowStation( hwinstaSave );
CloseWindowStation( hwinsta );
}
CloseWindowStation( hwinstaSave );
// We technically could continue, but if we're this strapped for
// memory, there's not much point. Let's bail on the winsta enumeration.
return FALSE;
}
else
{
lstrcpy(te->lpWinsta, lpstr);
}
//
// enumerate all the desktops for this windowstation
//
EnumDesktops( hwinsta, EnumDesktopsFunc, lParam );
//
// restore the context to the previous windowstation
//
if (hwinsta != hwinstaSave)
{
SetProcessWindowStation( hwinstaSave );
CloseWindowStation( hwinsta );
}
//
// continue the enumeration
//
return TRUE;
}
/*++
Routine Description:
Callback function for desktop enumeration.
Arguments:
lpstr - desktop name
lParam - ** not used **
Return Value:
TRUE - continues the enumeration
--*/
BOOL CALLBACK EnumDesktopsFunc(LPTSTR lpstr, LPARAM lParam)
{
PTASK_LIST_ENUM te = (PTASK_LIST_ENUM)lParam;
HDESK hdeskSave;
HDESK hdesk;
DWORD ec;
//
// open the desktop
//
hdesk = OpenDesktop( lpstr, 0, FALSE, MAXIMUM_ALLOWED );
if (!hdesk)
{
return FALSE;
}
//
// save the current desktop
//
hdeskSave = GetThreadDesktop( GetCurrentThreadId() );
//
// change the context to the new desktop
//
if (!SetThreadDesktop( hdesk ))
{
ec = GetLastError();
SetThreadDesktop( hdeskSave );
if (g_hMainDesktop != hdesk)
{
CloseDesktop( hdesk );
}
if (g_hMainDesktop != hdeskSave)
{
CloseDesktop( hdeskSave );
}
return TRUE;
}
//
// Update the desktop in the enumerator
//
if (te->lpDesk)
{
LocalFree(te->lpDesk);
}
te->lpDesk = (LPTSTR) LocalAlloc( 0, (lstrlen(lpstr) + 1) * sizeof(TCHAR));
if (NULL == te->lpDesk)
{
if (hdesk != hdeskSave)
{
SetThreadDesktop( hdeskSave );
}
if (g_hMainDesktop != hdesk)
{
CloseDesktop( hdesk );
}
if (g_hMainDesktop != hdeskSave)
{
CloseDesktop( hdeskSave );
}
return FALSE;
}
else
{
lstrcpy(te->lpDesk, lpstr);
}
//
// enumerate all windows in the new desktop
//
EnumWindows( (WNDENUMPROC) EnumWindowsProc, lParam );
//
// restore the previous desktop
//
if (hdesk != hdeskSave)
{
SetThreadDesktop( hdeskSave );
}
if (g_hMainDesktop != hdesk)
{
CloseDesktop( hdesk );
}
if (g_hMainDesktop != hdeskSave)
{
CloseDesktop( hdeskSave );
}
return TRUE;
}
/*++
Routine Description:
Callback function for window enumeration.
Arguments:
hwnd - window handle
lParam - ** not used **
Return Value:
TRUE - continues the enumeration
--*/
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD pid = 0;
DWORD i;
PTASK_LIST_ENUM te = (PTASK_LIST_ENUM)lParam;
DWORD numTasks = te->m_pTasks->GetSize();
TCHAR szTitle[MAX_PATH];
if ((GetWindow( hwnd, GW_OWNER )) ||
(!IsWindowVisible(hwnd)))
{
//
// not a top level window, or not visible
//
return TRUE;
}
if (FALSE == InternalGetWindowText(hwnd, szTitle, ARRAYSIZE(szTitle)))
{
// Can't get the title - something weird going on.. but continue anyway
return TRUE;
}
if (TEXT('\0') == szTitle[0])
{
// Empty title - of little value in the task list
return TRUE;
}
if (hwnd == g_hMainWnd)
{
// Don't show the Task Manager in the list
return TRUE;
}
if (0 == lstrcmpi(szTitle, TEXT("Program Manager")))
{
// Don't show the Program Manager (explorer) in the list
return TRUE;
}
//
// look for the task in the task list for this window
//
for (i=0; i < numTasks; i++)
{
CTaskInfo * pTask = (CTaskInfo *) te->m_pTasks->GetAt(i);
if (pTask->m_hwnd == hwnd)
{
//
// Update the task info
//
if (FAILED(pTask->SetData(hwnd, szTitle, te->lpWinsta, te->lpDesk, te->uPassCount, TRUE)))
{
return FALSE;
}
pTask->m_uPassCount.QuadPart = te->uPassCount.QuadPart;
break;
}
}
if (i >= numTasks)
{
// Didn't find the task, it must be a new one
CTaskInfo * pTask = new CTaskInfo;
if (NULL == pTask)
{
return FALSE;
}
// Init the task data. If fails, delete and bail
if (FAILED(pTask->SetData(hwnd, szTitle, te->lpWinsta, te->lpDesk, te->uPassCount, FALSE)))
{
delete pTask;
return FALSE;
}
else
{
// Add the icons to the page's imagelist
if (!pTask->m_hLargeIcon && !pTask->m_hSmallIcon)
{
pTask->m_iLargeIcon = 0;
pTask->m_iSmallIcon = 0;
}
else
{
// The indices to the small and large icons for a task must
// always be the same; so, if one size is missing, use the icon
// of the other size (stretched). All the resizing is taken
// care of for us by ImageList_AddIcon(), since it's already
// had a fixed size set on it and will force any added icon
// into that size.
pTask->m_iLargeIcon = ImageList_AddIcon(te->m_pPage->m_himlLarge,
pTask->m_hLargeIcon ?
pTask->m_hLargeIcon
: pTask->m_hSmallIcon);
if (-1 == pTask->m_iLargeIcon)
{
delete pTask;
return FALSE;
}
pTask->m_iSmallIcon = ImageList_AddIcon(te->m_pPage->m_himlSmall,
pTask->m_hSmallIcon ?
pTask->m_hSmallIcon
: pTask->m_hLargeIcon);
if (-1 == pTask->m_iSmallIcon)
{
ImageList_Remove(te->m_pPage->m_himlLarge, pTask->m_iLargeIcon);
delete pTask;
return FALSE;
}
}
// All went well, so add it to the array
if (!(te->m_pTasks->Add( (LPVOID) pTask)))
{
delete pTask;
return FALSE;
}
}
}
//
// continue the enumeration
//
return TRUE;
}
/*++ TaskPageProc
Routine Description:
Dialogproc for the task manager page.
Arguments:
hwnd - handle to dialog box
uMsg - message
wParam - first message parameter
lParam - second message parameter
Return Value:
For WM_INITDIALOG, TRUE == success
For others, TRUE == this proc handles the message
Revision History:
Nov-28-95 Davepl Created
--*/
INT_PTR CALLBACK TaskPageProc(
HWND hwnd, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
CTaskPage * thispage = (CTaskPage *)(LONG_PTR) GetWindowLongPtr(hwnd, GWLP_USERDATA);
// See if the parent wants this message
if (TRUE == CheckParentDeferrals(uMsg, wParam, lParam))
{
return TRUE;
}
switch(uMsg)
{
case WM_INITDIALOG:
{
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)lParam);
CTaskPage * thispage = (CTaskPage *) lParam;
thispage->m_hPage = hwnd;
HWND hTaskList = GetDlgItem(hwnd, IDC_TASKLIST);
ListView_SetImageList(hTaskList, thispage->m_himlSmall, LVSIL_SMALL);
// Turn on SHOWSELALWAYS so that the selection is still highlighted even
// when focus is lost to one of the buttons (for example)
SetWindowLong(hTaskList, GWL_STYLE, GetWindowLong(hTaskList, GWL_STYLE) | LVS_SHOWSELALWAYS);
if (SHRestricted(REST_NORUN))
{
EnableWindow (GetDlgItem(hwnd, IDM_RUN), FALSE);
}
SetFocus(GetDlgItem(hwnd, IDC_TASKLIST));
SubclassListView(GetDlgItem(hwnd, IDC_PROCLIST));
return FALSE;
}
// We need to fake client mouse clicks in this child to appear as nonclient
// (caption) clicks in the parent so that the user can drag the entire app
// when the title bar is hidden by dragging the client area of this child
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
{
if (g_Options.m_fNoTitle)
{
SendMessage(g_hMainWnd,
uMsg == WM_LBUTTONUP ? WM_NCLBUTTONUP : WM_NCLBUTTONDOWN,
HTCAPTION,
lParam);
}
break;
}
case WM_COMMAND:
{
thispage->HandleWMCOMMAND(LOWORD(wParam));
break;
}
case WM_NOTIFY:
{
return thispage->HandleTaskPageNotify((HWND) wParam, (LPNMHDR) lParam);
}
case WM_MENUSELECT:
{
if ((UINT) HIWORD(wParam) == 0xFFFF)
{
// Menu dismissed, resume display
thispage->Unpause();
}
break;
}
case WM_CONTEXTMENU:
{
if ((HWND) wParam == GetDlgItem(hwnd, IDC_TASKLIST))
{
thispage->HandleTaskListContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return TRUE;
}
break;
}
// Size our kids
case WM_SIZE:
{
thispage->SizeTaskPage();
return TRUE;
}
case WM_SETTINGCHANGE:
thispage->OnSettingsChange();
// fall through
case WM_SYSCOLORCHANGE:
SendMessage(GetDlgItem(hwnd, IDC_TASKLIST), uMsg, wParam, lParam);
return TRUE;
default:
return FALSE;
}
return FALSE;
}
//-----------------------------------------------------------CTaskPage类函数----------------------------------------------------
/*++ CTaskPage::Activate
Routine Description:
Brings this page to the front, sets its initial position,
and shows it
Arguments:
Return Value:
HRESULT (S_OK on success)
Revision History:
Nov-28-95 Davepl Created
--*/
HRESULT CTaskPage::Activate()
{
// Make this page visible
ShowWindow(m_hPage, SW_SHOW);
SetWindowPos(m_hPage,
HWND_TOP,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
SetFocus(GetDlgItem(m_hPage, IDC_TASKLIST));
// Change the menu bar to be the menu for this page
HMENU hMenuOld = GetMenu(g_hMainWnd);
HMENU hMenuNew = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MAINMENU_TASK));
if (hMenuNew && SHRestricted(REST_NORUN))
{
DeleteMenu(hMenuNew, IDM_RUN, MF_BYCOMMAND);
}
g_hMenu = hMenuNew;
if (g_Options.m_fNoTitle == FALSE)
{
SetMenu(g_hMainWnd, hMenuNew);
}
if (hMenuOld)
{
DestroyMenu(hMenuOld);
}
return S_OK;
}
/*++ CTaskPage::Deactivate