Ugly "disabled" images of TMainMenu - delphi

Delphi 2010, Win32 VCL. I need to create a main menu for my application with the most standard look. TMainMenu looks nice in all Windows versions, the only bad thing is when it displaying images for items with Enabled=False.
Delphi has some strange method for building that disabled images (b/w extrusion with bevels, for me it looks like spew). I want to make a patch for that procedure in VCL sources and let menu to select disabled images from the same TImageList, but I can't find it.
Is it exists at all or it is some standard windows API call? Do you know where is that procedure located?
Sure OwnerDraw style can fix all this but I want a bit faster solution.

There's a great post on Galfar's Lair blog which describes the problem, and has code for a workaround, overriding the TImageList DoDraw method.
Here's the pic (linked) showing the 'before' and 'after'.
I think this relates to pretty much all Delphi versions.

If you can provide your images as PNG you can use TPngImageList from PngComponents. It has different options to make a blended or grayscaled disabled image. The PNG format allows you to make use of alphablending.

Related

TImageList/TListview: correct design choice?

This is a question about picking the right Delphi components.
Using Delphi for a new app.
I'm looking to allow my user to have a list of (his own, on harddisk) pictures (just jpg for now, but should support different formats in the future), import them into my app, and then display them to him in a TListView. I was planning to tie that TListView to a TImageList (since this comes out of the box)... but when I tried, I ran into a set of weird problems about importing jpg's into a TImageList, reported here:
TImagelist not adding bitmap
So I'm wondering, am I using components for something they aren't intended for? Specifically, is the TImageList (even with some pre-formatting on import) useful for this kind of freestyle-all-sizes-and-formats-allowed stuff?
Any advice appreciated!
TImageList is designed to contain images of stored with the same format and size. If I am understanding correctly, TImageList doesn't do what you ask for.
TListView is tied to TImageList and therefore has the same limits. In my experience, a component flexible as you ask requires a custom component and manual drawing.
If you could change the requirement and decide a fixed size, you can preprocess the images making a thumbnail of the decided sizes and store them in the image list. This way you avoid building a component specific for your needs.

ImageList promises me Alphablending, but how do I enable it?

I want my buttons to have images with alphablending on them.
As instructed I've included a TXPManifest component on my mainform.
Below are some images I've loaded into my project.
However my BitBtn, which is linked to the imagelist via an ActionList still looks off.
<<-- It looks like this at runtime, Yikes!
How do I get Delphi 2007 running on my Windows 7 laptop to actually use the alpha channel the ImageList keeps teasing me with?
In response to #RRUZ, here are the imagelist properties:
(Note the absence of a colordepth property)
EDIT
The alpha-blending does work with the TMS AdvGlowButton:
So it's probably not a ImageList issue, as much as it is an BitBtn issue.
UPDATE 2
Downloaded and installed PngComponents. Putting a TPNGImageList on a blank form instantly crashes D2007. (Maybe something in the settings/path/etc, but I'm drifting too far from the original issue so I'm dropping the png pursuit).
So that doesn't work.
I suggest you to refer to Anders Melander's Blog.
Hes has published 2 relevant posts both related to alpha blending under Delphi 2007:
Alpha Blended Splash Screen in Delphi - Part 1
Alpha Blended Splash Screen in Delphi - Part 2
Very instructives.

Delphi: image with alpha blending capabilities

Is there some simple component that could display PNG 32-bit images and alpha-blend it to another image on mouse enter and on mouse leave? Or even just a simple image that can load 32-bit PNG and additionally would have Alpha parameter...
I suppose I could use some skin library (alphacontrols?) or some graphics library, but for some simple purely visual effects that would be quite an overkill and I can't seem to find a simple one that does it for me and would work on Glass surface as well...
It is not quite a component, but here is a link to a good article on how to do it yourself. Its just a few lines of code:
http://melander.dk/articles/alphasplash/
The basic TImage is capable of displaying a PNG image and alpha-blend-it to whatever is behind it. You just need to add the "pngimage" unit to the uses clause of your form. You didn't mention the version of Delphi you're on: Delphi 2010 has this unit, but I have no idea with what version of Delphi they started shipping it. For Delphi 7 I know for sure you'll need to find the open source "pngimage".
If you need to do this when the user moves in and out of your control, consider caching the state images in bitmaps: it will be faster at runtime and you can use a single TImage that shows the current image, you don't need two overlapping TIMage controls.

How to make the form into fully transparent 32bit alpha?

i use to create a full transparent form, but the png and the 32bit image will not blend to the form and images is not properly displayed its trnsparency. i get the concept here but i cannot put button on it. all abject are invisible except the image backgound. by the way my compiler is delphi7 and D2009
Seems that Andreas Hausladen stumbled upon a similar problem and has already implemented a solution: he rewrote TJvTransparentForm in the JVCL library.
Even if you are not going to use that component directly you may gain some insight by studying the source.
Here is the link to Andreas' article.
If you want to use a PNG to control transparency you might want to look into "layered windows":
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED);
UpdateLayeredWindow
This allows you to have variable transparency accross the window, just as PNG allows! The problem is, controls on layered windows don't really work, I guess it's a Windows issue. My solution was to actually brake up the big window into multiple smaller windows, with all the controls on non-layered windows. This creates yet an other problem, because you now have multiple windows and you want them to move like a single window. The solution: implement your own algorithm for moving the window accross the screen and use:
BeginDeferWindowPos
DeferWindowPos
EndDeferWindowPos
... to move all windows at once, so the user has no idea she's looking at multiple windows! Finally, if you want to get fancy, you might want to look into SetWindowRgn: this allows you to create a window with a non-rectangular shape.
P.S: Reading Andrea's link from Uwe Raabe, he's using the same technique, only he packaged it ready for action!

Looking for a simple graphical component for Delphi

I am looking for a graphical component in Delphi winch have such features:
allows to paint text in different font types, sizes and colors
allows to select previously drawn text and copy it
paints images on a given coords, gif support would be nice
its very fast in terms of CPU usage
I need this component as a main chat window. I don't want to use it as a text editor.
I've tried two solutions so far:
TVirtualStringTree
THtml
Currently I am using THtml. It performs quite nice but it is a bit to slow due to two facts:
It supports many features which are not necessary in my case
Each time I want to add some content to it, I must reload the whole content
I really don't want to go into its sources and modify them until I have no other choice. So maybe someone of you knows some nice lightweight component which I can use instead?
Take a look at TRichView. It's derived from TCustomControl so no external dependencies. It's third party commercial component, but a very good one. Skype Win client uses it.
What about a TRichEdit? Most of the things you mention should be easiliby possible with this component.
Concering the insertion of a bitmap, see this article on Delphi 3000.
Did you consider using TWebBrowser?
At least it ticks all your boxes...

Resources