【发布时间】:2018-02-25 06:32:28
【问题描述】:
一段时间以来,我一直在尝试创建一个仅在屏幕上显示位图图像的测试程序。理想情况下,图像将是半透明的(具有 Alpha 通道)并且“可点击”。但是,我还没有找到任何方法来做到这一点。
我为此拥有的应用程序是一个键盘指示器应用程序,它在后台运行,并在按下诸如 num lock 或 caps lock 之类的修饰符时在屏幕上显示一个弹出图像几秒钟。
我发现的是一个 MSDN 示例 for how to render an image on the screen,但我无法在 Windows 窗体应用程序中使其正常工作。在空白 WFA 应用程序的 Form1.cs 中,我有:
using System.Drawing;
using System.Windows.Forms;
namespace KeyboardIndicators
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
PictureBox pictureBox1 = new PictureBox();
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs pe)
{
Bitmap myBitmap = new Bitmap("Profile Image.jpg");
Graphics g = pe.Graphics;
g.DrawImage(myBitmap, 100, 100);
}
}
}
我可能在这里遗漏了很多东西,但我在 Visual Studio 中调试它的运气并不好。
我还没有找到一个在线网站,它可以完全描述如何做我想做的事情。我以前在其他应用程序中看到过这种事情,所以我知道它可以通过某种方式完成。
【问题讨论】:
-
要使“点击可通过”部分,覆盖
CreateParams(),设置WS_EX_TRANSPARENT标志。 -
@Idle_Mind Override ... 在什么范围内?表格1?
-
没错,无论您希望以何种形式对点击不可见。