@@ -275,7 +275,7 @@ HRESULT GetDatedFileName(_Out_ PWSTR result, UINT cchMax, _In_ PCWSTR source, SY
275
275
return hr;
276
276
}
277
277
278
- HRESULT _GetShellItemArrayFromDataOject (_In_ IUnknown* dataSource, _COM_Outptr_ IShellItemArray** items)
278
+ HRESULT GetShellItemArrayFromDataObject (_In_ IUnknown* dataSource, _COM_Outptr_ IShellItemArray** items)
279
279
{
280
280
*items = nullptr ;
281
281
CComPtr<IDataObject> dataObj;
@@ -292,73 +292,6 @@ HRESULT _GetShellItemArrayFromDataOject(_In_ IUnknown* dataSource, _COM_Outptr_
292
292
return hr;
293
293
}
294
294
295
- HRESULT _ParseEnumItems (_In_ IEnumShellItems* pesi, _In_ IPowerRenameManager* psrm, _In_ int depth = 0 )
296
- {
297
- HRESULT hr = E_INVALIDARG;
298
-
299
- // We shouldn't get this deep since we only enum the contents of
300
- // regular folders but adding just in case
301
- if ((pesi) && (depth < (MAX_PATH / 2 )))
302
- {
303
- hr = S_OK;
304
-
305
- ULONG celtFetched;
306
- CComPtr<IShellItem> spsi;
307
- while ((S_OK == pesi->Next (1 , &spsi, &celtFetched)) && (SUCCEEDED (hr)))
308
- {
309
- CComPtr<IPowerRenameItemFactory> spsrif;
310
- hr = psrm->GetRenameItemFactory (&spsrif);
311
- if (SUCCEEDED (hr))
312
- {
313
- CComPtr<IPowerRenameItem> spNewItem;
314
- hr = spsrif->Create (spsi, &spNewItem);
315
- if (SUCCEEDED (hr))
316
- {
317
- spNewItem->PutDepth (depth);
318
- hr = psrm->AddItem (spNewItem);
319
- }
320
-
321
- if (SUCCEEDED (hr))
322
- {
323
- bool isFolder = false ;
324
- if (SUCCEEDED (spNewItem->GetIsFolder (&isFolder)) && isFolder)
325
- {
326
- // Bind to the IShellItem for the IEnumShellItems interface
327
- CComPtr<IEnumShellItems> spesiNext;
328
- hr = spsi->BindToHandler (nullptr , BHID_EnumItems, IID_PPV_ARGS (&spesiNext));
329
- if (SUCCEEDED (hr))
330
- {
331
- // Parse the folder contents recursively
332
- hr = _ParseEnumItems (spesiNext, psrm, depth + 1 );
333
- }
334
- }
335
- }
336
- }
337
-
338
- spsi = nullptr ;
339
- }
340
- }
341
-
342
- return hr;
343
- }
344
-
345
- // Iterate through the data source and add paths to the rotation manager
346
- HRESULT EnumerateDataObject (_In_ IUnknown* dataSource, _In_ IPowerRenameManager* psrm)
347
- {
348
- CComPtr<IShellItemArray> spsia;
349
- HRESULT hr = E_FAIL;
350
- if (SUCCEEDED (_GetShellItemArrayFromDataOject (dataSource, &spsia)))
351
- {
352
- CComPtr<IEnumShellItems> spesi;
353
- if (SUCCEEDED (spsia->EnumItems (&spesi)))
354
- {
355
- hr = _ParseEnumItems (spesi, psrm);
356
- }
357
- }
358
-
359
- return hr;
360
- }
361
-
362
295
BOOL GetEnumeratedFileName (__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax, __in PCWSTR pszTemplate, __in_opt PCWSTR pszDir, unsigned long ulMinLong, __inout unsigned long* pulNumUsed)
363
296
{
364
297
PWSTR pszName = nullptr ;
@@ -528,7 +461,7 @@ bool DataObjectContainsRenamableItem(_In_ IUnknown* dataSource)
528
461
{
529
462
bool hasRenamable = false ;
530
463
CComPtr<IShellItemArray> spsia;
531
- if (SUCCEEDED (_GetShellItemArrayFromDataOject (dataSource, &spsia)))
464
+ if (SUCCEEDED (GetShellItemArrayFromDataObject (dataSource, &spsia)))
532
465
{
533
466
CComPtr<IEnumShellItems> spesi;
534
467
if (SUCCEEDED (spsia->EnumItems (&spesi)))
@@ -549,3 +482,30 @@ bool DataObjectContainsRenamableItem(_In_ IUnknown* dataSource)
549
482
}
550
483
return hasRenamable;
551
484
}
485
+
486
+ HWND CreateMsgWindow (_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void * p)
487
+ {
488
+ WNDCLASS wc = { 0 };
489
+ PCWSTR wndClassName = L" MsgWindow" ;
490
+
491
+ wc.lpfnWndProc = DefWindowProc;
492
+ wc.cbWndExtra = sizeof (void *);
493
+ wc.hInstance = hInst;
494
+ wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1 );
495
+ wc.lpszClassName = wndClassName;
496
+
497
+ RegisterClass (&wc);
498
+
499
+ HWND hwnd = CreateWindowEx (
500
+ 0 , wndClassName, nullptr , 0 , 0 , 0 , 0 , 0 , HWND_MESSAGE, 0 , hInst, nullptr );
501
+ if (hwnd)
502
+ {
503
+ SetWindowLongPtr (hwnd, 0 , (LONG_PTR)p);
504
+ if (pfnWndProc)
505
+ {
506
+ SetWindowLongPtr (hwnd, GWLP_WNDPROC, (LONG_PTR)pfnWndProc);
507
+ }
508
+ }
509
+
510
+ return hwnd;
511
+ }
0 commit comments