schangxiang@126.com
2025-09-02 6bd89520e09dc1c2d3fab72a80c3d01f2df93490
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace WMS.EnumDefine
{
    public class basicData
    {
        [DllImport("user32.dll", EntryPoint = "GetDesktopWindow", CharSet = CharSet.Auto, SetLastError = true)]
        static extern IntPtr GetDesktopWindow();
        /// <summary>文字提示
        /// 
        /// </summary>
        /// <param name="text">文字内容</param>
        public static void no( string text)
        {
            Thread pen = new Thread(new ParameterizedThreadStart(GraphicsText));
            pen.Start(text);
            Thread.Sleep(2000);
            pen.Abort();
        }
 
        public static void GraphicsText(object text)
        {
            IntPtr hct = GetDesktopWindow();
            Graphics g = Graphics.FromHwnd(hct);
         
          //  Random ra = new Random();
            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(500);
                int A = 20;
                int B = 20;
                Font drawFont = new Font("Arial", 30);
                SolidBrush drawBrush = new SolidBrush(Color.FromArgb(254, 240, 240));
                SolidBrush drawtext = new SolidBrush(Color.FromArgb(245, 108, 108));
                Rectangle rect = new Rectangle(A, B, 220, 50);
                g.FillRectangle(drawBrush, rect);
                g.DrawString((string)text, drawFont, drawtext, A + 10, B + 5);
            }
 
            g.Dispose();
 
        }
    }
}