sud*_*yes 4 c# windows pinvoke mfc window-handles
是否可以从C#修改所有打开的窗口的不透明度.我用谷歌搜索最小化窗口,我开始知道它可能与pInvoke调用.它甚至奏效了.同样可以从C#更改所有打开的窗口的不透明度?
另外,我不喜欢MFC的东西.还有什么工具可以知道在dll中暴露的api列表吗?
Aam*_*mir 10
您可以使用SetLayeredWindowAttributes API来执行此操作.
检查此API以获取此API的pInvoke版本.
上述链接中的示例代码:
[DllImport("user32.dll")]
static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey,byte bAlpha, uint dwFlags);
public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 0x80000;
public const int LWA_ALPHA = 0x2;
public const int LWA_COLORKEY = 0x1;
//set the window style to alpha appearance
private void button4_Click(object sender, EventArgs e)
{
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED);
SetLayeredWindowAttributes(Handle, 0, 128, LWA_ALPHA);
}
Run Code Online (Sandbox Code Playgroud)