Home > Blockchain >  C Builder 5 and WinAPI, TransparentColor
C Builder 5 and WinAPI, TransparentColor

Time:01-16

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

any WINAPI clue ?

DH

CodePudding user response:

  • 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.

CodePudding user response:

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

  •  Tags:  
  • Related