Tuesday, 15 January 2013

transparency - How to move a transparent form without border in Delphi? -



transparency - How to move a transparent form without border in Delphi? -

i know , have used these methods create form without boders can moved. move form without border style

i'm using wmnchittest override. mousedown event don't work @ all.

this form simple displaying countdown, number changes sec , that's all. number beingness painted using big tlabel big fonts.

but made form transparent using delphi's standard form properties. now, if seek click on form move it, area can utilize lines drawing changing numbers, if not thin, not practical. i'd user able move numbers position of screen clicking anywhere near numbers, let's within "0" or "8".

i'd think drawing transparent rectangle on numbers , clickable area, effect same, click go throu.

i know application this, possible, how?

procedure tfrmcountdown.timer1timer(sender: tobject); begin icount := icount - 1; lbltime.caption := formatfloat('00', icount); end; procedure tfrmcountdown.formcreate(sender: tobject); begin icount := 60; borderstyle:=bsnone; self.color := clgray; self.transparentcolor := true; self.transparentcolorvalue := clgray; end; procedure tfrmcountdown.wmnchittest(var message: twmnchittest); var pt: tpoint; begin pt := screentoclient(smallpointtopoint(message.pos)); if pt.y < 160 message.result := htcaption else inherited; end;

vcl form transparency (by presume mean transparentcolor property, opposed alpha properties) uses layered windows accomplish transparent drawing. using technique transparent area of window not transparent visually respect nail testing.

i.e. using vcl form transparency, transparent areas in form may not exist @ all.

what work turn off vcl form transparency , instead implement form using ws_ex_transparent window style. enables visual transparency allows handle nail testing create different areas of form transparent, or not, respect clicks.

unfortunately ws_ex_transparent not finish "transparency" solution - tells windows form transparent, have take additional steps transparent, or interpret "transparent" means specific form.

this means complicates visual rendering of form , have override paint mechanism draw form. how describe content on form not sound arduous however, though far straightforward (i not have working illustration unfortunately).

at to the lowest degree best replace tlabel calls select appropriate font , render text window client area transparent background. there additional house keeping required.

in wm_nchittest handler, respond htnowhere areas of form wish interpreted "click through" areas, , htcaption areas wish back upwards dragging (i.e. describe, within part defined bounds of text).

unfortunately think find there lots of fiddly aspects implementation of painting transparent window.

delphi transparency vcl

No comments:

Post a Comment