09-02-2009, 06:11 PM
(09-02-2009, 05:36 PM)Saket Wrote: Hi Ramesh,
There can be various way of doing this, as suggested by basanth using excel form and through 'hta' using vbscript.
we can do this easily using QTP dotnetfactory.
try this and let me know if it works
Code:Set oDForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set oOpt1 = DotNetFactory.CreateInstance("System.Windows.Forms.CheckBox", "System.Windows.Forms")
Set oOpt2 = DotNetFactory.CreateInstance("System.Windows.Forms.CheckBox", "System.Windows.Forms")
Set oGroupBox = DotNetFactory.CreateInstance("System.Windows.Forms.GroupBox", "System.Windows.Forms")
Set oButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
x=10
y=10
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y) '‘This will provide the locations(X,Y) for the controls
oOpt1.Text="Option1"
oGroupBox.Location=Pos
Pos.Y=30
oOpt1.Location=Pos
Pos.Y=CInt(oOpt1.Height)+CInt(oOpt1.Top)+10
oOpt2.Location=Pos
oOpt2.Text="Option2"
oGroupBox.Text="Select Option"
oGroupBox.Controls.Add(oOpt1)
oGroupBox.Controls.Add(oOpt2)
oButton.Text="OK"
Pos.X=60
Pos.Y=CInt(oGroupBox.Height)+20
oButton.Location=Pos
oDForm.CancelButton=oButton
oDForm.Controls.Add(oGroupBox)
oDForm.Controls.Add(oButton)
oDForm.StartPosition=CenterScreen
oDForm.Text="Option Dialog QTP"
oDForm.width = 250
oDForm.height = 190
oDForm.ShowDialog
If oOpt1.Checked Then
msgbox "You have selected Option 1"
elseif oOpt2.Checked Then
msgbox "You have selected Option 2"
else
msgbox "No Option selected"
End If