label的效果如同气泡提示的样子,需要是圆角的四角,并且还要有一个三角箭头,或者也可以是自定义的控件,请教大家

解决方案 »

  1.   

    利用windows API函数,声明一个Form对象,然后将它显示在一个你画出来的区域里面,就是一个不规则的窗口(windows XP登录时弹出的那个气球)。
    用这个API来创建不规则区域
    [DllImport("gdi32.DLL", EntryPoint="CombineRgn", CharSet=CharSet.Auto)]
    private static extern int CombineRgn(IntPtr hDestRgn, IntPtr hSrcRgn1, IntPtr hSrcRgn2, int nCombineMode);
    说明:返回值:0表示失败,其余表示成功。
    参数:hDestRgn是生成的不规则区域,hSrcRgn1是参与合并的区域1,hSrcRgn2是参与合并的区域2
    用这个API函数来创建不规则形状窗口。
    代码:
    IntPtr m_region;//目标不规则区域
    IntPtr HRGN_Main;//参与合并的区域1
    IntPtr HRGN_Top;//参与合并的区域2
    public const int RGN_AND = 1;//2个区域共同(交集)
    public const int RGN_OR = 2;//两个区域合并(并集)
    public const int RGN_XOR = 3;
    public const int RGN_DIFF = 4;
    public const int RGN_COPY = 5;
    public const int RGN_MIN = RGN_AND;
    public const int RGN_MAX = RGN_COPY;
    CombineRgn(HRGN_Main,HRGN_Top,APIParameters.RGN_OR);用这个API来将声明好的Form置入那个不规则区域m_region中。
    [DllImport("User32.DLL", EntryPoint="SetWindowRgn", CharSet=CharSet.Auto)]
    private static extern int SetWindowRgn(IntPtr hwnd, IntPtr hRgn, bool bRedraw);
    代码:
    Form m_frm = new Form();
    SetWindowRgn(m_frm.Handle, m_region, true);
    Form.Show();
    调用了Show()后你就能看到这个不规则画面了,不过在这里我没有写出完整的设置区域的代码,这个你可以自己写。提供你个函数:
    [DllImport("gdi32.DLL", EntryPoint="CreateEllipticRgn", CharSet=CharSet.Auto)]
    private static extern IntPtr CreateEllipticRgn(int X1, int Y1, int X2, int Y2);

    [DllImport("gdi32.DLL", EntryPoint="CreateRectRgn", CharSet=CharSet.Auto)]
    public static extern IntPtr CreateRectRgn(int X1, int Y1, int X2, int Y2);
    以上两个函数分别是画椭圆和矩形的函数,置于怎么样组合出你想要的图形,就看你的搭积木的能力了,嘻嘻嘻:)
      

  2.   

    不要忘了,最好把那个弹出的Form的FormBoardStyle属性设置为“None”。这样好看。
      

  3.   

    能不能简单的继承label然后重写它的Paint()呢?不知道还有没有人做过类似的
      

  4.   

    我的意思就是做个漂亮点label,系统自带的客户觉得太丑了,谢谢大家
      

  5.   

    同样可以,用SetWindowRgn方法
    SetWindowRgn(this.handle,m_region, true);