ultimatepp icon indicating copy to clipboard operation
ultimatepp copied to clipboard

How to make a transparent window?

Open arthur-s opened this issue 3 years ago • 1 comments

Hello, how to create transparent background of window? and without title bar (will be used for overlay). I tried next code, but window has black background:

#include <CtrlLib/CtrlLib.h>

 

using namespace Upp;

 

struct MyAppWindow : TopWindow {

    virtual void Paint(Draw& w) override {
		auto rgba = RGBA();
		rgba.r = 0;
		rgba.g = 0;
		rgba.b = 0;
		rgba.a = 50;
		
        w.DrawRect(GetSize(), Color(rgba));

        w.DrawText(20, 20, "Hello world!", Arial(30), Magenta);

    }

    

    MyAppWindow() {

        Title("My application").Transparent();

    }

};

 

GUI_APP_MAIN

{

    MyAppWindow app;

    app.SetRect(0, 0, 300, 200);
    app.Transparent();

    app.Run();

}

arthur-s avatar Jan 23 '23 08:01 arthur-s

This is the correct solution bro

#include <CtrlLib/CtrlLib.h>

using namespace Upp;
#define FIXED_COLORS
#define FIXED_SIZE

struct MyAppWindow : TopWindow {

   MyAppWindow() {

       Title("My application");
		Transparent();
		SetDarkThemeEnabled(false);
		
		SetRect(0, 0, 400, 100);
        SetAlpha(128);
   }

   void Paint(Draw& w) override {
		SetDarkThemeEnabled(false);
		
		Transparent();	
		SetAlpha(128);

   }

};

GUI_APP_MAIN
{
	

   MyAppWindow app;

   app.Run();
}

OnlySamael avatar Oct 06 '23 01:10 OnlySamael