c#中无法通过句柄设置窗口的透明度?我正在尝试设置所有窗口的透明度。我有以下代码。publicpartialclassForm1:Form{[DllImport("user32.dll")]staticexternintSetWindowLong(IntPtrhWnd,intnIndex,intdwNewLong);[DllImport("user32.dll")]staticexternintGetWindowLong(IntPtrhWnd,intnIndex);[DllImport("user32.dll")]staticexternboolSetLayeredWindowAttributes(IntPtrhwnd,uintcrKey,bytebAlpha,uintdwFlags);publicconstintGWL_EXSTYLE=-20;publicconstintWS_EX_LAYERED=0x80000publicconstlic;LWA_ALPHA=0x2;publicForm1(){InitializeComponent();this.Load+=newEventHandler(Form1_Load);}privatevoidForm1_Load(objectsender,EventArgse){Process[]processlist=Process.GetProcesses();进程列表中的进程){SetWindowLong(进程。句柄,GWL_EXSTYLE,GetWindowLong(进程。句柄,GWL_EXSTYLE)^WS_EX_LAYERED);SetLayeredWindowAttributes(theprocess.Handle,0,128,LWA_ALPHA);}}}当我执行代码时没有任何反应。怎么了??SetWindowLong采用窗口句柄(hWnd),但您传递的是进程句柄。在将theprocess.Handle的所有实例更改为theProcess.MainWindowHandle后,它可以在我测试它的WindowsXP机器上运行。现在我将不得不修改代码以使窗口恢复正常;)幸运的是,VisualStudio2010窗口不受影响。这部分代码:^WS_EX_LAYERED翻转WS_EX_LAYERED位,我想你想要:|WS_EX_LAYERED|WS_EX_LAYERED你试过设置不透明度吗?以上就是C#学习教程:在c#中不能通过句柄设置窗口的透明度?分享的所有内容,如果对你有用,需要了解更多C#学习教程,希望大家多多关注——this.Opacity=0.50;本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
