做一个项目,有部分功能要实现点击一个地图上的某一个镇的区域就弹出一个窗体显示这个镇的一些信息。     地图(就是整个大窗体)的大小是可以改变的,可以拖大、拖小或是最大化之类;还有就是弹出的窗体不是矩形的,是不规则的的图形;还有就是大窗体的右上角放一个小的显示区域,也是个不规则的形状。    请问这样能实现么 , 用什么技术做比较好点?  希望高手帮帮忙!多谢了!!效果如图:

解决方案 »

  1.   

    用区域,
    1.定义GraphicsPath
    2、从上面定义Region
    3、设置窗体的Region
      

  2.   

    不规则窗体显示,差不多可以了, 就是窗体缩放的时候位置不好改动;有什么好办法码?   信息窗:
    private void frmShow_Load(object sender, EventArgs e)
            {
                this.panel1.Left = this.Width - this.panel1.Width;
                this.panel1.Top = 0;
            }        private void panel1_Paint(object sender, PaintEventArgs e)
            {
                SetWindowRegion(this.panel1);
            }        public void SetWindowRegion(Panel pan)
            {
                System.Drawing.Drawing2D.GraphicsPath FormPath;
                FormPath = new System.Drawing.Drawing2D.GraphicsPath();            Rectangle rect = new Rectangle(0, 0, pan.Width, pan.Height - 22);//this.Left-10,this.Top-10,this.Width-10,this.Height-10);            FormPath = GetRoundedRectPath(rect, 30);            pan.Region = new Region(FormPath);
            }        private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
            {
                int diameter = radius;
                Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
                GraphicsPath path = new GraphicsPath();
                //   左上角   
                path.AddArc(arcRect, 180, 90);
                //   右上角   
                arcRect.X = rect.Right - diameter;            path.AddArc(arcRect, 270, 90);
                //   右下角   
                arcRect.Y = rect.Bottom - diameter;
                path.AddArc(arcRect, 0, 90);
                //   左下角   
                arcRect.X = rect.Left;
                path.AddArc(arcRect, 90, 90);
                path.CloseFigure();
                return path;
            }
      

  3.   

    使用WPF可以实现不规则窗体...
      

  4.   

      WPF 还没用过,  有待学习
      

  5.   

       高手帮帮忙呀......   关于点击某一区域弹出窗体的问题,我是在那一区域上放了一个透明的Label,这样一来当大窗体也就是整个地图的位置改变了之后,放的Label位置就没法定了.  哪位兄台做过这方面的算法吗,或者这种功能有其他的办法实现吗   ?    麻烦给指点一下吧 , 不胜感激.
      

  6.   

    Mouse_Click() 
    { } 
    不就是判断Mouse的座标是否在那个区域上啊,
      

  7.   

    gis吧,提示框用个窗体控件或什么,然后确定控件的location,然后再mapDrawn事件里动态改变框的位置,很简单的!
      

  8.   


    鼠标移动到按钮区域就显示提示
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Drawing.Drawing2D;
    using System.Threading;namespace WindowsApplication194
    {
        public partial class Form1 : Form, IMessageFilter
        {
            Button B = new Button();
            PictureBox PB = new PictureBox();
            Form F = new Form();
            GraphicsPath GP = new GraphicsPath();        public Form1()
            {
                InitializeComponent();            Application.AddMessageFilter(this);            B.Parent = this;            GP.AddEllipse(0, 0, 80, 40);
                GP.AddEllipse(20, 45, 40, 15);
                GP.AddEllipse(25, 70, 20, 10);            F.Opacity = 0;
                F.FormBorderStyle = FormBorderStyle.None;
                F.Size = new Size(100, 100);
                F.Region = new Region(GP);
                F.TopMost = true;
                DoDraw(String.Empty);  
                F.Show();            PB.Parent = F;
                PB.Dock = DockStyle.Fill;
            }        public bool PreFilterMessage(ref Message m)
            {
                int WM_MOUSEMOVE = 0x200;            if (m.Msg == WM_MOUSEMOVE)
                {
                    if (B.Bounds.Contains(this.PointToClient(Control.MousePosition)))
                    {
                        F.Location = Point.Add(Control.MousePosition, new Size(-25, -F.Height));
                        F.Show();
                        new Thread(new ParameterizedThreadStart(ShowFormThread)).Start("ABC");
                        this.Focus();
                    }
                    else
                    {
                        F.Opacity = 0;
                        F.Hide();
                    }
                }
                return false;
            }        void ShowFormThread(Object Obj)
            {
                try
                {
                    String Text = Obj.ToString();
                    int StartTick = Environment.TickCount;                this.Invoke(new Draw(DoDraw), new Object[] { Text });
                    
                    while ((double)this.Invoke(new GetOpacity(DoGetOpacity)) < 0.8)
                        if (Environment.TickCount - StartTick > 200)
                        {
                            this.Invoke(new IncOpacity(DoIncOpacity));                        StartTick = Environment.TickCount;
                        }
                }
                catch
                {
                    // 忽略程序退出的异常
                }
            }        delegate double GetOpacity();
            delegate void IncOpacity();
            delegate void Draw(String Text);        double DoGetOpacity()
            {
                return F.Opacity;
            }        void DoIncOpacity()
            {
                F.Opacity += 0.1;
            }        void DoDraw(String Text)
            {
                Bitmap Bmp = new Bitmap(PB.ClientRectangle.Width, PB.ClientRectangle.Height);            using (Graphics G = Graphics.FromImage(Bmp))
                {
                    SizeF SF = G.MeasureString(Text, F.Font);                G.Clear(Color.Yellow);
                    G.DrawPath(Pens.Black, GP);
                    G.DrawString(Text, F.Font, Brushes.Black, (80 - SF.Width) / 2, 10);
                }
                PB.Image = Bmp;
            }
        }
    }
      

  9.   

    wartim  效果挺好 O(∩_∩)O~   多谢大家 
      

  10.   

    gdi+
    把地图的无用区域做成透明的png格式图片。
    加载的时候,自动会去掉的。