#include <SFML/Graphics.hpp>
#include <Windows.h>
#include <iostream>
#include <cstring>
#include <string>

TCHAR file_path[MAX_PATH];

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_DROPFILES:
			{
				HDROP hDrop = (HDROP)wParam; 
				DWORD count_file = DragQueryFile(hDrop, 0xFFFFFFFF, file_path, sizeof(file_path)); // количество файлов
				for (int i = 0; i < count_file; i++)
				{
					DragQueryFile(hDrop, i, (LPSTR)file_path, sizeof(file_path)); // получаем путь в file_path
				}
				DragFinish(hDrop); // просто закрытие хендла
			} 
			break;
		default:
			return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
	sf::RenderWindow window(sf::VideoMode(200, 200), "Drag and Drop Test");
	window.setFramerateLimit(30);

	DragAcceptFiles(window.getSystemHandle(), TRUE); // включение обработки drag and drop окна window 

	// SFML вывод текста
	sf::Font font;
	font.loadFromFile("arial.ttf");

	sf::Text check_message;
	check_message.setFont(font);
	check_message.setCharacterSize(20);
	check_message.setColor(sf::Color::White);
	check_message.setString("none");
	//

	while (window.isOpen())
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
				window.close();
		}
		
		/*GetMessage(&msg, 0, 0, 0);
		TranslateMessage(&msg);           не робит
		DispatchMessage(&msg);*/
		
		check_message.setString(std::to_string(std::strlen(file_path))); // 0 если путь пустой, и больше если работает 
		
		window.clear();
		window.draw(check_message);
		window.display();
	}

	return 0;
}