@@ -209,12 +209,13 @@ unsafe HRESULT IDropTarget.Interface.Drop(IDataObject* dataObject, MODIFIERKEYS_
209209
210210 private static unsafe DragUI ? CreateDragUIForExternalDrag ( IDataObject * dataObject , FORMATETC [ ] formatEtcList )
211211 {
212- var dragUI = new DragUI ( PointerDeviceType . Mouse ) ;
212+ var dragUI = new DragUI ( ) ;
213213
214214 // Check if we have a DIB (Device Independent Bitmap) format
215- var dibFormat = formatEtcList . FirstOrDefault ( f => f . cfFormat == ( int ) CLIPBOARD_FORMAT . CF_DIB ) ;
216- if ( dibFormat . cfFormat ! = 0 )
215+ var dibFormatIndex = Array . FindIndex ( formatEtcList , f => f . cfFormat == ( int ) CLIPBOARD_FORMAT . CF_DIB ) ;
216+ if ( dibFormatIndex > = 0 )
217217 {
218+ var dibFormat = formatEtcList [ dibFormatIndex ] ;
218219 // Try to get the DIB data directly
219220 var hResult = dataObject ->GetData ( dibFormat , out STGMEDIUM dibMedium ) ;
220221 if ( hResult . Succeeded && dibMedium . u . hGlobal != IntPtr . Zero )
@@ -228,6 +229,15 @@ unsafe HRESULT IDropTarget.Interface.Drop(IDataObject* dataObject, MODIFIERKEYS_
228229 return dragUI ;
229230 }
230231 }
232+ catch ( Exception ex )
233+ {
234+ // If we can't load the image, continue without visual feedback
235+ var logger = typeof ( Win32DragDropExtension ) . Log ( ) ;
236+ if ( logger . IsEnabled ( LogLevel . Debug ) )
237+ {
238+ logger . LogDebug ( $ "Failed to load image thumbnail for drag operation: { ex . Message } ") ;
239+ }
240+ }
231241 finally
232242 {
233243 PInvoke . ReleaseStgMedium ( & dibMedium ) ;
@@ -236,9 +246,10 @@ unsafe HRESULT IDropTarget.Interface.Drop(IDataObject* dataObject, MODIFIERKEYS_
236246 }
237247
238248 // Check if we have file drop format
239- var hdropFormat = formatEtcList . FirstOrDefault ( f => f . cfFormat == ( int ) CLIPBOARD_FORMAT . CF_HDROP ) ;
240- if ( hdropFormat . cfFormat ! = 0 )
249+ var hdropFormatIndex = Array . FindIndex ( formatEtcList , f => f . cfFormat == ( int ) CLIPBOARD_FORMAT . CF_HDROP ) ;
250+ if ( hdropFormatIndex > = 0 )
241251 {
252+ var hdropFormat = formatEtcList [ hdropFormatIndex ] ;
242253 // Try to get the HDROP data directly
243254 var hResult = dataObject ->GetData ( hdropFormat , out STGMEDIUM hdropMedium ) ;
244255 if ( hResult . Succeeded && hdropMedium . u . hGlobal != IntPtr . Zero )
0 commit comments