Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
New Schedule in MindQ Systems, Madhapur By SUDHAKAR
Course Name Date Time Duration Type Branch
Selenium+Appium 16th October 2017 7.30 AM - 9.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur
Selenium+Appium 30th October 2017 9.30 AM - 11.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Thursday, September 2, 2010

DotnetFactory Object - Creating .Net Forms Using QTP

'###############################################
'           DotNetFactory Object 
'###############################################

'Purpose - To create an instance of a .NET object, and access its methods and properties.
'      We can create forms where the user can interact with them and give some input in run time
 
 Set MainForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
 Set TextField = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
 Set Button = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
 Set objPosition = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
 
 'Assign Text Field Details
 objPosition.X = 100
 objPosition.Y = 100
 TextField.Location = objPosition
 TextField.Width = 100
 
 'Assign Button Details
 objPosition.X = 100
 objPosition.Y = 130
 Button.Location = objPosition
 Button.Text = "Close"
 
 'Add Text Field and Button to Main Form
 MainForm.Controls.Add TextField
 MainForm.Controls.Add Button
 MainForm.CancelButton = Button
 
 'Show Form
 MainForm.ShowDialog
 
 Msgbox TextField.Text
  
 Set TextField = Nothing
 Set Button = Nothing
 Set objPosition = Nothing
 Set MainForm = Nothing

1 comment :

  1. Hi Sudhakar

    thanks for sharing this info.

    I would like to know, how do i create an instance of an existing Application window - for Ex: Outlook - Meeting Form.

    Thanks for your reply in advance

    ReplyDelete