ArcObjects Library Reference  

Password

About the Load a map document into the PageLayoutControl Sample

[C#]

Password.cs

namespace LoadMapControl
{
	public class frmPassword : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox txtPassword;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button cmdOK;
		private System.Windows.Forms.Button cmdCancel;
		private string m_password;
		private int m_check;

		private System.ComponentModel.Container components = null;

		public frmPassword()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.txtPassword = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.cmdOK = new System.Windows.Forms.Button();
			this.cmdCancel = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(248, 32);
			this.label1.TabIndex = 0;
			this.label1.Text = "Please enter the password for the published map in the text box below and press O" +
				"K.";
			// 
			// txtPassword
			// 
			this.txtPassword.Location = new System.Drawing.Point(88, 64);
			this.txtPassword.Name = "txtPassword";
			this.txtPassword.Size = new System.Drawing.Size(152, 20);
			this.txtPassword.TabIndex = 1;
			this.txtPassword.Text = "";
			this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(64, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "Password:";
			// 
			// cmdOK
			// 
			this.cmdOK.Location = new System.Drawing.Point(40, 104);
			this.cmdOK.Name = "cmdOK";
			this.cmdOK.Size = new System.Drawing.Size(88, 32);
			this.cmdOK.TabIndex = 3;
			this.cmdOK.Text = "OK";
			this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
			// 
			// cmdCancel
			// 
			this.cmdCancel.Location = new System.Drawing.Point(152, 104);
			this.cmdCancel.Name = "cmdCancel";
			this.cmdCancel.Size = new System.Drawing.Size(88, 32);
			this.cmdCancel.TabIndex = 4;
			this.cmdCancel.Text = "Cancel";
			this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
			// 
			// frmPassword
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(288, 166);
			this.Controls.Add(this.cmdCancel);
			this.Controls.Add(this.cmdOK);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.txtPassword);
			this.Controls.Add(this.label1);
			this.Name = "frmPassword";
			this.Text = "Password Dialog";
			this.Load += new System.EventHandler(this.frmPassword_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void cmdCancel_Click(object sender, System.EventArgs e)
		{
			//On Cancel button pushed
			txtPassword.Text = "";
			m_check = 0;
			this.Close();
		}

		private void cmdOK_Click(object sender, System.EventArgs e)
		{
			//On OK button pushed
			m_password = txtPassword.Text;
			txtPassword.Text = "";
			m_check = 1;
			this.Close();
		}

		public string Password
		{
			//Retrieve the password 
			get {return m_password; }
		}

		public int Check
		{
			get { return m_check; }
		}
	
  	private void txtPassword_TextChanged(object sender, System.EventArgs e)
		{
			//Set Enabled property
			if(txtPassword.Text == "") 
				cmdOK.Enabled = false;
			else
				cmdOK.Enabled = true;
		}

		private void frmPassword_Load(object sender, System.EventArgs e)
		{
			//Set placeholder character for password
			txtPassword.PasswordChar = '*';
			cmdOK.Enabled = false;
		}
	}
}

[Visual Basic .NET]

Password.vb

Public Class frmPassword
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.IContainer

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents txtPassword As System.Windows.Forms.TextBox
  Friend WithEvents cmdOK As System.Windows.Forms.Button
  Friend WithEvents cmdCancel As System.Windows.Forms.Button
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label
    Me.Label2 = New System.Windows.Forms.Label
    Me.txtPassword = New System.Windows.Forms.TextBox
    Me.cmdOK = New System.Windows.Forms.Button
    Me.cmdCancel = New System.Windows.Forms.Button
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.Location = New System.Drawing.Point(16, 24)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(232, 40)
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Please enter the password for the published map in the text box below and press O" & _
    "K."
    '
    'Label2
    '
    Me.Label2.Location = New System.Drawing.Point(8, 80)
    Me.Label2.Name = "Label2"
    Me.Label2.Size = New System.Drawing.Size(72, 16)
    Me.Label2.TabIndex = 1
    Me.Label2.Text = "Password:"
    '
    'txtPassword
    '
    Me.txtPassword.Location = New System.Drawing.Point(80, 80)
    Me.txtPassword.Name = "txtPassword"
    Me.txtPassword.Size = New System.Drawing.Size(160, 20)
    Me.txtPassword.TabIndex = 2
    Me.txtPassword.Text = ""
    '
    'cmdOK
    '
    Me.cmdOK.Location = New System.Drawing.Point(24, 120)
    Me.cmdOK.Name = "cmdOK"
    Me.cmdOK.Size = New System.Drawing.Size(88, 32)
    Me.cmdOK.TabIndex = 3
    Me.cmdOK.Text = "OK"
    '
    'cmdCancel
    '
    Me.cmdCancel.Location = New System.Drawing.Point(136, 120)
    Me.cmdCancel.Name = "cmdCancel"
    Me.cmdCancel.Size = New System.Drawing.Size(88, 32)
    Me.cmdCancel.TabIndex = 4
    Me.cmdCancel.Text = "Cancel"
    '
    'frmPassword
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(264, 174)
    Me.Controls.Add(Me.cmdCancel)
    Me.Controls.Add(Me.cmdOK)
    Me.Controls.Add(Me.txtPassword)
    Me.Controls.Add(Me.Label2)
    Me.Controls.Add(Me.Label1)
    Me.Name = "frmPassword"
    Me.Text = "frmPassword"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private m_password As String
  Private m_check As Integer


  Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
    txtPassword.Text = ""
    m_check = 0
    Me.Close()
  End Sub


  Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
    m_password = txtPassword.Text
    txtPassword.Text = ""
    m_check = 1
    Me.Close()
  End Sub


  Public ReadOnly Property Password() As String
    Get
      Return m_password
    End Get
  End Property

  Public ReadOnly Property Check() As Integer
    Get
      Return m_check
    End Get
  End Property

  Private Sub frmPassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Set placeholder character for password
    txtPassword.PasswordChar = "*"
    cmdOK.Enabled = False
  End Sub

  Private Sub txtPassword_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPassword.TextChanged
    'Set Enabled property
    If txtPassword.Text = "" Then
      cmdOK.Enabled = False
    Else
      cmdOK.Enabled = True
    End If
  End Sub
End Class