Skip to content

Commit 607db5a

Browse files
committed
Paste CF_DIB/CF_DIBV5 in preference to CF_HDROP
1 parent a88b27e commit 607db5a

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

BmpHeaderViewer/BmpHeaderViewer.cpp

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -599,65 +599,7 @@ INT_PTR CALLBACK HeaderViewerDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPA
599599

600600
case IDC_PASTE:
601601
{
602-
if (IsClipboardFormatAvailable(CF_HDROP))
603-
{ // Open up to 100 files of a list pasted from the clipboard
604-
if (!OpenClipboard(hDlg))
605-
return FALSE;
606-
607-
HDROP hDrop = (HDROP)GetClipboardData(CF_HDROP);
608-
if (hDrop == NULL)
609-
{
610-
CloseClipboard();
611-
return FALSE;
612-
}
613-
614-
LPVOID lpDropFiles = GlobalLock(hDrop);
615-
if (lpDropFiles == NULL)
616-
{
617-
CloseClipboard();
618-
return FALSE;
619-
}
620-
621-
UINT nFiles = DragQueryFile(hDrop, (UINT)-1, NULL, 0);
622-
if (nFiles > 100)
623-
nFiles = 100;
624-
625-
if (nFiles == 0)
626-
{
627-
GlobalUnlock(hDrop);
628-
CloseClipboard();
629-
return FALSE;
630-
}
631-
632-
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
633-
HWND hwndEdit = GetDlgItem(hDlg, IDC_OUTPUT);
634-
635-
ClearOutputWindow(hwndEdit);
636-
637-
BOOL bSuccess = FALSE;
638-
for (UINT iFile = 0; iFile < nFiles; iFile++)
639-
{
640-
DragQueryFile(hDrop, iFile, s_szFileName, _countof(s_szFileName));
641-
642-
if (iFile > 0)
643-
Edit_ReplaceSel(hwndEdit, TEXT("\r\n"));
644-
645-
bSuccess = ParseFile(hDlg, s_szFileName) || bSuccess;
646-
}
647-
648-
GlobalUnlock(hDrop);
649-
CloseClipboard();
650-
651-
if (bSuccess && GetFocus() != hwndEdit)
652-
{
653-
SetFocus(hwndEdit);
654-
int nLen = Edit_GetTextLength(hwndEdit);
655-
Edit_SetSel(hwndEdit, nLen, nLen);
656-
}
657-
658-
SetCursor(hOldCursor);
659-
}
660-
else if (IsClipboardFormatAvailable(CF_DIB) || IsClipboardFormatAvailable(CF_DIBV5))
602+
if (IsClipboardFormatAvailable(CF_DIB) || IsClipboardFormatAvailable(CF_DIBV5))
661603
{ // Paste a DIBv3 or a DIBv5 from the clipboard
662604
if (!OpenClipboard(hDlg))
663605
return FALSE;
@@ -739,6 +681,64 @@ INT_PTR CALLBACK HeaderViewerDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPA
739681
Edit_SetSel(hwndEdit, nLen, nLen);
740682
}
741683

684+
SetCursor(hOldCursor);
685+
}
686+
else if (IsClipboardFormatAvailable(CF_HDROP))
687+
{ // Open up to 100 files of a list pasted from the clipboard
688+
if (!OpenClipboard(hDlg))
689+
return FALSE;
690+
691+
HDROP hDrop = (HDROP)GetClipboardData(CF_HDROP);
692+
if (hDrop == NULL)
693+
{
694+
CloseClipboard();
695+
return FALSE;
696+
}
697+
698+
LPVOID lpDropFiles = GlobalLock(hDrop);
699+
if (lpDropFiles == NULL)
700+
{
701+
CloseClipboard();
702+
return FALSE;
703+
}
704+
705+
UINT nFiles = DragQueryFile(hDrop, (UINT)-1, NULL, 0);
706+
if (nFiles > 100)
707+
nFiles = 100;
708+
709+
if (nFiles == 0)
710+
{
711+
GlobalUnlock(hDrop);
712+
CloseClipboard();
713+
return FALSE;
714+
}
715+
716+
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
717+
HWND hwndEdit = GetDlgItem(hDlg, IDC_OUTPUT);
718+
719+
ClearOutputWindow(hwndEdit);
720+
721+
BOOL bSuccess = FALSE;
722+
for (UINT iFile = 0; iFile < nFiles; iFile++)
723+
{
724+
DragQueryFile(hDrop, iFile, s_szFileName, _countof(s_szFileName));
725+
726+
if (iFile > 0)
727+
Edit_ReplaceSel(hwndEdit, TEXT("\r\n"));
728+
729+
bSuccess = ParseFile(hDlg, s_szFileName) || bSuccess;
730+
}
731+
732+
GlobalUnlock(hDrop);
733+
CloseClipboard();
734+
735+
if (bSuccess && GetFocus() != hwndEdit)
736+
{
737+
SetFocus(hwndEdit);
738+
int nLen = Edit_GetTextLength(hwndEdit);
739+
Edit_SetSel(hwndEdit, nLen, nLen);
740+
}
741+
742742
SetCursor(hOldCursor);
743743
}
744744
}

0 commit comments

Comments
 (0)