读书人

bcb2010 窗体透明有关问题

发布时间: 2012-04-19 14:36:43 作者: rapoo

bcb2010 窗体透明问题

C/C++ code
void __fastcall TForm1::FormCreate(TObject *Sender){        long IRt=GetWindowLong(Handle,GWL_EXSTYLE);        IRt=IRt|WS_EX_LAYERED;        SetWindowLong(Handle,GWL_EXSTYLE,IRt);        SetLayeredWindowAttributes(Handle,clBlue,200,LWA_ALPHA);}

错误提示如下:
[BCC32 Error] Unit1.cpp(22): E2015 Ambiguity between '__stdcall SetLayeredWindowAttributes(HWND__ *,unsigned long,unsigned char,unsigned long)' and 'Forms::SetLayeredWindowAttributes'
Full parser context
Unit1.cpp(18): parsing: void _fastcall TForm1::FormShow(TObject *)

在BCB6下 执行可通过。。。。。。

[解决办法]
你这个实现的效果是什么,直接设置窗体的属性不行吗?

AlphaBlend , AlphaBlendValue ,TransparentColor , TransparentColorValue
[解决办法]
这是因为Forms单元中的SetLayeredWindowAttributes函数和Windows API中的函数重名了。

SetLayeredWindowAttributes(Handle,clBlue,200,LWA_ALPHA);
改成:
::SetLayeredWindowAttributes(Handle, clBlue, 200, LWA_ALPHA);
就行了。

读书人网 >C++ Builder

热点推荐