Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
prompt Dialog Box
#1
Solved: 11 Years, 4 Months ago
Hi,

Is there any way we can get the inputs from User using Dialog Box.
suppose i want to display 4 checkboxes to the user through dialog box and user will be selecting 1 option from them. and i will use that value in my code

thanks
Ramesh
Reply
#2
Solved: 11 Years, 4 Months ago
Yes. Using VBscript InputBox.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#3
Solved: 11 Years, 4 Months ago
Hi,

i tried same but it is just displaying one editbox to the user. Actually my requirement was to diaply the 4 checkboxes to the User.

thanks
ramesh
Reply
#4
Solved: 11 Years, 4 Months ago
I am not pretty sure if you can do that using Vbscript. The easiest would be to create a user form using Excel.

The other way which i may workaround would be researching on DotNetFactory.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#5
Solved: 11 Years, 4 Months ago
i hope i will get benefited from dotnetfactory !!

thanks for the help
Reply
#6
Solved: 11 Years, 4 Months ago
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

Reply
#7
Solved: 11 Years, 4 Months ago
(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

Reply
#8
Solved: 11 Years, 4 Months ago
hi saket
I got ur code
but when i close the Form then i am able to fetch the checkbox values

but i dont wont to use cross button of the form ; however i should be able to fetch the checkbox value on clicking OK/somebutton and my form should not be there anymore in frontend if i click OK
Reply
#9
Solved: 11 Years, 4 Months ago
I see that the form dissapears when clicked on Ok. Are you by any chance specifying the message box ?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#10
Solved: 11 Years, 4 Months ago
hey, Have you tried running this code? this works exactly as you need.
please go through the code again,you willl find the code for OK button is already there and t is working exactly as you need

Code:
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)
In case the button is not visible then try resizing the form or remove following statements
Code:
oDForm.width = 250
oDForm.height = 190

hey, Have you tried running this code? this works exactly as you need.
please go through the code again,you willl find the code for OK button is already there and t is working exactly as you need

Code:
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)
In case the button is not visible then try resizing the form or remove following statements
Code:
oDForm.width = 250
oDForm.height = 190

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Automating save dialog box in windows using UFT shipu 0 4,788 01-16-2015, 07:54 PM
Last Post: shipu
  QTP 11 - Chrome 24. Dialog box is identifying as Win object. Kannan R 0 3,096 08-13-2013, 08:10 PM
Last Post: Kannan R
Exclamation Getting run time error while executing the QTP script in command prompt. vishruth143 1 5,659 07-15-2013, 05:41 PM
Last Post: vinod123
  Dialog box differs on different browsers version (IE7 and IE9) for same application visitjaga 1 2,803 12-07-2012, 05:14 PM
Last Post: Ankesh
  Default value in Edit Box when Check Box is checked nacchio 2 5,104 07-18-2012, 12:21 PM
Last Post: sree.85

Forum Jump:


Users browsing this thread: 2 Guest(s)