#include <SFML/Graphics.hpp>
#include <Windows.h>
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
// window
sf::RenderWindow Window(sf::VideoMode(300, 400), "Window", sf::Style::None);
sf::Vector2i mousePos; // mouse coordinates relatively of window
bool grabbedWindow = false;
sf::Vector2i grabbedOffset;
sf::IntRect TaskBar(10, 24, (int)Window.getSize().x-10, 25); // pseudo title bar
// get image
sf::Image imgBackground;
imgBackground.loadFromFile("/path/to/image");
// background image
sf::Texture txBackground;
sf::Sprite sprBackground;
txBackground.loadFromImage(imgBackground);
sprBackground.setTexture(txBackground);
sf::Event Event;
while(Window.isOpen())
{
mousePos = sf::Mouse::getPosition(Window);
// events
while(Window.pollEvent(Event))
{
// closing
if(Event.type == sf::Event::Closed || (Event.type == sf::Event::KeyPressed && Event.key.code == sf::Keyboard::Escape))
Window.close();
// LMB
else if(Event.type == sf::Event::MouseButtonPressed && Event.mouseButton.button == sf::Mouse::Left)
{
// title bar contains mouse
if(TaskBar.contains(mousePos))
{
grabbedOffset = Window.getPosition() - sf::Mouse::getPosition();
grabbedWindow = true;
}
}
// LMB
else if(Event.type == sf::Event::MouseButtonReleased && Event.mouseButton.button == sf::Mouse::Left)
{
if(TaskBar.contains(mousePos))
grabbedWindow = false;
}
}
if(grabbedWindow)
Window.setPosition(sf::Mouse::getPosition() + grabbedOffset);
Window.clear(sf::Color::Transparent);
Window.draw(sprBackground);
Window.display();
}
}
/path/to/image - whatever .png image with outer shadows and without background color. I posted an example up in this thread.