本文介绍了关于setWindowLong& getWindowLong的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发C#应用程序,因为我需要使用setWindowLong& getWindowLong.我想了解更多.将发件人控件设为透明是否有帮助?

谢谢!!!

I am developing C# application for that i need to use setWindowLong & getWindowLong. I wish to know more about it. Does it help to make From control transparent?

Thanks!!!

推荐答案

// WINAPI Constants
private const int GWL_EXSTYLE = -20;
private const int WS_EX_LAYERED = 0x80000;
private const int LWA_ALPHA = 2;

// WINAPI Functions
[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hwnd, int nIndex);

[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)]
private static extern int SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong);

[DllImport("user32.dll")]
private static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);

public static void ApplyMenuTransparency(IntPtr Handle, byte Transparency)
{
    SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) | WS_EX_LAYERED);
    SetLayeredWindowAttributes(Handle, 0, Transparency, LWA_ALPHA);
}

protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
{
    if (e.Item.IsOnDropDown)
        Manager.ApplyMenuTransparency(e.ToolStrip.Handle, this.MenuTransparency);
    base.OnRenderMenuItemBackground(e);
}


这篇关于关于setWindowLong& getWindowLong的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 10:01