Prevent click on transparent form

I want to build a function in a form without a visible background of the form. Created TForm with TransparentColor set to True and TransParentColorValue set to clWhite. Just put a TImage on it, draw a function on the bitmap, assign it to the image, do a great job. There is one problem. I can no longer click on the form. Any click on the title of the form and the client area leads to a click in the base application. This is caused by setting the TransparentColor parameter to True. How can I prevent this “click”?

Update I tried Sertac's suggestions and I got some great results. I am preparing a bitmap as follows:

   Bitmap.Canvas.Brush.Color := clFuchsia;
   Bitmap.Canvas.FillRect (Rect (0, 0, Bitmap.Width, Bitmap.Height));

When the color is set to clWhite and Forms TransparentColorValue, the form is fully activated with the click of a button.

Both are installed in clBlack, the form can be moved, but the borders cannot be changed, and the system buttons do not work.

Both are installed in clFuchsia, it behaves like a regular form. Well, now it works, but maybe someone got an explanation?

+3
source share
1 answer

It would seem that the API acts strange when certain colors are used. White is obvious, black is a little less problematic. I tried with a yellow, gray, button face, fuchsia, etc., And they look fine.

If someone wants to duplicate the problem without using the Delphi 'Transparent ...' properties, here's a little snippet:

procedure TForm1.Button1Click(Sender: TObject);
var
  Color: DWORD;
  DC: HDC;
begin
  Color := $00FFFFFF;
  SetWindowLong(Handle, GWL_EXSTYLE,
      GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED );
  SetLayeredWindowAttributes(Handle, Color, 255, LWA_COLORKEY);

  DC := GetWindowDC(Handle);
  SetDCBrushColor(DC, Color);
  FillRect(DC, Rect(10, 10, 100, 80), GetStockObject(DC_BRUSH));
  ReleaseDC(Handle, DC);
end;


. , - .

+5

All Articles