Maybe most programmers will ask: What is the application value of transparent windows, especially transparent Panel? Don't underestimate them, let me talk about their huge role.
(1) Transparent window can be used for software interface effects. Everyone can see that many software's window appears or exit, which is gradually or gradually, not like Win98, and pops up the window. This is the function provided below Win2000. The implementation method is simple:
This-> alphablend = true;
this-> alphablendvalue = 100;
The code is this is the pointer of the window, of course, you can't call (nonsense) in the data module or other categories. The code changes the properties of the window: Alphablend and AlphablendValue. When Alphablend is True, the window is transparent. It is an opaque state when false; the alphablendvalue value is integer, and the range of 0 to 255 can be taken. It is full transparent, 255 is all opaque, of course, the value of the middle is half translucent. Cool). The window gradual or gradual effect Just set alphablend to True first, then gradually change the alphablendvalue value in a loop in a circular statement when the window is displayed or turned off, it is possible (don't forget to finish AlphablendValue. Window: this-> refresh ()). Note that the window is transparent, all controls above the window will follow the window transparent.
Is it so transparent in the window? NO !!! There is also more exciting. There are two attributes of the window class: TransparentColor and TransParentColorValue. First set the TransparentColor (Bool) to True, then set the TransparentColorValue (TCOLOR) to the color you want to be transparent, then the window will present a transparent state as long as there is such a color. (Cool) with Alphablend and AlphablendValue properties, you can make it can't think of. How to do it? Don't write it any more.
(2) Implementation method of transparent Panel. TPANel class has a big disadvantage: you can only set its color, if you want to put a BMP map above or you want to transparency; and it also has a big advantage: because he is from the TwinControl class, so it's top You can put other controls, and then it can be on the top of the same level control. What does the last sentence mean? You put a TPANEL control on the window, and put a TIMAGE control on the window. Now the parent of these two controls is a window, and these two controls belong to the same level, drag the Panel to Image to the image. Some, you will find that no matter how you don't operate the Panel, even if you use the bring to front or set to back command, if you replace the image to Panel, two panels can be covered no one can cover anyone . This is because Timage inherits from TGRAPHICCONTROL. And any controls that inherit the control from TGRAPHICCONTROL. You can also find that the TPANEL class does not have a Tcanvas property, so it cannot be painted on it.
How to achieve transparency, and can also display the panel of the background picture? The answer is that I re-made a panel coming out, limited to the space, I am not writing here, if you want, send me an e-mail: DECSENTANGLE@sohu.com. Then I will send you the control code again (don't worry, free). C Builder and Delphi code can be. What is the use of transparent panel? GOD Save Me, can be used properly, such as as a layer in the GIS system. Layer? Of course, if you have used Photoshop or Flash. First, transparent Panel can accept controls, then you can put some controls such as points, lines, faces, and maps to it, instead of using Tcanvas to draw them, using OOP (object-oriented programming) technology you can easily carry them. Operation, for example, when the user clicks on a line, you can use the online control to trigger it, and if you are drawn with Tcanvas, you have to determine whether the coordinates of the mouse click in this line. Of course, you can also use transparent Panel instead of ordinary panels to make a lot of interface effects.