 |
|
|
Code behavior
Last Post 23 May 2011 02:27 PM by halr9000. 2 Replies.
|
Sort:
|
|
Prev Next |
You are not authorized to post a reply. |
|
Soul Biter
 New Member Posts:1

 |
| 20 May 2011 08:34 AM |
|
=========================================================================================== Can anyone tell me why when running this scriptlet below, the cursor is not already in the dialog box? You have to click in the box before beginning to type. =========================================================================================== [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "DP Maintenance System" $objForm.Size = New-Object System.Drawing.Size(300,200) $objForm.StartPosition = "CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,120) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$x=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(150,120) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(280,20) $objLabel.Text = "Choose a Data Protector Maintenance Task:" $objForm.Controls.Add($objLabel) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(10,40) $objTextBox.Size = New-Object System.Drawing.Size(260,20) $objForm.Controls.Add($objTextBox) $objForm.Topmost = $True $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() $x |
|
|
|
|
EBGreen
 Veteran Member Posts:1092

 |
| 23 May 2011 01:09 PM |
|
I realize that it really isn't your fault, but that makes my brain hurt too much to try and sort it out into something I can read. |
|
| "Look Ma...no strings!" |
|
|
halr9000 PowerShell MVP, Site Admin
 Advanced Member Posts:565

 |
|
| You are not authorized to post a reply. |
|
Active Forums 4.3
|
|
 |