Fix Drop file with SDL/Win32. implement it with plain win32
we have to handle both unicode and non unicode builds
This commit is contained in:
		
							parent
							
								
									cb2d479867
								
							
						
					
					
						commit
						01c6a9cd09
					
				
							
								
								
									
										13
									
								
								src/input.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/input.c
									
									
									
									
									
								
							@ -1014,10 +1014,23 @@ int Get_input(int sleep_time)
 | 
			
		||||
                    Drop_file_name=calloc(len+1,1);
 | 
			
		||||
                    if (Drop_file_name)
 | 
			
		||||
                    {
 | 
			
		||||
#ifdef UNICODE
 | 
			
		||||
                      TCHAR LongDropFileName[MAX_PATH];
 | 
			
		||||
                      TCHAR ShortDropFileName[MAX_PATH];
 | 
			
		||||
                      if (DragQueryFile(hdrop, 0 , LongDropFileName ,(UINT) MAX_PATH)
 | 
			
		||||
                        && GetShortPathName(LongDropFileName, ShortDropFileName, MAX_PATH))
 | 
			
		||||
                      {
 | 
			
		||||
                        int i;
 | 
			
		||||
                        for (i = 0; ShortDropFileName[i] != 0; i++)
 | 
			
		||||
                          Drop_file_name[i] = (char)ShortDropFileName[i];
 | 
			
		||||
                        Drop_file_name[i] = 0;
 | 
			
		||||
                      }
 | 
			
		||||
#else
 | 
			
		||||
                      if (DragQueryFile(hdrop,0 ,(LPTSTR) Drop_file_name ,(UINT) MAX_PATH))
 | 
			
		||||
                      {
 | 
			
		||||
                        // Success
 | 
			
		||||
                      }
 | 
			
		||||
#endif
 | 
			
		||||
                      else
 | 
			
		||||
                      {
 | 
			
		||||
                        free(Drop_file_name);
 | 
			
		||||
 | 
			
		||||
@ -166,6 +166,32 @@ static LRESULT CALLBACK Win32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
 | 
			
		||||
  case WM_CHAR:
 | 
			
		||||
    Key_ANSI = Key_UNICODE = wParam;
 | 
			
		||||
    return 0;
 | 
			
		||||
  case WM_DROPFILES:
 | 
			
		||||
    {
 | 
			
		||||
      int file_count;
 | 
			
		||||
      HDROP hDrop = (HDROP)wParam;
 | 
			
		||||
 | 
			
		||||
      file_count = DragQueryFile(hDrop, (UINT)-1, NULL , 0);
 | 
			
		||||
      if (file_count > 0)
 | 
			
		||||
      {
 | 
			
		||||
        TCHAR LongDropFileName[MAX_PATH];
 | 
			
		||||
        TCHAR ShortDropFileName[MAX_PATH];
 | 
			
		||||
        if (DragQueryFile(hDrop, 0 , LongDropFileName ,(UINT) MAX_PATH)
 | 
			
		||||
           && GetShortPathName(LongDropFileName, ShortDropFileName, MAX_PATH))
 | 
			
		||||
        {
 | 
			
		||||
          Drop_file_name = (char *)malloc(lstrlen(ShortDropFileName) + 1);
 | 
			
		||||
          if (Drop_file_name != NULL)
 | 
			
		||||
          {
 | 
			
		||||
            int i;
 | 
			
		||||
 | 
			
		||||
            for (i = 0; ShortDropFileName[i] != 0; i++)
 | 
			
		||||
              Drop_file_name[i] = (char)ShortDropFileName[i];
 | 
			
		||||
            Drop_file_name[i] = 0;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
  default:
 | 
			
		||||
    {
 | 
			
		||||
      char msg[256];
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user