Is there a way to draw on form with canvas and then use the updatelayeredwindow so not the form will be visible but the text, like a transculent form showing only text? if not, then is there a way to make some sort of transculent form with only the canvas (opengl/directx) maybe? i would like to draw with commands on the top of all windows.
Asked
Active
Viewed 1,645 times
4
-
Does this link help ? : [how-to-make-a-transparent-form-when-a-vcl-style-is-enabled](http://stackoverflow.com/questions/8317617/how-to-make-a-transparent-form-when-a-vcl-style-is-enabled) – LU RD Dec 18 '11 at 23:08
-
thats helpful but im searching for a Transparent form, opaque AA label or something... – Knobik Dec 18 '11 at 23:12
-
1Do you want to create something like on screen displayed text ? If so, then take a look [here](http://stackoverflow.com/q/5200707/960757). [Dorin Duminica](http://stackoverflow.com/users/497849/dorin-duminica) created a component for it ;) – TLama Dec 18 '11 at 23:13
-
@TLama, thats almost exacly what im looking for, i think that with it i can create something that is static? – Knobik Dec 18 '11 at 23:22
-
i need the form to be totaly transculent :( this component cant help me sorry... – Knobik Dec 18 '11 at 23:26
1 Answers
7
You can set the TransparentColor
property of the form to 'True', then set the form color to the same color of TransparentColorValue
, and all of the form's client area will be transparent. If the Delphi version you use does not have the 'TransparentColor[Value]' properties you can achieve the same with API calls:
Color := clBlack;
SetWindowLong(Handle, GWL_EXSTYLE,
GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED );
SetLayeredWindowAttributes(Handle, 0, 255, LWA_COLORKEY);
will make the forms client area transparent. You can paint on the canvas as you normally would:
procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Font.Color := clWhite;
Canvas.TextOut(0, 0, 'Text');
end;
Of course you can also put a label on the form having a font color anything different then the transparent color.

Sertac Akyuz
- 54,131
- 4
- 102
- 169
-
this is soooo simple that i eaven forgot about that :) thats what i almost wanted. now i need to make it top-most and that i can click throu that :) – Knobik Dec 18 '11 at 23:28
-
1
-
TransparentColorValue and TransparentColor helped a bit BUT!... how to remove this white outline from that label? is there a way? [http://i42.tinypic.com/1z5lw7d.png](http://i42.tinypic.com/1z5lw7d.png) – Knobik Dec 18 '11 at 23:33
-
-
1
-
-
-
@Talibek - The label's font color should be different than the transparent color, the whole point is that one of the colors on the form's surface is made transparent. But I guess what you are seeing may be some antialisaing artifact due to changed background color. If so, you might need to drop using a label and play with 'lfQuality' of a 'LOGFONT'. Or try to achieve some outline effect by using more than one label having different font colors perhaps.. – Sertac Akyuz Dec 18 '11 at 23:51
-
2@Talibek - I can have a label without a visible outline by setting the background to a color that is slightly different than 'clWindowText'. F.i. `BgColor:=graphutil.ColorAdjustLuma(clWindowText,10,False)`, set form's 'Color', 'TransparentColorValue', and label's 'Color' to this value, label's font color would be 'clWindowText'. It helps getting rid of the outline but also reduces anti-aliasing so it now looks uglier. And when there's no outline, it's not visible when the color under the form is similar. I guess this is quite a different problem then transparency, consider asking a question. – Sertac Akyuz Dec 19 '11 at 00:25
-