Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
An important update from QtpSudhakar. I stopped giving classroom training in MindQ Systems. I have bigger plans and I want to put an end to regular classroom training because very less people are practicing. From now onwards every session of mine is going to have explanation and practice. Everyone should practice in presence of mine and should go out of classroom with practical knowledge. So I started my own institute AnyTechLabs in Madhapur. Please reach out to +91-8328152362 for course details. Visit AnyTechLabs.com for address details.
Selenium + Cucumber 24th October 7.30 AM IST to 9.00 AM IST 45 Days WeekDay Online

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