SetBackgroundBitmap results in white background

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetBackgroundBitmap results in white background

Post by doublemax »

doublemax wrote: Thu Oct 21, 2021 7:32 pm As wxWidgets uses native controls where ever possible, this is your first show-stopper. You won't get semi-transparent controls over any background. You'd need custom controls for that.
Quoting and correcting myself. Under Windows 8 and up this should be possible, even if it may require platform specific code.
https://docs.microsoft.com/en-us/window ... attributes

So not all hope is lost :)
Use the source, Luke!
GamerX
Earned a small fee
Earned a small fee
Posts: 17
Joined: Wed Oct 20, 2021 3:06 pm

Re: SetBackgroundBitmap results in white background

Post by GamerX »

Thanks, I´ll have a look at these suggestions, although from my understanding, imGUI is more suited for 3D app and game overlays and kinda a bit overkill for an ordinary UI, unless I misunderstood the description of it on Github.

I really do need my application to be contained within a single exe, and ideally with as little overhead as possible. I also require access to other processes, so a sandboxed application is out of the question (e.g. Chrome based UI in a sandbox).

Apart from the wallpapers and the transparency, the GUI elements I need are very simple, just checkboxes, buttons and combo boxes.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: SetBackgroundBitmap results in white background

Post by PB »

GamerX wrote: Thu Oct 21, 2021 8:05 pm Thanks, I´ll have a look at these suggestions, although from my understanding, imGUI is more suited for 3D app and game overlays and kinda a bit overkill for an ordinary UI, unless I misunderstood the description of it on Github.
BTW, out of curiousity, I checked imGUI docs and it seems it may not have great PM DPI-awareness support:
https://github.com/ocornut/imgui/blob/m ... pplication

I think that you should check lists of GUI libraries for your preferred languages and filter them out. Starting with licence and maturity and then go on, there is not that many and then you ask on their communication channel if it has features you want. I guess for C++ FLTK is out of question as well, JUCE is probably not what you want...
GamerX
Earned a small fee
Earned a small fee
Posts: 17
Joined: Wed Oct 20, 2021 3:06 pm

Re: SetBackgroundBitmap results in white background

Post by GamerX »

I see, that´s unfortunate. Ideally I would really love to stick with wxWidgets, because it has this really awesome Validator functionality, which can save me a lot of coding. But I´m just afraid of getting stuck in a nightmare of bitmap shenanigans, just like with win32, I´m not really a friend of the whole PaintDC and MemoryDC etc. and GDI stuff, so i hoped that wxWidgets would kinda wrap all of this functionality up in some class or function, without me having to worry about what happens behind the scenes. Is there really no way to have an image being assigned to a window, automatically scaling with it when DPI changes (and ideally also automatically being scaled to fit the window upon initialization)? Apart from not even fitting the bitmap to the window, SetBackgroundBitmap also does not scale in any way when DPI changes either.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: SetBackgroundBitmap results in white background

Post by PB »

wxWidgets usually wraps a native control or provides a complex control in high demand (e.g., wxGrid). I suppose, image panel you want is neither. While such control would not be difficult to write it still costs time so I understand you are not willing to do that.

OTOH, you may not find a library that does all you want so you may have to compromise...

BTW, I do not really understand the demand of bitmap being rescaled when DPI changes. Rescaling bitmaps rarely leads to good results, image crispness is usually lost. Hence, bitmaps ought to be provided in all required resolution, which is often infeasible...
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetBackgroundBitmap results in white background

Post by doublemax »

GamerX wrote: Thu Oct 21, 2021 8:40 pm I see, that´s unfortunate. Ideally I would really love to stick with wxWidgets, because it has this really awesome Validator functionality, which can save me a lot of coding.
But I´m just afraid of getting stuck in a nightmare of bitmap shenanigans, just like with win32, I´m not really a friend of the whole PaintDC and MemoryDC etc. and GDI stuff, so i hoped that wxWidgets would kinda wrap all of this functionality up in some class or function, without me having to worry about what happens behind the scenes.
You'll probably have to deal with it, but it's really not that bad.
Is there really no way to have an image being assigned to a window, automatically scaling with it when DPI changes (and ideally also automatically being scaled to fit the window upon initialization)? Apart from not even fitting the bitmap to the window, SetBackgroundBitmap also does not scale in any way when DPI changes either.
wxCustomBackgroundWindow is indeed quite limited, but coding what you want is pretty easy - for someone with wxWidgets experience.

You won't find tailor-made solutions for all your requirements in any framework.
Use the source, Luke!
GamerX
Earned a small fee
Earned a small fee
Posts: 17
Joined: Wed Oct 20, 2021 3:06 pm

Re: SetBackgroundBitmap results in white background

Post by GamerX »

Yeah, I know that sadly there are no one size fits all frameworks, although WinUI3 was really close to being my choice, but the inability to ship as a single exe is my top priority after all, so that was a deal breaker.

Thanks again for all the help guys, I will consider all the information you provided me with before making a choice.
AmadeusK525
Experienced Solver
Experienced Solver
Posts: 61
Joined: Wed Aug 19, 2020 12:04 am

Re: SetBackgroundBitmap results in white background

Post by AmadeusK525 »

GamerX wrote: Thu Oct 21, 2021 7:23 pm 2) The GUI layout being: a custom "status" bar at the top, followed by a panel with controls below it, the panel has cycling background wallpapers, the controls have transparency and show the wallpaper behind them, the controls have a way to disable the annoying focus rectangle which just looks outdated on native win32, the controls don't flicker (not even when the wallpaper is changed mid runtime).
Hey, I have an application already released that sounds like what you're looking for. It's a Launcher for a game called 'Beyond The Forbidden Lands'. It's like, almost exactly what you described. If you wanna check it out, you can join this Discord server (https://discord.gg/9tNBGjMd2y), follow the rules and go to #releases to download the installer (I can't upload the installer here).

The reason I'm saying this is to show that making an application like this is, indeed, possible, it's just not pretty. The code is very hacky and it's not easy to mantain (nor is it good). To achieve the things you described, I used the wxShapeFramework. This is the repository for it if you're interested in looking at the code: https://github.com/BTFLDev/BTFL-Launcher. Since it's a side-project, I didn't have much time to really organize things, so the code is overall pretty messy. I'm gonna leave some images below, but I suggest you download the app to get a feel for it (it's not very heavy and it's a fast download).
image_2022-01-04_11-14-36.png
image_2022-01-04_11-16-11.png
image_2022-01-04_11-16-27.png
As you can see it's not even recognizable as a wxWidgets application. Of course, this all has some limitations: I can't make most controls look good - I wanted to use a picker of some sort but I have no idea how I'm gonna do that and make it look good in the program, as everything is very skinned. If I hadn't used wxWidgets for this, I wouldn't have this problem, but I like the library and I like the community so I decided to do so even if it'd bring me unnecessary headaches. Thinking back on it, it wasn't a very wise decision, but I wasn't in the mood to bloat my program with Electron or learn Qt from scratch :)
Post Reply