Delphi create transparent window

326 views Asked by At

So i'v created a window using WinApi's CreateWindow function yet can't seem to make the hole window transparent, the window displays as full black or white not transparent what am i missing?

begin
  case uMsg of
    WM_DESTROY:
      begin
        Cleanup;
        PostQuitMessage(0);
        Result := 0;
        Exit;
      end;

    WM_PAINT:
      begin
        ValidateRect(hWnd, nil);
        Result := 0;
        Exit;
      end;
  end;

  Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
end;

    var
      wc: TWndClassEx = (cbSize: SizeOf(TWndClassEx); style: WS_EX_TRANSPARENT;
        lpfnWndProc: @MsgProc; cbClsExtra: 0; cbWndExtra: 0; hInstance: 0;
        hIcon: 0; hCursor: 0; hbrBackground: 0; lpszMenuName: nil;
        lpszClassName: 'Window'; hIconSm: 0);
    begin
      wc.hInstance := GetModuleHandle(nil);
      RegisterClassEx(wc);
    
      hWindow := CreateWindow('Window', '', 0, 0, 0, 300, 300,
        GetDesktopWindow, 0, wc.hInstance, nil);

  if SUCCEEDED(hWindow) then
  begin
    ShowWindow(hWindow, SW_SHOW);
    UpdateWindow(hWindow);

    while GetMessage(msg, 0, 0, 0) do
    begin
      TranslateMessage(msg);
      DispatchMessage(msg);
    end;
end;
1

There are 1 answers

0
Skalla On

I have used an image as parent for components and set the components to use parent