Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Non-Square partially transparent Window (no border)  (Read 1968 times)

0 Members and 1 Guest are viewing this topic.

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Non-Square partially transparent Window (no border)
« on: February 10, 2018, 12:19:24 am »
I was away from SFML for a while, and needed to do some freshing up, but what I would firstly like to state is that SFML is such a great library, consistent, simple (on the surface), and it just works! Thanks to all who have made this possible over the years!

Some days ago I ducked some posts on this forum that seemed to answer my question, I've been clicking and ducking for an hour or so now, and cannot find it anymore, my bad... So, I up front apologise for the question, that I know already has an answer somewhere here on the forum.

What I would like to do is create a window (without borders, no problem), that is partially transparent (in the sense that one can see through parts of it, i.e. see what's behind it). I remember reading that this was, in general, not recommended, but possible on windows.

Could someone either point me to the relevant post(s) (Hapax or eXpl0it3r, if I remember well) or try and put me in the right direction. I'm on Windows 10/1709/x64 and use SFML trunk from a few days ago.

Thanks in advance.
« Last Edit: February 10, 2018, 12:40:04 am by degski »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Non-Square partially transparent Window (no border)
« Reply #1 on: February 10, 2018, 02:45:06 am »
Took me a while to get that people apparently are using "duck" as verb in the sense of using DuckDuckGo for searching. Seems weird and IMHO doesn't really work. Googling works because it's not a name and not already used for a different meaning... :-\

Quick search on the forum, brought up this thread which you may be referring to. Otherwise you can look at that link list Hapax posted once.

As a general tip for searching the forums, the search box at the top is context sensitive, so if you search while having this thread open, it will just search this thread. If you search in some sub-forum it will just search in that sub-forum. So the easiest way to search everywhere is to open the dedicated search page. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Non-Square partially transparent Window (no border)
« Reply #2 on: February 10, 2018, 03:29:30 pm »
"duckduckgoing" doesn't roll of my tongue easily, though...

The Hapax post was the one I was looking for, the list effectively... Next time I find something I might think I need in the future, I'll be pocketing it immediately ;)...

Thanks, eXpl0it3r (and Hapax)...


#include <SFML/Graphics.hpp>
#include <Windows.h>
#include <Dwmapi.h>

#pragma comment ( lib, "Dwmapi.lib" )

void makeWindowSeeThrough ( sf::RenderWindow & window ) noexcept {

    // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644898(v=vs.85).aspx
    // https://en.sfml-dev.org/forums/index.php?topic=21118.msg150860#msg150860

    // TODO: Add error checking...

    HWND hwnd = window.getSystemHandle ( );
    MARGINS margins;
    margins.cxLeftWidth = -1;
    SetWindowLongPtr ( hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE );
    DwmExtendFrameIntoClientArea ( hwnd, &margins );
}


I must say, I do share the OP's enthusiasm for this (is it a hack?)... StockTicker directly projected on the desktop, reminders, a game using a hex-shaped board (I never liked this, like sticking a square peg in a round hole)... the applications seem endless...

Yes it's windows only, surely some of the clever nix-coders can come up with an equivalent... after which this should (IMHO, of course) definitely be added to SFML...

Attached, an impression (it's a WIP) of what's possible..
« Last Edit: February 12, 2018, 02:51:01 am by degski »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Non-Square partially transparent Window (no border)
« Reply #3 on: February 17, 2018, 04:43:51 pm »
You're welcome :)

And what's wrong with just using the word "search"? :P
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything