Micro Focus QTP (UFT) Forums
prompt Dialog Box - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: prompt Dialog Box (/Thread-prompt-Dialog-Box)

Pages: 1 2


prompt Dialog Box - ramesh.tahiliani - 09-02-2009

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


RE: prompt Dialog Box - basanth27 - 09-02-2009

Yes. Using VBscript InputBox.


RE: prompt Dialog Box - ramesh.tahiliani - 09-02-2009

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


RE: prompt Dialog Box - basanth27 - 09-02-2009

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.


RE: prompt Dialog Box - ramesh.tahiliani - 09-02-2009

i hope i will get benefited from dotnetfactory !!

thanks for the help


RE: prompt Dialog Box - Saket - 09-02-2009

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



RE: prompt Dialog Box - Saket - 09-02-2009

(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



RE: prompt Dialog Box - ramesh.tahiliani - 09-02-2009

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


RE: prompt Dialog Box - basanth27 - 09-02-2009

I see that the form dissapears when clicked on Ok. Are you by any chance specifying the message box ?


RE: prompt Dialog Box - Saket - 09-02-2009

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