David Harouche
David Harouche

Reputation: 29

C++ Builder 5 and WinAPI, TransparentColor

What could be the alternative to TransparentColor and Transparent properties coming from CBuilder6, but absents of TForm in CBuilder5...

any WINAPI clue ?

DH

Upvotes: 1

Views: 111

Answers (2)

David Harouche
David Harouche

Reputation: 29

Here is my best answer :

void __fastcall TForm1::FormCreate(TObject *Sender) 

{ this->Align = ::alClient;
  this->Color = TColor(RGB(255, 255, 255)); 
 
 ::SetWindowLongPtr(this->Handle, GWL_EXSTYLE, WS_EX_LAYERED); 
 ::SetLayeredWindowAttributes(this->Handle, ::ColorToRGB(this->Color), 255, LWA_COLORKEY); 
}

Notice that I was compelled to have the TForm's Align property set to ::alClient...so the TForm became clickable even with LayerAttribute set to a COLOR_REF...

Thanks all... That, now, is usable...

DH

Upvotes: 0

Anders
Anders

Reputation: 101636

  • SetLayeredWindowAttributes can specify one color as a transparent color.

  • SetWindowRgn can also be used (and must be used on versions before Win2000). It however requires you to build the mask by yourself.

Upvotes: 1

Related Questions