Using 32bit Bitmap for Toobar? - winapi

We do use a Toolbar that is created with the Win32 CreateToolbarEx() function. Currently it uses a 24bit Bitmap for displaying the Buttons. Is there any possibility to use a 32bit Bitmap with Alpha blending for better displaying the Background of the toolbar buttons? Are 32bit Bitmaps with Alpha blending supported by this Toolbar?

Related

Semi-transparent pixel support in GDI+ Graphics.DrawImage() methods

I need to draw 32-bit PNG images with semi-transparent pixels loaded into an ImageList control on a Graphics when clip rectangles may be applied to this drawing. It turned out that I can't do this with the Graphics.DrawImage() method. The translucent pixels simply became gray when I tried to call some overloaded versions of Graphics.DrawImage.
As an example, look at the following picture:
The picture above was created with the following redefined OnPaint method of the form:
protected override void OnPaint(PaintEventArgs e)
{
imageList1.Draw(e.Graphics, 10, 30, 0);
e.Graphics.DrawImage(imageList1.Images[0], 10, 90);
base.OnPaint(e);
}
As you can see, the first ImageList.Draw() method based on the Win32 API ImageList_DrawEx function renders the translucent pixels correctly, while the GDI+ Graphics methods don't. I would be glad to use ImageList.Draw as it does the work correctly, but GDI+ clip rectangles do not work with it (because of its GDI nature).
Is there a way to draw 32-bit PNG images with semi-transparent pixels correctly with pure GDI+ methods if they can be limited by GDI+ clip rectangles?
If it may help, I uploaded the image into the ImageList control at design time this way:
Dropped the ImageList control onto the designer's surface.
Set the ColorDepth property to Depth32Bit.
Set the ImageSize property (48, 48 for that test icon).
Clicked the ellipsis button in the editor of the Images property and added the icon in the Images Collection Editor with its Add button.
The test Mobile Phone Icon of the size 48x48 I used can be downloaded from this source.
You might want to check the Graphics Property CompositingMode.
It should be set to
e.Graphics.CompositingMode = CompositingMode.SourceOver;.
If not, the graphics object is not using transparency. I assume that this is done implicitly by the ImageList control if you use its draw method.

Visual Studio / MFC: BMP fills Picture Control on desktop, but is too small on my laptop

I have a number of dialogs with Picture Controls. On my Win10 desktop, the BMP correctly fills the entire picture control, but on my Win10 laptop the BMP only fills about 2/3 of the picture control.
If I change Windows 10 "Scale and layout" setting from say 100% to 125% on both my desktop and laptop, then the dialog and BMP both get bigger/smaller, but the same problem exists: the BMP is significantly smaller than the control on my laptop.
In the Picture Control properties, Image is set to an IDB bitmap resource, and Type=Bitmap.
Is there an easy fix for this?
If you look here:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb760773(v=vs.85).aspx
You will see the following quote:
SS_REALSIZEIMAGE is always used in conjunction with SS_ICON.
You need to change your resource setting because yours is not an icon. That article also states:
SS_REALSIZECONTROL
Adjusts the bitmap to fit the size of the static control. For example, changing the locale can change the system font, and thus controls might be resized. If a static control had a bitmap, the bitmap would no longer fit the control. This style bit dictates automatic redimensioning of bitmaps to fit their controls.
If SS_CENTERIMAGE is specified, the bitmap or icon is centered (and clipped if needed). If SS_CENTERIMAGE is not specified, the bitmap or icon is stretched or shrunk.
Note that the redimensioning in the two axes are independent, and the result may have a changed aspect ratio.

How do I set a custom button background for a Metro app for all states

I want to use my own bitmaps for my buttons for a Metro style Windows 8 app. I can set the background brush for a button to my own ImageBrush and that works fine, except for the hover and pressed states. I cannot figure out how to set the bitmaps for them. Does anyone know how to do this?
Thanks.
WinRT XAML Toolkit has an ImageButton control that allows to define images for all states if that is what you need. You can also check its default template in Generic.xaml to see how it uses the bitmaps based on multiple overlaid Image controls (check e.g. PART_HoverStateImage) and visual states that control opacities of these Image controls.
If you are lazy - you can also use just two bitmaps and use semi-transparent bitmap defined using the PressedStateImageSource overlaid on top of the bitmap defined with IdleStateImageSource to show a hover state. Or you can go fully lazy and use just a single bitmap for idle state and let the control generate bitmaps for the other two states by setting GeneratePressedState and GenerateHoverState to true - that generates these bitmaps by "lightening" the idle state image with some basic image processing. The Toolkit also has a sample app with a page that demonstrates the use of the ImageButton control in multiple ways.

Is it possible to change the glass color only for my own forms?

I would like to create my application forms in the color independent from the user's color settings of the Aero. Is it possible to colorize my forms with the selected color without affecting the user's settings ?
This I want to do only for the Windows Aero colors.
Thanks
No, you can't do that, the glass composition color is system wide. As workaround you can draw a 32 bits bitmap of a solid color over the form using the Windows.AlphaBlend function.

How can I draw an image with alpha on a transparent canvas on Xorg?

I'm using Linux and I would like to create a transparent window and load in it an image with an alpha channel, so that the windows below show through the alpha channel. What's the simplest way of doing this? I'd use Python if possible, but I'm not fussy.
You can't directly do it with X11. It does not know what transparency is.
In order to draw a translucent window, your window manager (which must be a COMPOSITE window manager) has to provide this function.
So try studying your WM specs and see if and how it handles transparency.

Resources