2011-04-28 3 views
0

사용자가 폼의 단추를 클릭 할 때 특정 세부 정보를 표시하는 컨트롤이 포함 된 팝업 상자를 표시하려는 Windows 모바일 응용 프로그램을 개발 중입니다.Windows 모바일 응용 프로그램에서 팝업 상자를 표시하는 방법은 무엇입니까?

나는 ShowDialog() 메서드를 사용하고 있지만 작동 중입니다.

아무에게도 이것을 구현하는 방법을 제안 할 수 있습니까?

미리 감사드립니다.

+0

ShowDialog() 메서드를 사용하고 있지만 작동 중입니다. ? –

+0

컴팩트 프레임 워크 앱입니까? 그렇다면 asp.net과 아무 관련이 없으므로 태그를 편집해야합니다. 또한 귀하의 질문은 명확하지 않습니다 - 작동합니까 아니면 그렇지 않은가요? 사람들이 더 많은 것을 도울 수있는 코드를 보여줘야합니다. –

답변

0

질문을 올바르게 이해했다면 해결 방법은 맞춤 팝업 클래스를 만드는 것입니다.

public class Popup : Control 
{ 
    private class Const 
    { 
     public const int Height = 100; 
     public static Color BarFrameColor = SystemColors.ControlDark; 
     public static Color BarShadowColor = Color.Black; 
     public static Color BackColor = SystemColors.Info; 
     public static Color ForeColor = SystemColors.InfoText; 
    } 

    // [ gdi objects ] 
    private Bitmap m_bmp; 
    private Pen m_penShadow, m_penFrame; 

    private Panel panel; 
    private VScrollBar vScrollBar; 
    private Label lblText; 
    private bool scrolling; 

    public string Text 
    { 
     get 
     { 
      return lblText.Text; 
     } 
     set 
     { 
      lblText.Text = value; 
     } 
    } 

    public bool Scrolling 
    { 
     get 
     { 
      return this.scrolling; 
     } 
     set 
     { 
      this.scrolling = value; 
     } 
    } 

    public Popup() 
    { 
     this.Hide(); 
     this.ForeColor = Const.ForeColor; 
     this.BackColor = Const.BackColor; 
     this.Height = Const.Height; 

     this.panel = new Panel(); 
     this.panel.BackColor = Const.BackColor; 
     this.panel.Location = new Point(2, 2); 

     this.vScrollBar = new VScrollBar(); 
     this.vScrollBar.ValueChanged += new EventHandler(vScrollBar_ValueChanged); 

     this.lblText = new Label(); 
     this.lblText.Location = new Point(0, 0); 
     this.lblText.Text = ""; 

     this.panel.Controls.Add(lblText); 
     this.Controls.Add(vScrollBar); 
     this.Controls.Add(panel); 

     CreateGdiObjects(); 

     this.Scrolling = false; 
    } 

    private void CreateGdiObjects() 
    { 
     // [ gdi objects ] 
     this.m_penShadow = new Pen(Const.BarShadowColor); 
     this.m_penFrame = new Pen(Const.BarFrameColor); 
    } 

    protected override void OnParentChanged(EventArgs e) 
    { 
     base.OnParentChanged(e); 

     // [ calculate layout ] 
     this.Left = 0; 
     if (this.Parent != null) 
     { 
      this.Width = this.Parent.Width; 
      this.Top = this.Parent.Height - this.Height; 
     } 

     if (this.Scrolling) 
     { 
      this.vScrollBar.Size = new Size(12, this.Height - 4); 
      this.vScrollBar.Location = new Point(this.Width - 2 - this.vScrollBar.Width, 2); 

      this.panel.Size = new Size(this.Width - 4 - this.vScrollBar.Width, this.Height - 4); 
      this.vScrollBar.Minimum = this.panel.Top; 
      this.vScrollBar.Maximum = this.panel.Height; 
      this.vScrollBar.Visible = true; 

      this.lblText.Size = new Size(this.panel.Width, this.Height * 3); 
     } 
     else 
     { 
      this.panel.Size = new Size(this.Width - 4, this.Height - 4); 
      this.vScrollBar.Visible = false; 
      this.lblText.Size = this.panel.Size; 
     } 


     this.BringToFront(); 
    } 

    protected override void OnPaint(PaintEventArgs e) 
    { 
     // [ draw progress on memory bitmap ] 
     CreateMemoryBitmap(); 
     Graphics g = Graphics.FromImage(this.m_bmp); 
     DrawControl(g); 

     // [ blit to screen ] 
     e.Graphics.DrawImage(this.m_bmp, 0, 0); 
    } 

    protected override void OnPaintBackground(PaintEventArgs e) 
    { 
     // [ don't pass to base since we paint everything, avoid flashing ] 
    } 

    private void CreateMemoryBitmap() 
    { 
     // [ see if need to create bitmap ] 
     if (this.m_bmp == null || this.m_bmp.Width != this.Width || this.m_bmp.Height != this.Height) 
      this.m_bmp = new Bitmap(this.Width, this.Height); 
    } 

    private void DrawControl(Graphics g) 
    { 
     g.Clear(this.BackColor); 
     Rectangle rc = new Rectangle(0, 0, this.Width - 1, this.Height - 1); 
     g.DrawRectangle(this.m_penShadow, rc); 
     rc.Inflate(-1, -1); 
     g.DrawRectangle(this.m_penFrame, rc); 
    } 

    private void vScrollBar_ValueChanged(object sender, System.EventArgs e) 
    { 
     this.lblText.Top = -this.vScrollBar.Value; 
    } 
} 
관련 문제