fork download
  1. #include <SFML/Graphics.hpp>
  2. #include <Windows.h>
  3. #include <iostream>
  4. #include <cstring>
  5. #include <string>
  6.  
  7. TCHAR file_path[MAX_PATH];
  8.  
  9. LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  10. {
  11. switch (message)
  12. {
  13. case WM_DROPFILES:
  14. {
  15. HDROP hDrop = (HDROP)wParam;
  16. DWORD count_file = DragQueryFile(hDrop, 0xFFFFFFFF, file_path, sizeof(file_path)); // количество файлов
  17. for (int i = 0; i < count_file; i++)
  18. {
  19. DragQueryFile(hDrop, i, (LPSTR)file_path, sizeof(file_path)); // получаем путь в file_path
  20. }
  21. DragFinish(hDrop); // просто закрытие хендла
  22. }
  23. break;
  24. default:
  25. return DefWindowProc(hwnd, message, wParam, lParam);
  26. }
  27. return 0;
  28. }
  29.  
  30. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
  31. {
  32. sf::RenderWindow window(sf::VideoMode(200, 200), "Drag and Drop Test");
  33. window.setFramerateLimit(30);
  34.  
  35. DragAcceptFiles(window.getSystemHandle(), TRUE); // включение обработки drag and drop окна window
  36.  
  37. // SFML вывод текста
  38. sf::Font font;
  39. font.loadFromFile("arial.ttf");
  40.  
  41. sf::Text check_message;
  42. check_message.setFont(font);
  43. check_message.setCharacterSize(20);
  44. check_message.setColor(sf::Color::White);
  45. check_message.setString("none");
  46. //
  47.  
  48. while (window.isOpen())
  49. {
  50. sf::Event event;
  51. while (window.pollEvent(event))
  52. {
  53. if (event.type == sf::Event::Closed)
  54. window.close();
  55. }
  56.  
  57. /*GetMessage(&msg, 0, 0, 0);
  58. TranslateMessage(&msg); не робит
  59. DispatchMessage(&msg);*/
  60.  
  61. check_message.setString(std::to_string(std::strlen(file_path))); // 0 если путь пустой, и больше если работает
  62.  
  63. window.clear();
  64. window.draw(check_message);
  65. window.display();
  66. }
  67.  
  68. return 0;
  69. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:29: fatal error: SFML/Graphics.hpp: No such file or directory
 #include <SFML/Graphics.hpp>
                             ^
compilation terminated.
stdout
Standard output is empty