forked from Open-Shell/Open-Shell-Menu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExplorerBHO.cpp
More file actions
1573 lines (1465 loc) · 52.4 KB
/
Copy pathExplorerBHO.cpp
File metadata and controls
1573 lines (1465 loc) · 52.4 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
// Classic Shell (c) 2009-2017, Ivo Beltchev
// Open-Shell (c) 2017-2018, The Open-Shell Team
// Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author
// ExplorerBHO.cpp : Implementation of CExplorerBHO
#include "stdafx.h"
#include "ExplorerBHO.h"
#include "Settings.h"
#include "ResourceHelper.h"
#include "resource.h"
#include "SettingsUI.h"
#include "Translations.h"
#include "SettingsUIHelper.h"
#include "DownloadHelper.h"
#include "FNVHash.h"
#include "dllmain.h"
#include <uxtheme.h>
#include <dwmapi.h>
#include <Ntquery.h>
#include <algorithm>
// CExplorerBHO - a browser helper object that implements Alt+Enter for the folder tree
const UINT_PTR TIMER_NAVIGATE='CLSH';
int CExplorerBHO::s_AutoNavDelay;
static void GetTreeItemPidl( HTREEITEM hItem, HWND hwndTree, PIDLIST_ABSOLUTE *result )
{
// find the PIDL of the tree item (combine all child PIDLs from the current item and its parents)
CAbsolutePidl pidl;
while (hItem)
{
TVITEMEX info={TVIF_PARAM,hItem};
TreeView_GetItem(hwndTree,&info);
PIDLIST_RELATIVE **pidl1=(PIDLIST_RELATIVE**)info.lParam;
if (!pidl1 || !*pidl1 || !**pidl1)
{
pidl.Clear();
break;
}
pidl.Attach(pidl?ILCombine((PIDLIST_ABSOLUTE)**pidl1,pidl):(PIDLIST_ABSOLUTE)ILClone(**pidl1));
hItem=TreeView_GetParent(hwndTree,hItem);
}
*result=pidl.Detach();
}
LRESULT CALLBACK CExplorerBHO::SubclassTreeParentProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
// when the tree selection changes start a timer to navigate to the new folder in 100ms
if (uMsg==WM_NOTIFY && ((NMHDR*)lParam)->code==TVN_SELCHANGED)
{
if (GetSettingInt(L"AutoNavigate")==2 || ((NMTREEVIEW*)lParam)->action==TVC_BYKEYBOARD)
SetTimer(((NMHDR*)lParam)->hwndFrom,TIMER_NAVIGATE,s_AutoNavDelay,NULL);
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
// Subclass the tree control to:
// - support Alt+Enter
// - navigate to the new folder when you go up/down with the keyboard
// - fix the random scrolling of the tree when a folder is expanded
// - change the tree styles to achieve different looks
LRESULT CALLBACK CExplorerBHO::SubclassTreeProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
if (uMsg==TVM_ENSUREVISIBLE && (dwRefData&1))
{
// HACK! there is a bug in Win7 Explorer and when the selected folder is expanded for the first time it sends TVM_ENSUREVISIBLE for
// the root tree item. This causes the navigation pane to scroll up. To work around the bug we ignore TVM_ENSUREVISIBLE if it tries
// to show the root item and it is not selected
HTREEITEM hItem=(HTREEITEM)lParam;
if (!TreeView_GetParent(hWnd,hItem) && !(TreeView_GetItemState(hWnd,hItem,TVIS_SELECTED)&TVIS_SELECTED))
return 0;
}
if (uMsg==WM_TIMER && wParam==TIMER_NAVIGATE)
{
// time to navigate to the selected folder (only if different from the current folder)
KillTimer(hWnd,TIMER_NAVIGATE);
if (GetFocus()!=hWnd)
return 0;
CAbsolutePidl pidl;
GetTreeItemPidl(TreeView_GetSelection(hWnd),hWnd,&pidl);
if (pidl)
{
bool bSameFolder=false;
CExplorerBHO *pThis=GetTlsData()->bho;
CComPtr<IShellView> pView;
if (pThis->m_pBrowser && SUCCEEDED(pThis->m_pBrowser->QueryActiveShellView(&pView)))
{
CComQIPtr<IFolderView> pView2=pView;
CComPtr<IPersistFolder2> pFolder;
CAbsolutePidl pidl2;
if (pView2 && SUCCEEDED(pView2->GetFolder(IID_IPersistFolder2,(void**)&pFolder)) && SUCCEEDED(pFolder->GetCurFolder(&pidl2)) && pidl2)
{
if (ILIsEqual(pidl,pidl2))
bSameFolder=true;
}
}
if (!bSameFolder)
SendMessage(hWnd,WM_KEYDOWN,VK_SPACE,0);
}
return 0;
}
// ignore the Alt+Enter syscharacter (to stop the tree view from beeping)
if (uMsg==WM_SYSCHAR && wParam==VK_RETURN)
return 0;
if (uMsg==WM_SYSKEYDOWN && wParam==VK_RETURN)
{
// Alt+Enter is pressed
// if this message was for the folder tree, show the properties of the selected item
if (GetSettingBool(L"AltEnter") && ShowTreeProperties(hWnd))
return 0;
}
if ((uMsg==WM_LBUTTONDOWN || uMsg==WM_LBUTTONDBLCLK) && (wParam&MK_CONTROL))
{
TVHITTESTINFO test;
test.pt.x=(short)LOWORD(lParam);
test.pt.y=(short)HIWORD(lParam);
HTREEITEM hItem=TreeView_HitTest(hWnd,&test);
if (test.flags&TVHT_ONITEM)
{
CAbsolutePidl pidl;
GetTreeItemPidl(hItem,hWnd,&pidl);
if (pidl)
{
CExplorerBHO *pThis=GetTlsData()->bho;
if (pThis->m_pBrowser)
{
pThis->m_pBrowser->BrowseObject(pidl,SBSP_NEWBROWSER|SBSP_ABSOLUTE);
}
}
}
return 0;
}
if (uMsg==TVM_SETEXTENDEDSTYLE && wParam==(TVS_EX_FADEINOUTEXPANDOS|TVS_EX_AUTOHSCROLL|0x80000000) && lParam==0)
{
wParam&=0x7FFFFFFF;
if (GetSettingInt(L"AutoNavigate")>0)
SetWindowSubclass(GetParent(hWnd),SubclassTreeParentProc,'CLSH',0);
if (!GetSettingBool(L"NoFadeButtons"))
wParam&=~TVS_EX_FADEINOUTEXPANDOS;
int indent=-1;
if (GetSettingBool(L"FullIndent"))
indent=0;
int treeStyle=GetSettingInt(L"TreeStyle");
if (treeStyle==STYLE_CLASSIC && GetWinVersion()>=WIN_VER_WIN10)
treeStyle=STYLE_VISTA;
DWORD style=GetWindowLong(hWnd,GWL_STYLE);
if (treeStyle!=STYLE_VISTA)
{
SetWindowTheme(hWnd,NULL,NULL);
if (treeStyle==STYLE_SIMPLE)
{
style|=TVS_SINGLEEXPAND|TVS_TRACKSELECT;
style&=~TVS_HASLINES;
}
else
{
style|=TVS_HASLINES;
style&=~(TVS_SINGLEEXPAND|TVS_TRACKSELECT);
wParam|=TVS_EX_FADEINOUTEXPANDOS;
HIMAGELIST images=TreeView_GetImageList(hWnd,TVSIL_NORMAL);
int cx, cy;
ImageList_GetIconSize(images,&cx,&cy);
indent=cx+3;
}
}
int scroll=GetSettingInt(L"HScrollbar");
if ((scroll==0 && treeStyle==STYLE_VISTA) || scroll==1)
wParam&=~TVS_EX_AUTOHSCROLL;
if ((scroll==0 && treeStyle!=STYLE_VISTA) || scroll==2)
style&=~TVS_NOHSCROLL;
SetWindowLong(hWnd,GWL_STYLE,style);
if (indent>=0)
TreeView_SetIndent(hWnd,indent);
int d=GetSettingInt(L"TreeItemSpacing");
if (d)
{
CExplorerBHO *pThis=GetTlsData()->bho;
pThis->m_TreeItemHeight=TreeView_GetItemHeight(hWnd)+d;
TreeView_SetItemHeight(hWnd,pThis->m_TreeItemHeight);
}
if (wParam==0)
return 0;
}
if (uMsg==WM_SETTINGCHANGE)
{
LRESULT res=DefSubclassProc(hWnd,uMsg,wParam,lParam);
int indent=-1;
if (GetSettingBool(L"FullIndent"))
indent=0;
if (GetSettingInt(L"TreeStyle")==STYLE_CLASSIC && GetWinVersion()<WIN_VER_WIN10)
{
HIMAGELIST images=TreeView_GetImageList(hWnd,TVSIL_NORMAL);
int cx, cy;
ImageList_GetIconSize(images,&cx,&cy);
indent=cx+3;
}
if (indent>=0)
TreeView_SetIndent(hWnd,indent);
return res;
}
if (uMsg==TVM_SETITEMHEIGHT)
{
CExplorerBHO *pThis=GetTlsData()->bho;
if (pThis->m_TreeItemHeight>0)
wParam=pThis->m_TreeItemHeight;
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
LRESULT CALLBACK CExplorerBHO::HookExplorer( int nCode, WPARAM wParam, LPARAM lParam )
{
// wait for the tree control to be created and subclass it
if (nCode==HCBT_CREATEWND)
{
HWND hWnd=(HWND)wParam;
CBT_CREATEWND *pCreate=(CBT_CREATEWND*)lParam;
if (pCreate->lpcs->lpszClass>(LPTSTR)0xFFFF && _wcsicmp(pCreate->lpcs->lpszClass,WC_TREEVIEW)==0)
{
HWND parent=GetAncestor(pCreate->lpcs->hwndParent,GA_ROOT);
wchar_t name[256];
if (GetClassName(parent,name,_countof(name)) && _wcsicmp(name,L"CabinetWClass")==0)
{
DWORD_PTR settings=0;
if (GetWinVersion()==WIN_VER_WIN7 && GetSettingBool(L"FixFolderScroll"))
settings|=1;
SetWindowSubclass(hWnd,SubclassTreeProc,'CLSH',settings);
PostMessage(hWnd,TVM_SETEXTENDEDSTYLE,TVS_EX_FADEINOUTEXPANDOS|TVS_EX_AUTOHSCROLL|0x80000000,0);
}
}
else if (pCreate->lpcs->lpszClass>(LPTSTR)0xFFFF && _wcsicmp(pCreate->lpcs->lpszClass,L"DUIViewWndClassName")==0)
{
TlsData *pTlsData=GetTlsData();
if (!pTlsData->bho->m_DUIView)
{
pTlsData->bho->m_DUIView=hWnd;
SetWindowSubclass(pTlsData->bho->m_DUIView,SubclassDUIViewProc,(UINT_PTR)pTlsData->bho,'CLSH');
}
}
}
return CallNextHookEx(NULL,nCode,wParam,lParam);
}
LRESULT CALLBACK CExplorerBHO::HookKeyboard( int nCode, WPARAM wParam, LPARAM lParam )
{
// wait for the tree control to be created and subclass it
if (nCode==HC_ACTION)
{
TlsData *pTlsData=GetTlsData();
if (wParam==pTlsData->bho->m_AltD && (lParam&0x20000000))
{
if (lParam&0x80000000)
{
return 0;
}
else
{
if (IsWindow(pTlsData->bho->m_Breadcrumbs) && IsWindowVisible(pTlsData->bho->m_Breadcrumbs))
{
SetFocus(pTlsData->bho->m_Breadcrumbs);
SendMessage(pTlsData->bho->m_Breadcrumbs,WM_KEYDOWN,VK_SPACE,0);
SendMessage(pTlsData->bho->m_Breadcrumbs,WM_KEYUP,VK_SPACE,0);
return 0;
}
}
}
if (wParam==(pTlsData->bho->m_UpHotkey&255) && !(lParam&0x80000000))
{
// Backspace goes to the parent folder, but only if no window has the caret
GUITHREADINFO info={sizeof(info)};
if (GetGUIThreadInfo(GetCurrentThreadId(),&info) && !info.hwndCaret)
{
bool bShift1=(pTlsData->bho->m_UpHotkey&(HOTKEYF_SHIFT<<8))!=0;
bool bCtrl1=(pTlsData->bho->m_UpHotkey&(HOTKEYF_CONTROL<<8))!=0;
bool bAlt1=(pTlsData->bho->m_UpHotkey&(HOTKEYF_ALT<<8))!=0;
bool bShift2=GetKeyState(VK_SHIFT)<0;
bool bCtrl2=GetKeyState(VK_CONTROL)<0;
bool bAlt2=GetKeyState(VK_MENU)<0;
if (bShift1==bShift2 && bAlt1==bAlt2)
{
if (bCtrl1==bCtrl2)
{
pTlsData->bho->m_pBrowser->BrowseObject(NULL,SBSP_SAMEBROWSER|SBSP_PARENT);
return 1;
}
else if (bCtrl2)
{
pTlsData->bho->m_pBrowser->BrowseObject(NULL,SBSP_NEWBROWSER|SBSP_PARENT);
return 1;
}
}
}
}
}
return CallNextHookEx(NULL,nCode,wParam,lParam);
}
bool CExplorerBHO::GetStatusText( wchar_t *buf, int size, const wchar_t *oldText, bool bShowTip, bool bShowSpace )
{
bool res=false;
CComPtr<IShellView> pView;
if (m_pBrowser && SUCCEEDED(m_pBrowser->QueryActiveShellView(&pView)))
{
CComQIPtr<IFolderView> pView2=pView;
CComPtr<IPersistFolder2> pFolder;
if (pView2 && SUCCEEDED(pView2->GetFolder(IID_IPersistFolder2,(void**)&pFolder)))
{
int count;
if (bShowTip && SUCCEEDED(pView2->ItemCount(SVGIO_SELECTION,&count)) && count==1)
{
// if only one item is selected, show its info in the status bar
CComPtr<IEnumIDList> pEnum;
PITEMID_CHILD child;
if (SUCCEEDED(pView2->Items(SVGIO_SELECTION,IID_IEnumIDList,(void**)&pEnum)) && pEnum && pEnum->Next(1,&child,NULL)==S_OK)
{
CComQIPtr<IShellFolder> pFolder2=pFolder;
if (pFolder2)
{
CComPtr<IQueryInfo> pQueryInfo;
if (SUCCEEDED(pFolder2->GetUIObjectOf(NULL,1,(PCUITEMID_CHILD*)&child,IID_IQueryInfo,NULL,(void**)&pQueryInfo)))
{
CComString pTip;
if (SUCCEEDED(pQueryInfo->GetInfoTip(QITIPF_DEFAULT|QITIPF_SINGLELINE,&pTip)) && pTip)
{
Strcpy(buf,size,pTip);
for (wchar_t *p=buf;*p;p++)
if (*p=='\t')
*p=' ';
res=true;
}
}
}
}
}
if (!res)
{
wchar_t buf2[256];
if (!oldText)
{
int count=-1;
const wchar_t *fmt=NULL;
if (SUCCEEDED(pView2->ItemCount(SVGIO_SELECTION,&count)) && count>0)
{
fmt=(count==1?FindTranslation(L"Status.ItemSelected",L"%s item selected"):FindTranslation(L"Status.ItemsSelected",L"%s items selected"));
}
else if (SUCCEEDED(pView2->ItemCount(SVGIO_ALLVIEW,&count)) && count>=0)
{
fmt=(count==1?FindTranslation(L"Status.Item",L"%s item"):FindTranslation(L"Status.Items",L"%s items"));
}
else
buf2[0]=0;
if (fmt)
{
wchar_t str1[100];
wchar_t str2[100];
Sprintf(str1,_countof(str1),L"%d",count);
NUMBERFMT numFmt;
wchar_t sep1[10], sep2[10];
numFmt.NumDigits=0;
GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_ILZERO,sep1,10);
numFmt.LeadingZero=_wtol(buf);
GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_INEGNUMBER,sep1,10);
numFmt.NegativeOrder=_wtol(buf);
GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SGROUPING,sep1,10);
numFmt.Grouping=0;
for (const wchar_t *p=sep1;*p;p++)
if (*p>='1' && *p<='9')
numFmt.Grouping=numFmt.Grouping*10+(*p-'0');
GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SDECIMAL,sep1,10);
numFmt.lpDecimalSep=sep1;
GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_STHOUSAND,sep2,10);
numFmt.lpThousandSep=sep2;
if (GetNumberFormat(LOCALE_USER_DEFAULT,0,str1,&numFmt,str2,_countof(str2)))
Sprintf(buf2,_countof(buf2),fmt,str2);
else
Sprintf(buf2,_countof(buf2),fmt,str1);
}
res=true;
}
if (bShowSpace)
{
// show the free space of the drive containing the current folder
// also works for network locations
CAbsolutePidl pidl;
wchar_t path[_MAX_PATH];
ULARGE_INTEGER diskSize;
if (SUCCEEDED(pFolder->GetCurFolder(&pidl)) && SHGetPathFromIDList(pidl,path) && GetDiskFreeSpaceEx(path,NULL,NULL,&diskSize))
{
wchar_t str[100];
StrFormatByteSize64(diskSize.QuadPart,str,_countof(str));
Sprintf(buf,size,FindTranslation(L"Status.FreeSpace",L"%s (Disk free space: %s)"),oldText?oldText:buf2,str);
res=true;
}
else if (!oldText)
Strcpy(buf,size,buf2);
}
else if (!oldText)
Strcpy(buf,size,buf2);
}
}
}
return res;
}
void CExplorerBHO::GetFileSize( wchar_t *buf, int size )
{
__int64 fileSize=-1;
CComPtr<IShellView> pView;
bool bMore=false;
int time0=GetTickCount();
if (m_pBrowser && SUCCEEDED(m_pBrowser->QueryActiveShellView(&pView)))
{
CComQIPtr<IFolderView> pView2=pView;
CComPtr<IPersistFolder2> pFolder;
CAbsolutePidl pidl;
if (pView2 && SUCCEEDED(pView2->GetFolder(IID_IPersistFolder2,(void**)&pFolder)) && SUCCEEDED(pFolder->GetCurFolder(&pidl)))
{
CComQIPtr<IShellFolder2> pFolder2=pFolder;
UINT type=SVGIO_SELECTION;
int count, selCount;
if (SUCCEEDED(pView2->ItemCount(SVGIO_ALLVIEW,&count)))
{
if ((FAILED(pView2->ItemCount(SVGIO_SELECTION,&selCount)) || selCount==0))
type=SVGIO_ALLVIEW;
CComPtr<IEnumIDList> pEnum;
if ((count<10000 || selCount<1000) && SUCCEEDED(pView2->Items(type,IID_IEnumIDList,(void**)&pEnum)) && pEnum)
{
PITEMID_CHILD child;
SHCOLUMNID column={PSGUID_STORAGE,PID_STG_SIZE};
int index=0;
while (pEnum->Next(1,&child,NULL)==S_OK)
{
index++;
if ((index%100)==0 && (GetTickCount()-time0)>500)
{
ILFree(child);
bMore=true;
break;
}
CComVariant var;
if (SUCCEEDED(pFolder2->GetDetailsEx(child,&column,&var)) && var.vt==VT_UI8)
{
if (fileSize<0)
fileSize=var.ullVal;
else
fileSize+=var.ullVal;
}
ILFree(child);
}
}
}
}
}
if (fileSize>=0)
{
// format the file size as KB, MB, etc
StrFormatByteSize64(fileSize,buf,size);
if (bMore)
Strcat(buf,size,L"+");
}
else
buf[0]=0;
}
// Subclass the statusbar to:
// - show free disk space
// - show the total size of the selected files
LRESULT CALLBACK CExplorerBHO::SubclassStatusProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
wchar_t buf[1024];
if (uMsg==WM_CLEAR)
{
// recalculate the selection size on a timer. this way if the status text is changed frequently
// the recalculation will not happen every time
SetTimer(hWnd,uIdSubclass,10,NULL);
}
if (uMsg==WM_PAINT && ((CExplorerBHO*)uIdSubclass)->m_bForceRefresh)
{
// sometimes Explorer doesn't fully initialize the status bar on Windows 7 and leaves it with 1 part
// in such case force the view to refresh after the status bar is fully visible
((CExplorerBHO*)uIdSubclass)->m_bForceRefresh=false;
if (SendMessage(hWnd,SB_GETPARTS,0,0)<=1)
PostMessage(GetParent(hWnd),WM_COMMAND,41504,0); // Refresh command
}
if (uMsg==SB_SETTEXT && LOWORD(wParam)==0)
{
// when the text of the first part is changing
if (dwRefData&SHOW_FREE_SPACE)
{
if (((CExplorerBHO*)uIdSubclass)->m_bResetStatus && SendMessage(hWnd,SB_GETPARTS,0,0)<=1)
{
// HACK! there is a bug in Win7 and when the Explorer window is created it doesn't correctly
// initialize the status bar to have 3 parts. as soon as the user resizes the window the
// 3 parts appear. so here we resize the parent of the status bar to create the 3 parts.
HWND parent=GetParent(hWnd);
RECT rc;
GetWindowRect(parent,&rc);
SetWindowPos(parent,NULL,0,0,rc.right-rc.left+1,rc.bottom-rc.top,SWP_NOZORDER|SWP_NOMOVE);
SetWindowPos(parent,NULL,0,0,rc.right-rc.left,rc.bottom-rc.top,SWP_NOZORDER|SWP_NOMOVE);
// the first time the status text is set it is too early. so we do this until we get at lest 2 parts
if (SendMessage(hWnd,SB_GETPARTS,0,0)>1)
((CExplorerBHO*)uIdSubclass)->m_bResetStatus=false;
}
}
if (((CExplorerBHO*)uIdSubclass)->GetStatusText(buf,_countof(buf),(wchar_t*)lParam,(dwRefData&SHOW_INFOTIP)!=0,(dwRefData&SHOW_FREE_SPACE)!=0))
lParam=(LPARAM)buf;
}
if (uMsg==SB_SETTEXT && LOWORD(wParam)==1)
{
return 0;
}
if (uMsg==WM_TIMER && wParam==uIdSubclass)
{
// recalculate the total size of the selected files and show it in part 2 of the status bar
KillTimer(hWnd,wParam);
((CExplorerBHO*)uIdSubclass)->GetFileSize(buf,_countof(buf));
DefSubclassProc(hWnd,SB_SETTEXT,1,(LPARAM)buf);
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
LRESULT CALLBACK CExplorerBHO::SubclassStatusProc8( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
wchar_t buf[1024];
if (uMsg==WM_CLEAR)
{
// recalculate the selection size on a timer. this way if the status text is changed frequently
// the recalculation will not happen every time
SetTimer(hWnd,uIdSubclass,10,NULL);
if (!((CExplorerBHO*)uIdSubclass)->GetStatusText(buf,_countof(buf),NULL,(dwRefData&SHOW_INFOTIP)!=0,(dwRefData&SHOW_FREE_SPACE)!=0))
buf[0]=0;
SendMessage(hWnd,SB_SETTEXT,PART_TEXT,(LPARAM)buf);
return 0;
}
if (uMsg==WM_TIMER && wParam==uIdSubclass)
{
// recalculate the total size of the selected files and show it in part 2 of the status bar
KillTimer(hWnd,wParam);
((CExplorerBHO*)uIdSubclass)->GetFileSize(buf,_countof(buf));
SendMessage(hWnd,SB_SETTEXT,PART_SIZE,(LPARAM)buf);
return 0;
}
if (uMsg==WM_LBUTTONDBLCLK)
{
POINT pt={(short)LOWORD(lParam),(short)HIWORD(lParam)};
RECT rc;
DefSubclassProc(hWnd,SB_GETRECT,PART_ZONE,(LPARAM)&rc);
if (PtInRect(&rc,pt))
{
CExplorerBHO *pThis=(CExplorerBHO*)uIdSubclass;
CComBSTR url;
if (pThis->m_pWebBrowser && SUCCEEDED(pThis->m_pWebBrowser->get_LocationURL(&url)))
{
// use undocumented function 383 from shlwapi
typedef void (WINAPI* FZoneConfigureW)(HWND,LPCWSTR);
FZoneConfigureW ZoneConfigureW;
HMODULE hShlwapi=LoadLibrary(L"shlwapi.dll");
if(hShlwapi)
{
ZoneConfigureW=(FZoneConfigureW)GetProcAddress(hShlwapi,MAKEINTRESOURCEA(383));
if(ZoneConfigureW)
ZoneConfigureW(GetAncestor(hWnd,GA_ROOT),url);
FreeLibrary(hShlwapi);
}
}
return 0;
}
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
// Subclass the DUIView to reduce its size and reposition the taskbar
LRESULT CALLBACK CExplorerBHO::SubclassDUIViewProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
CExplorerBHO *pThis=(CExplorerBHO*)uIdSubclass;
if (uMsg==WM_WINDOWPOSCHANGING && pThis->m_Status8)
{
WINDOWPOS *pPos=(WINDOWPOS*)lParam;
if (!(pPos->flags&SWP_NOSIZE))
{
RECT rc;
GetWindowRect(pThis->m_Status8,&rc);
int height=rc.bottom-rc.top;
pPos->cy-=height;
SetWindowPos(pThis->m_Status8,NULL,pPos->x,pPos->y+pPos->cy,pPos->cx,rc.bottom-rc.top,SWP_NOZORDER);
int parts[]={pPos->cx-height-pThis->m_FileSizeWidth-pThis->m_ZoneWidth,pPos->cx-height-pThis->m_ZoneWidth,-1};
SendMessage(pThis->m_Status8,SB_SETPARTS,pThis->m_ZoneWidth?3:2,(LPARAM)parts);
}
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
// Subclass the rebar in the title bar to handle the title bar Up button
LRESULT CALLBACK CExplorerBHO::SubclassRebarProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
if (uMsg==WM_NOTIFY && ((NMHDR*)lParam)->hwndFrom==(HWND)dwRefData && ((NMHDR*)lParam)->code==NM_CUSTOMDRAW)
{
// custom-draw the toolbar. just draw the correct icon and nothing else
NMTBCUSTOMDRAW *pDraw=(NMTBCUSTOMDRAW*)lParam;
if (pDraw->nmcd.dwDrawStage==CDDS_PREPAINT)
return CDRF_NOTIFYITEMDRAW;
if (pDraw->nmcd.dwDrawStage==CDDS_ITEMPREPAINT)
{
CExplorerBHO *pThis=(CExplorerBHO*)uIdSubclass;
BOOL comp;
if (SUCCEEDED(DwmIsCompositionEnabled(&comp)) && comp)
FillRect(pDraw->nmcd.hdc,&pDraw->nmcd.rc,(HBRUSH)GetStockObject(BLACK_BRUSH));
if (pDraw->nmcd.uItemState&CDIS_DISABLED)
{
if (pThis->m_IconDisabled)
DrawIconEx(pDraw->nmcd.hdc,0,0,pThis->m_IconDisabled,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
else
DrawIconEx(pDraw->nmcd.hdc,0,0,pThis->m_IconNormal,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
}
else if (pDraw->nmcd.uItemState&CDIS_SELECTED)
{
if (pThis->m_IconPressed)
DrawIconEx(pDraw->nmcd.hdc,0,0,pThis->m_IconPressed,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
else
DrawIconEx(pDraw->nmcd.hdc,1,1,pThis->m_IconNormal,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
}
else if (pDraw->nmcd.uItemState&CDIS_HOT)
{
if (pThis->m_IconHot)
DrawIconEx(pDraw->nmcd.hdc,0,0,pThis->m_IconHot,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
else
DrawIconEx(pDraw->nmcd.hdc,0,0,pThis->m_IconNormal,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
}
else
DrawIconEx(pDraw->nmcd.hdc,0,0,pThis->m_IconNormal,0,0,0,NULL,DI_NORMAL|DI_NOMIRROR);
return CDRF_SKIPDEFAULT;
}
}
if (uMsg==WM_THEMECHANGED)
{
// the button size is reset when the theme changes. force the correct size again
HWND toolbar=(HWND)dwRefData;
RECT rc;
GetClientRect(toolbar,&rc);
PostMessage(toolbar,TB_SETBUTTONSIZE,0,MAKELONG(rc.right,rc.bottom));
}
if (uMsg==WM_NOTIFY && ((NMHDR*)lParam)->hwndFrom==(HWND)dwRefData && ((NMHDR*)lParam)->code==TBN_GETINFOTIP)
{
// show the tip for the up button
NMTBGETINFOTIP *pTip=(NMTBGETINFOTIP*)lParam;
Strcpy(pTip->pszText,pTip->cchTextMax,FindTranslation(L"Toolbar.GoUp",L"Up One Level"));
return 0;
}
if (uMsg==WM_NOTIFY && ((NMHDR*)lParam)->hwndFrom==(HWND)dwRefData && ((NMHDR*)lParam)->code==NM_RCLICK)
{
NMMOUSE *pInfo=(NMMOUSE*)lParam;
POINT pt=pInfo->pt;
ClientToScreen(pInfo->hdr.hwndFrom,&pt);
ShowSettingsMenu(hWnd,pt.x,pt.y);
return TRUE;
}
if (uMsg==WM_COMMAND && wParam==1)
{
UINT flags=(GetKeyState(VK_CONTROL)<0?SBSP_NEWBROWSER:SBSP_SAMEBROWSER);
((CExplorerBHO*)uIdSubclass)->m_pBrowser->BrowseObject(NULL,flags|SBSP_PARENT);
}
CExplorerBHO *pThis=(CExplorerBHO*)uIdSubclass;
if (pThis->m_bRemapBands)
{
// HACK! Explorer doesn't use RB_IDTOINDEX every time it needs to access a particular band. Since we insert the Up button in the second
// position, the rest of the bands get offset and comedy ensues (the search box is not sized properly).
// To fix the issue, we renumber the bands so that from the outside ours appears to be last.
static int remapNewOld[2][4]={{3,0,1,2},{0,3,1,2}};
static int remapOldNew[2][4]={{1,2,3,0},{0,2,3,1}};
if (uMsg==RB_IDTOINDEX || uMsg==RB_HITTEST)
{
// remap the result from RB_IDTOINDEX and RB_HITTEST
LRESULT res=DefSubclassProc(hWnd,uMsg,wParam,lParam);
if (res<0 || res>3) return res;
res=remapNewOld[pThis->m_UpButtonIndex-1][res];
if (lParam && uMsg==RB_HITTEST) ((RBHITTESTINFO*)lParam)->iBand=(int)res;
return res;
}
if (uMsg==RB_GETBANDBORDERS || uMsg==RB_GETBANDINFO || uMsg==RB_GETRECT || uMsg==RB_SETBANDINFO || uMsg==RB_SETBANDWIDTH)
{
// remap wParam for all GET/SET messages
if (wParam>=0 && wParam<=3)
wParam=remapOldNew[pThis->m_UpButtonIndex-1][wParam];
}
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
// Subclass the breadcrumbs to make them show the full path
LRESULT CALLBACK CExplorerBHO::SubclassBreadcrumbProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
CExplorerBHO *pThis=(CExplorerBHO*)uIdSubclass;
if (*pThis->m_CurPath)
{
if (uMsg==WM_SETFOCUS)
{
if (wParam)
{
// see if the focus comes from the combo box. if so, most likely Escape was pressed, so just focus the main frame
HWND from=(HWND)wParam;
HWND combo=FindChildWindow(GetParent(GetParent(hWnd)),WC_COMBOBOXEX);
if (combo && (combo==from || IsChild(combo,from)))
{
SetFocus(GetAncestor(hWnd,GA_ROOT));
return 0;
}
}
// when the breadcrumbs are focused, switch to the combobox by simulating a mouse click
RECT rc;
GetClientRect(hWnd,&rc);
LPARAM pos=MAKELONG(rc.right-1,rc.bottom/2);
DefSubclassProc(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,pos);
DefSubclassProc(hWnd,WM_LBUTTONUP,0,pos);
return 0;
}
if (uMsg==WM_LBUTTONDOWN || uMsg==WM_LBUTTONDBLCLK || uMsg==WM_LBUTTONUP)
{
// unless the mouse is clicked on the icon, replace the mouse position with a point on the far right.
// this will cause Explorer to switch to the combobox even when a breadcrumb is clicked
int iconSize=GetSystemMetrics(SM_CXSMICON);
if (!pThis->m_CurIcon || (short)LOWORD(lParam)>iconSize+3)
{
RECT rc;
GetClientRect(hWnd,&rc);
lParam=MAKELONG(rc.right-1,rc.bottom/2);
}
}
if (uMsg==WM_PAINT)
{
// make the breadcrumbs control draw the full path like the XP address bar
RECT rc;
GetClientRect(hWnd,&rc);
PAINTSTRUCT ps;
HDC hdc=BeginPaint(hWnd,&ps);
// we need to use buffered painting because DrawThemeTextEx with DTT_COMPOSITED requires it
// on Vista DTT_COMPOSITED is required so that the black text doesn't get transparent. On Windows 7 regular DrawText seems to work fine
BP_PAINTPARAMS paintParams={sizeof(paintParams)};
paintParams.dwFlags=BPPF_ERASE;
HDC hdcPaint=NULL;
HPAINTBUFFER hBufferedPaint=BeginBufferedPaint(hdc,&rc,BPBF_TOPDOWNDIB,&paintParams,&hdcPaint);
if (hdcPaint)
{
rc.top++;
SendMessage(GetParent(GetParent(hWnd)),WM_PRINTCLIENT,(WPARAM)hdcPaint,PRF_CLIENT);
// draw icon
int iconSize=GetSystemMetrics(SM_CXSMICON);
if (pThis->m_CurIcon)
DrawIconEx(hdcPaint,rc.left+3,(rc.top+rc.bottom-iconSize)/2,pThis->m_CurIcon,iconSize,iconSize,0,NULL,DI_NORMAL);
rc.left+=iconSize+8; // Not a good idea to hard-code number of pixels, but seems to work fine for different DPI settings
// draw path
HFONT font=(HFONT)SendMessage(hWnd,WM_GETFONT,0,0);
HGDIOBJ font0=SelectObject(hdcPaint,font);
SetBkMode(hdcPaint,TRANSPARENT);
SetTextColor(hdcPaint,GetSysColor(COLOR_WINDOWTEXT));
HTHEME theme=GetWindowTheme(hWnd);
BOOL dwm;
if (theme && SUCCEEDED(DwmIsCompositionEnabled(&dwm)) && dwm)
{
DTTOPTS opts={sizeof(opts),DTT_COMPOSITED|DTT_TEXTCOLOR};
opts.crText=GetSysColor(COLOR_WINDOWTEXT);
DrawThemeTextEx(theme,hdcPaint,0,0,pThis->m_CurPath,-1,DT_NOPREFIX|DT_VCENTER|DT_SINGLELINE,&rc,&opts);
}
else
{
DrawText(hdcPaint,pThis->m_CurPath,-1,&rc,DT_NOPREFIX|DT_VCENTER|DT_SINGLELINE);
}
SelectObject(hdcPaint,font0);
EndBufferedPaint(hBufferedPaint,TRUE);
}
EndPaint(hWnd,&ps);
return 0;
}
}
return DefSubclassProc(hWnd,uMsg,wParam,lParam);
}
// Subclass the progress bar behind the address bar to remove the history and replace it with a list of parent folders
LRESULT CALLBACK CExplorerBHO::SubclassProgressProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
CExplorerBHO *pThis=(CExplorerBHO*)uIdSubclass;
if (uMsg==WM_PARENTNOTIFY && LOWORD(wParam)==WM_CREATE && !pThis->m_ComboBox.m_hWnd)
{
// on Windows 7 the combobox is not created at startup. so listen for child windows being created and update pThis->m_ComboBox
HWND combo=(HWND)lParam;
wchar_t className[256];
GetClassName(combo,className,_countof(className));
if (_wcsicmp(className,WC_COMBOBOXEX)==0)
pThis->m_ComboBox=combo;
}
if (uMsg==WM_COMMAND && (HWND)lParam==pThis->m_ComboBox.m_hWnd)
{
if (HIWORD(wParam)==CBN_DROPDOWN)
{
// on drop down refresh the list
pThis->ClearComboItems();
CComPtr<IShellFolder> pDesktop;
SHGetDesktopFolder(&pDesktop);
{
// add desktop
ITEMIDLIST shEmpty={{0}};
CComString pName;
if (SUCCEEDED(SHGetNameFromIDList((PIDLIST_ABSOLUTE)&shEmpty,SIGDN_DESKTOPABSOLUTEEDITING,&pName)))
{
ComboItem item={ILCloneFull((PIDLIST_ABSOLUTE)&shEmpty),0,CString(pName)};
pThis->m_ComboItems.push_back(item);
}
}
if (dwRefData==2)
{
// enumerate all desktop items
CComPtr<IEnumIDList> pEnum;
if (SUCCEEDED(pDesktop->EnumObjects(NULL,SHCONTF_FOLDERS,&pEnum)) && pEnum)
{
PITEMID_CHILD child;
while (pEnum->Next(1,&child,NULL)==S_OK)
{
STRRET str;
if (SUCCEEDED(pDesktop->GetDisplayNameOf(child,SHGDN_INFOLDER|SHGDN_NORMAL,&str)))
{
CComString pName;
StrRetToStr(&str,child,&pName);
ComboItem item={(PIDLIST_ABSOLUTE)child,1,CString(pName)};
item.sortName=item.name;
pThis->m_ComboItems.push_back(item);
}
else
ILFree(child);
}
}
// sort desktop items
std::sort(pThis->m_ComboItems.begin()+1,pThis->m_ComboItems.end());
}
if (dwRefData==2)
{
// enumerate all computer items
CAbsolutePidl pidlComp;
SHGetKnownFolderIDList(FOLDERID_ComputerFolder,0,NULL,&pidlComp);
int index=1;
for (int i=1;i<(int)pThis->m_ComboItems.size();i++)
if (ILIsEqual(pidlComp,pThis->m_ComboItems[i].pidl))
{
index=i+1;
break;
}
int index0=index;
CComPtr<IShellFolder> pComputer;
pDesktop->BindToObject(pidlComp,NULL,IID_IShellFolder,(void**)&pComputer);
CComPtr<IEnumIDList> pEnum;
if (pComputer && SUCCEEDED(pComputer->EnumObjects(NULL,SHCONTF_FOLDERS,&pEnum)) && pEnum)
{
PITEMID_CHILD child;
while (pEnum->Next(1,&child,NULL)==S_OK)
{
STRRET str;
if (SUCCEEDED(pComputer->GetDisplayNameOf(child,SHGDN_INFOLDER|SHGDN_NORMAL,&str)))
{
CComString pName;
StrRetToStr(&str,child,&pName);
ComboItem item={ILCombine(pidlComp,child),2,CString(pName)};
pThis->m_ComboItems.insert(pThis->m_ComboItems.begin()+index,1,item);
index++;
}
ILFree(child);
}
}
//sort computer items
std::sort(pThis->m_ComboItems.begin()+index0,pThis->m_ComboItems.begin()+index);
}
if (pThis->m_CurPidl)
{
// enumerate all parent items
CAbsolutePidl pidl(pThis->m_CurPidl);
PIDLIST_ABSOLUTE pidlStart=pidl;
int index=0;
for (int i=0;i<(int)pThis->m_ComboItems.size();i++)
{
PIDLIST_ABSOLUTE p=(PIDLIST_ABSOLUTE)ILFindChild(pThis->m_ComboItems[i].pidl,pidl);
if (p)
{
index=i;
pidlStart=p;
}
}
int n=0;
for (PUIDLIST_RELATIVE child=pidl;!ILIsEmpty(child);child=ILGetNext(child))
n++;
int start=n;
for (PUIDLIST_RELATIVE child=pidlStart;!ILIsEmpty(child);child=ILGetNext(child))
start--;
for (int i=start;i<n;i++)
{
wchar_t *pName=NULL;
CComPtr<IShellFolder> pFolder;
PCITEMID_CHILD child;
if (SUCCEEDED(SHBindToParent(pidl,IID_IShellFolder,(void**)&pFolder,&child)))
{
STRRET str;
if (SUCCEEDED(pFolder->GetDisplayNameOf(child,SHGDN_INFOLDER|SHGDN_NORMAL,&str)))
{
CComString pName;
StrRetToStr(&str,child,&pName);
ComboItem item={ILCloneFull(pidl),n-(i-start),CString(pName)};
pThis->m_ComboItems.insert(pThis->m_ComboItems.begin()+index+1,1,item);
}
}
ILRemoveLastID(pidl);
}
}
// add all sorted items to the combobox
COMBOBOXEXITEM item={CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE|CBEIF_INDENT|CBEIF_LPARAM};
item.iItem=-1;
for (std::vector<ComboItem>::const_iterator it=pThis->m_ComboItems.begin();it!=pThis->m_ComboItems.end();++it)
{
item.iImage=item.iSelectedImage=-1;
item.pszText=(LPWSTR)(LPCWSTR)it->name;
item.iIndent=it->indent;
item.lParam=(LPARAM)it->pidl;
SHFILEINFO info;
if (SHGetFileInfo((LPCTSTR)it->pidl,0,&info,sizeof(info),SHGFI_PIDL|SHGFI_SYSICONINDEX|SHGFI_SMALLICON))
item.iImage=item.iSelectedImage=info.iIcon;
int idx=(int)pThis->m_ComboBox.SendMessage(CBEM_INSERTITEM,'CLSH',(LPARAM)&item);
if (pThis->m_CurPidl && ILIsEqual(it->pidl,pThis->m_CurPidl))
pThis->m_ComboBox.SendMessage(CB_SETCURSEL,idx);
}
return 0;
}
if (HIWORD(wParam)==CBN_CLOSEUP || HIWORD(wParam)==CBN_SELENDCANCEL)
{
// on close clear the list
if (!pThis->m_ComboItems.empty())
{
pThis->m_ComboBox.SetWindowText(pThis->m_CurPath);
pThis->ClearComboItems();
}
if (HIWORD(wParam)==CBN_SELENDCANCEL)
PostMessage(hWnd,pThis->m_NavigateMsg,1,0);
return 0;
}
if (HIWORD(wParam)==CBN_SELENDOK)
{
// when an item is selected, go to it and clear the list (selection with mouse)
int index=(int)pThis->m_ComboBox.SendMessage(CB_GETCURSEL);
if (index>=0)
{
COMBOBOXEXITEM item={CBEIF_LPARAM,index};
pThis->m_ComboBox.SendMessage(CBEM_GETITEM,0,(LPARAM)&item);
pThis->m_NavigatePidl.Clone((PIDLIST_ABSOLUTE)item.lParam);
PostMessage(hWnd,pThis->m_NavigateMsg,0,0);
}
pThis->ClearComboItems();