SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6

Thread: Dialog Box

  1. #1
    Member
    Join Date
    Apr 2002
    Location
    newark, nj USA
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Dialog Box

    Hello Everyone,

    I want to create a dialog box with buttons and drop down list. The idea is for the user to select something from the drop down box and click on the button, which would perform a particular job...like calling a function or something like that by passing a parameter.

    Can someone please help? I tried understanding the Begin Dialog example but could not get the user action part.

    Thanks

    Rinku.

  2. #2
    Moderator Joe Strazzere's Avatar
    Join Date
    May 2000
    Location
    USA
    Posts
    13,170
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Dialog Box

    Rinku,

    This sounds like a tool-specific question, although you haven't mentioned which tool.

    I suggest that you elaborate a bit, and post this im the corresponding tool-specific forum (WinRunner, Robot, etc), rather than here in the general Automated Testing forum.
    Joe Strazzere
    Visit my website: AllThingsQuality.com to learn more about quality, testing, and QA!

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Location
    Montreal, QC, Canada
    Posts
    366
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dialog Box

    This is an example of a function i use to display a dialog, see how it works using debugger:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">'##################################### #######################################
    '#
    '# Function ShowDialog() As Integer
    '#
    '# DESCRIPTION:
    '#
    '# This function will display a dialog box to enable the tester to choose
    '# whether Baseline data or Comparison data will be created/processed.
    '#
    '#
    '# PARAMETERS:
    '#
    '#
    '# RETURNS:
    '#
    '# 0 Indicates Create Baseline was chosen (const gcsCreateBaseline)
    '# 1 Indicates Compare Data was chosen (const gcsCompare)
    '# -1 Indicates the user pressed the Cancel button
    '#
    '# ERRORS:
    '#
    '# none
    '#
    '# Orig Author: Maxine McNaughton
    '# Orig Date: March 29, 2001
    '# History:
    '#
    '#
    '################################################# ###########################


    Function ShowDialog() As Integer
    Dim returnf as Integer


    'Create the Dialog
    Begin Dialog UserDialog 174, 55, &quot;Choose the Mode to Run the Script in&quot;
    OptionGroup .OptionGroup2
    OptionButton 5, 5, 75, 12, &quot;Baseline Creation&quot;, .OptionButton3
    OptionButton 5, 30, 80, 8, &quot;Capture Actual Data&quot;, .OptionButton4
    OKButton 113, 6, 50, 14
    CancelButton 114, 26, 50, 14
    End Dialog

    Dim mydialog as UserDialog

    On Error Resume Next 'The Cancel button is regarded as an error by Robot

    'Show the Dialog
    Dialog mydialog

    If Err=102 then
    ShowDialog = -1 'Cancel Button was pressed
    Else
    ShowDialog = mydialog.OptionGroup2 'Choice
    End If

    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">specifically on dropdown, the help indicates the following example:

    This example defines a dialog box with a drop combo box and the OK and Cancel buttons.

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Sub main
    Dim cchoices as String
    On Error Resume Next
    cchoices=&quot;All&quot;+Chr$(9)+&quot;Nothing&quo t;
    Begin Dialog UserDialog 180, 95, &quot;SQABasic Dialog Box&quot;
    ButtonGroup .ButtonGroup1
    Text 9, 3, 69, 13, &quot;Filename:&quot;, .Text1
    DropComboBox 9, 17, 111, 41, cchoices, .ComboBox1
    OKButton 131, 8, 42, 13
    CancelButton 131, 27, 42, 13
    End Dialog
    Dim mydialogbox As UserDialog
    Dialog mydialogbox
    If Err=102 then
    MsgBox &quot;You pressed Cancel.&quot;
    Else
    MsgBox &quot;You pressed OK.&quot;
    End If
    End Sub</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">HTH,
    Max

  4. #4
    Member
    Join Date
    Apr 2002
    Location
    newark, nj USA
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dialog Box

    Thanks for yoru suggestion. I currently work with Rational Robot and is looking for help with this tool.

    Thanks

    Rinku

  5. #5
    Member
    Join Date
    Apr 2002
    Location
    newark, nj USA
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dialog Box

    Can someone please write a small code to describr the following example.

    Dialog box contains following thing:

    text box (like a label) = displays a value from a variable.
    Button1 = A (Button Name) which upon clicking runs a function.
    Button2 = B (Button Name) which upon clicking runs a function.

    Cancel button = Cancels the dialog bax.

    Sorry if I am asking to much but this would really help.

    Thanks

    Rinku

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Location
    Montreal, QC, Canada
    Posts
    366
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dialog Box

    Copy the code and run it to see how it works.

    If the cancel button is pressed it triggers Err=102, to find out which button the user pressed to know which function to call you use the variable name you attributed to the dialog ie. mydialog where
    Dim mydialog as UserDialog

    And for you, you need a ButtonGroup like follows, that you'll reference using .ButtonGroup1 for instance and add your buttons, you need to play with the coords so everything is visible in your dialog and call each one differently - in the example .Push1 and .Push2:

    Then to find out which one was pressed you can use a select statement or if statement.

    Sample:

    Dim fchoices as String
    fchoices="File1" & Chr(9) & "File2" & Chr(9) & "File3"
    Begin Dialog UserDialog 185, 94, "SQABasic Dialog Box"
    Text 9, 5, 69, 10, "Filename:", .Text1
    DropComboBox 9, 17, 88, 71, fchoices, .ComboBox1
    ButtonGroup .ButtonGroup1
    OKButton 113, 14, 54, 13
    CancelButton 113, 33, 54, 13
    Button 113, 57, 54, 13, "Help", .Push1
    Button 113, 75, 54, 13, "What", .Push2
    End Dialog
    Dim mydialog as UserDialog
    On Error Resume Next
    Dialog mydialog
    If Err=102 then
    MsgBox "Dialog box canceled."
    'End Function usually
    End If

    Select Case mydialog.ButtonGroup1
    Case 0
    '.Push1 was pressed
    'Call some function
    Case 1
    '.Push2 was pressed
    'Call some other function
    End Select

    HTH,
    Max

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 08:08 PM.

Copyright BetaSoft Inc.