Browser style tabs on the windows navigation bar - electron

I am designing a electron app that is geared to look like a browser (i.e., google chrome), with tabs on the navigation bar.
I want to keep the windows style buttons in the top right for closing, maximizing and minimizing and the border with Windows color.
Currently I am using a frameless electron window and attempting to replicate the Windows 10 GUI but I am coming into a few roadblocks.
How do I get the window color?
When un-focused Windows 10 gives a window a 1px transparent grey border. Any transparent border I create is overlayed against electron's window background and is not transparent.
Where can I find the windows resources to replicate the top right window buttons? I want this to look like windows, not a custom GUI.
Then come the difficulties of replicating this approach for something like the Aero Glass style of Windows 7. Is there a better way to do this? Say perhaps draw directly onto the window border in a way I am not aware of, or is this the only approach?

You have to get this information via a native module that accesses the winAPI. There are packages that will help you if your not familiar with writing the binding yourselfe.
https://www.npmjs.com/package/winapi
https://www.npmjs.com/package/win32api
You can make the window transperent and then add a margin to the html/body instead of using a border when unfocused. check the electron docs for how to make the window transperent.
You will need to consider the diffrences in DPI Windows7 / Windows 10 and also any further change on the windows 10 lifetime, they will definitly change the appearance over the years. Otherwise you could extract the SVG's and styling from here https://codepen.io/agrimsrud/pen/WGgRPP MS did not publish the files so there is no way to get the original ones.
If you want native windows you should not make the window frameless, i think adding the tab support for windows which actually exists should be added to electron. Maybe create a Issue on GitHub, i think the devs there can give you some better hints on how to archive what you want.

Related

Delphi 6 TDateTimePicker Windows Visual Theme support via Manifest

As per my previous question (Delphi 6 support for toolbar and menu icons with alpha channel transparency), we are updating a legacy application developed in Delphi 6 to support Windows Visual Themes by including a Manifest. This has worked well and we have the majority of controls adopting the Windows visual theme correctly.
However, we do have a problem with TDateTimePicker behaving in a slightly odd manner. We have the form colour set to white (RGB 255/255/255) and the input box for TDateTimePicker is not visible on the form until it is clicked into and has an entry in it. Please see screenshots below:
Changing the form colour to grey, we can see that the box is there when not selected, it just has no border drawn around it:
We have been unable to find a property that will change this behaviour. Can anyone shed some light on why this might be occurring, what property needs to be changed, or another method we could possibly use to resolve it?

Delphi XE5 Android TButton colors

I need change color of 50 buttons in one form.
Every button another color and color want to set by code(no design editor).
It is firemonkey mobile application.
By my opinion, without making your own button that doesn't use FMX styles completely (which would break multiplatform compatibility if you are looking forward to support multiple platforms with their native styles), you may apply some filter on top of each of those buttons but on some styles this may cause the text not to be visible, implementing your own filter might get you the desired result:
Effect:=TFillRGBEffect.Create(Self);
Effect.Color:=$80FF0000;
Effect.Parent:=SomeButton;
Another way would be to take advantage of TColorButton with TText on top of it, but this way the entire button won't be filled with your color, but you can modify default/custom style for each platform in order to get what you need (this indeed needs to be done in the designer but you would have to create just one style for each platform you need to support and not 50 for each button):
Button:=TColorButton.Create(Self);
Button.Color:=$80FF0000;
Text:=TText.Create(Button);
Text.Parent:=Button;
Text.Align:=TAlignLayout.alClient;
Text.Text:='Hello';
Text.HitTest:=false;
Button.ClipChildren:=true;
Button.Parent:=Self;

TComboBoxEx with VCL-Styles: Borders flicker

I`m using Delphi XE3. When using the custom styles (e.g. Carbon) that are available since Delphi XE2, there is a visible white flickering when moving the mouse over the borders of the TComboBoxEx control (MouseExit/Enter).
Steps to reproduce: Create a new VCL Forms app, drop a TComboBoxEx on the form, select e.g. Carbon in project options --> Application\Appearance and start the application
Is this a known problem/bug and is any solution known?
Thank you
This Border flicker issue is not the product of using Delphi VCL Styles.
(The same problem can be observed without using VCL styles)
The culprit here is the Desktop Window Manager which is an essential part of Windows Visual Styles and Themes.
The reason why you are seeing this issue and others may not, is because you have at some point changed the default Windows Theme (aero theme) or you've changed a specific Visual effect property of your selected theme.
You perhaps also have intentionally or unintentionally disabled the Desktop Window Manager since it runs as a Windows service.
To be more exact, the issue is resolved if you enable the Desktop composition feature.
This feature is only available in Aero themes(default) but not in Basic or Classic, tho sometimes it can appear to be available even when it is not.
Control Panel --> System --> Advanced System Settings --> Advanced --> Performance Settings --> Visual Effects
When desktop composition is enabled, individual windows no longer draw
directly to the screen or primary display device as they did in
previous versions of Windows. Instead, their drawing is redirected to
off-screen surfaces in video memory, which are then rendered into a
desktop image and presented on the display.
As you might have guessed, the functionality of this function is to basically act as a Buffer which in a very neat way explains the border flickering when this option is turned off.
Important Fact
Desktop composition feature can only be enabled if your current theme is an Aero theme and using Windows Visual Styles.(It is by default enabled for every Aero Theme)
Visual Styles are enabled by default in Aero Themes, you can check that it is enabled by making sure that the Use Visual Styles on Windows feature is enabled in the Performance Settings. When the Classic or Basic Themes are in effect the desktop composition feature is never in play and cannot be enabled. (Classic theme has been deprecated since Windows 8)
Sometimes in Windows 7, the Desktop composition feature can show itself in the Performance Options even when using a Basic or Classic Theme but do not be fooled, this is an internal bug.
Steps to reproduce this bug :
Start With default Windows Aero Theme
Go into Performance Settings as described above
Uncheck the Desktop composition from the list
Mouse over the border of TComboBoxEx, it should now be flickering as
you enter/leave.
But what happens if I uncheck Use Visual Styles on Windows checkbox? Why does this solve the flickering issue?
This will cause the Desktop Window Manager(DWM) to disable themes all together for all Windows Controls. What this means is that controls will be drawn using an older rendering style as oppose to using the newer Aero rendering style.
You can turn off Visual Styles for individual controls without turning it off globally with the following method SetWindowTheme(Handle, nil, nil)
This is also why the flickering issue for TComboBoxEx border is resolved when Visual Styles are disabled.
It's also worth mentioning that since Windows 8 you cannot disable Visual Styles anymore because as I said the Classic theme is deprecated.
Regarding the solution, I don't think you've got much of a choice really. Given how much freedom is left to the user when it comes to modifying the visual effects of Windows themes, this sort of thing is bound to happen. At least you can be certain that this issue does not happen on the default Windows Theme.

Transparency & runtime themes

When runtime themes are disabled for whole project, transparent images are drawn with black background. Is it possible to draw transparent image on button when runtime themes are disabled? The button I am using is from TMS Component Pack, its class name is TAdvToolButton. I need to have themes disabled because I want to fully control how application looks like. This is important request.
Please try to explain the connection between transparency & themes because I don't see it. I think these are two different things.

Change the color of the applications title bar

With Delphi 7 trying to change the color of the title bar of the software from the window theme. I have seen code which allows you to change ALL the title bars of all programs, but I am just wanting to change my program.
Anyone seen/done anything like this? Don't mind paying for a component if needed.
I believe Windows sends the WM_NCPAINT message to an application when it should paint the window frame including the title bar. The default behaviour is to fall back to the default Windows handler which draws the default frame. You could replace this, or re-paint the title-bar section right after.
This looks like a good example: http://delphi.about.com/od/adptips2006/qt/draw_captionbar.htm
The answer by Stijn is not fully complete, as the caption and border of the window will also be redrawn when it is (de-)activated. So in addition to WM_NCPAINT you will also need to handle WM_NCACTIVATE. Unfortunately this can not simply be replaced, as there is other code in the default message handler (apart from drawing code) that needs to be executed. But calling the default handler will in turn lead to the default caption and border being drawn first, which you would then need to draw over with your intended colour, resulting in flicker.
One way to work around this is to adjust the drawing region that the default message handler is called with. See "Drawing titlebar on XP with themes" for an example using Windows API calls that should easily translate to Delphi. Note that this deals only with the text in the caption bar, but the principle applies.
You might take a look at a skinning library. ExpressSkin by DevExpress is a good one.

Resources