Micro Focus QTP (UFT) Forums
.netfactory - 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: .netfactory (/Thread-netfactory)



.netfactory - punjprakash - 11-17-2010

Hi all,
I want to write some instructions within the form,I can create form and radiobutton,textboxes but how to write my instructions?

Code:
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)

what about writing inthe form itself?


RE: .netfactory - Saket - 11-17-2010

You will have to use Label class for that. In the example below- you will find the use of Label to add the instructions to a Form
Code:
Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")  
Set MyText = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")  
Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")  
Set MyLabel = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms")  
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)  

MyLabel.Text = "Please enter some text into the text box below and click on close button"
MyLabel.AutoSize = True

Pos.X = 90  
Pos.Y = 100  
MyText.Location = Pos  
MyText.Width = 100  

Pos.X = 100  
Pos.Y = 130  
MyButton.Location = Pos  
MyButton.Text = "Close"

MyForm.Controls.Add MyLabel
MyForm.Controls.Add MyText  
MyForm.Controls.Add MyButton  
MyForm.CancelButton = MyButton  

MyForm.ShowDialog  

Msgbox MyText.Text  

Set MyText = Nothing
Set MyButton = Nothing
Set Pos = Nothing
Set MyForm = Nothing

hope that helps.