如图:
想知道的是:
1.那个框式怎么打印出来的,貌似半透明。
2.文字阴影如何实现?思路OR代码,最好代码,因为我已经实现了桌面漂浮文字,半透明框,但效果不够好。

解决方案 »

  1.   

    没有平台的支持做这些是很费力的,这也是为什么MS要整个WPF
      

  2.   

    我手头上有一套做这样效果的类代码,是之前突然兴起想用C#做桌面工具时候找回来的……贴出来或许能够帮到你……using System;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;
    using System.Windows.Forms;
    using System.Collections;/// <summary>
    /// Wind32API声明
    /// </summary>
    internal class Win32
    {
        [StructLayout(LayoutKind.Sequential)]
        public struct Size
        {
            public Int32 cx;
            public Int32 cy;        public Size(Int32 x, Int32 y)
            {
                cx = x;
                cy = y;
            }
        }    [StructLayout(LayoutKind.Sequential, Pack = 1)]
        public struct BLENDFUNCTION
        {
            public byte BlendOp;
            public byte BlendFlags;
            public byte SourceConstantAlpha;
            public byte AlphaFormat;
        }    [StructLayout(LayoutKind.Sequential)]
        public struct Point
        {
            public Int32 x;
            public Int32 y;        public Point(Int32 x, Int32 y)
            {
                this.x = x;
                this.y = y;
            }
        }    public const byte AC_SRC_OVER = 0;
        public const Int32 ULW_ALPHA = 2;
        public const byte AC_SRC_ALPHA = 1;    [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern IntPtr CreateCompatibleDC(IntPtr hDC);    [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern IntPtr GetDC(IntPtr hWnd);    [DllImport("gdi32.dll", ExactSpelling = true)]
        public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);    [DllImport("user32.dll", ExactSpelling = true)]
        public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);    [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern int DeleteDC(IntPtr hDC);    [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern int DeleteObject(IntPtr hObj);    [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);    [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
        public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
      

  3.   

     public partial class Form2 : Form
        {
            Point oldPoint = new Point(0, 0);
            bool mouseDown = false;
                    protected override void OnClosing(CancelEventArgs e)
            {
                e.Cancel = true;
                base.OnClosing(e);        }
                    protected override void OnHandleCreated(EventArgs e)
            {
               
                base.OnHandleCreated(e);        }
                    protected override CreateParams CreateParams
            {
                get
                {
                    CreateParams cParms = base.CreateParams;
                    cParms.ExStyle |= 0x00080000; // WS_EX_LAYERED
                    return cParms;
                }
            }
                    public Form2()
            {
                InitializeComponent();
                             this.MouseDown += new MouseEventHandler(Form2_MouseDown);
                this.MouseUp += new MouseEventHandler(Form2_MouseUp);
                this.MouseMove += new MouseEventHandler(Form2_MouseMove);
            }        void Form2_MouseMove(object sender, MouseEventArgs e)
            {
                if (mouseDown)
                {
                    this.Left += (e.X - oldPoint.X);
                    this.Top += (e.Y - oldPoint.Y);
                }
            }        void Form2_MouseUp(object sender, MouseEventArgs e)
            {
                mouseDown = false;
            }        void Form2_MouseDown(object sender, MouseEventArgs e)
            {
                oldPoint = e.Location;
                mouseDown = true;
            }        public void SetBits(Bitmap bitmap)
            {
                            if (!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
                    throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");            IntPtr oldBits = IntPtr.Zero;
                IntPtr screenDC = Win32.GetDC(IntPtr.Zero);
                IntPtr hBitmap = IntPtr.Zero;
                IntPtr memDc = Win32.CreateCompatibleDC(screenDC);            try
                {
                    Win32.Point topLoc = new Win32.Point(Left, Top);
                    Win32.Size bitMapSize = new Win32.Size(bitmap.Width, bitmap.Height);
                    Win32.BLENDFUNCTION blendFunc = new Win32.BLENDFUNCTION();
                    Win32.Point srcLoc = new Win32.Point(0, 0);                hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));
                    oldBits = Win32.SelectObject(memDc, hBitmap);                blendFunc.BlendOp = Win32.AC_SRC_OVER;
                    blendFunc.SourceConstantAlpha = 255;
                    blendFunc.AlphaFormat = Win32.AC_SRC_ALPHA;
                    blendFunc.BlendFlags = 0;                Win32.UpdateLayeredWindow(Handle, screenDC, ref topLoc, ref bitMapSize, memDc, ref srcLoc, 0, ref blendFunc, Win32.ULW_ALPHA);
                }
                finally
                {
                    if (hBitmap != IntPtr.Zero)
                    {
                        Win32.SelectObject(memDc, oldBits);
                        Win32.DeleteObject(hBitmap);
                    }
                    Win32.ReleaseDC(IntPtr.Zero, screenDC);
                    Win32.DeleteDC(memDc);
                }
            }
    这是窗体的代码,使用SetBits过程就可以实现你要的窗体效果的了……
      

  4.   


    在哪里调用SetBits呢?怎么我没有效果。
      

  5.   

    顶mywatermelon,的确可以显示边框,但文字阴影如何实现呢?