[GH-ISSUE #139] How to make a transparent window? #60

Open
opened 2026-05-05 03:36:46 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @arthur-s on GitHub (Jan 23, 2023).
Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/139

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();

}
Originally created by @arthur-s on GitHub (Jan 23, 2023). Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/139 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(); } ```
Author
Owner

@OnlySamael commented on GitHub (Oct 6, 2023):

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();
}
<!-- gh-comment-id:1749881373 --> @OnlySamael commented on GitHub (Oct 6, 2023): 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(); } ```
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/ultimatepp#60
No description provided.