I have a dialog in vb6 which changes the values being displayed in its parent dialog.
The x1 is displayed in txt_c1 text in parent dialog and it has a txt_1validate function too for the text box. Now i want to change the value of txt_c1 txtbox from child dialog and then call its validate function. But the problem is that txt_c1 is not available in child dialog.
Please note that i am working in vb6 in the MS VB 6.0 IDE
Forms are just classes and can therefore be instantiated explictly (and you will probably find your life easier if you do rather than using the automatic instantiation in VB6) and references to forms can be assigned.
You can solve your problem by creating a public property on your child dialog (Form1.frm) of type Form that you set to the instance of the parent dialog thus giving you access to the controls andd methods on the parent from the child.
My VB6 is somewhat rusty (and I don't have an installed instance available) so this isn't going to be actual, correct code - but something along the lines of the following should work
In the code that calls the child:
Form childDialog = new Form1
childDialog.Parent = this
childDialog.ShowModal
Then in the child dialog:
Parent.txt_c1 = newValue
if not Parent.Validate then
...
end if
Related
I'm writing a program to generate a VFP form class with lots (90+ each) of labels and radio buttons on it. That's the easy part. (and yes, I know that's a lot of radio buttons, but that's what the users want).
We have several VCXs in our application which do something similar, but not with anywhere near as many individual controls. So, rather than spend a huge fraction of my life dragging and dropping fields around, and realizing that I happen to have a handy list of all the fields, their options and default values, I used the 'View Class Code' option from the Class Browser to get a sample of what the code looks like as a base. Then I wrote code to generate a PRG with all the pieces I need.
My actual problem is that the code output by 'View Class Code' seems to include invalid syntax:
DEFINE CLASS form40 AS frmae
Height = 427
Width = 710
ScrollBars = 2
DoCreate = .T.
Visible = .T.
Name = "form40"
ADD OBJECT form40.cntouter.cntform40 AS cntctrls WITH ;
Top = 175, ;
Left = 2, ;
Visible = .T., ;
Name = "Cntform40"
ENDDEFINE
The class frmae is a class (from a VCX) which includes a container called 'cntouter'. Class cntctrls is the container that contains all the labels/radio buttons.
The problem is that apparently you can't, in the DEFINE CLASS command, ADD OBJECT to a member. The dotted syntax causes a syntax error. Yet, this technique is used in the 'View Class Code' output.
I suspect I could get around this by generating an Init method which calls ADDOBJECT() to add my control container to cntouter, but I'd rather have it in the class definition.
The "View Class Code" option doesn't produce runnable code; it never has.
My suggestion for doing what you need is to create an option button class with the appearance that you want. Then, use your existing list to populate a cursor and write code that spins through that and adds option buttons to a container class.
The key thing you need to know here is that you can run code in the IDE that affects a form or class that's open in the Form Designer or Class Designer. That's what Builders do. So rather than generate a code-based class, use code to create a visual class.
If you want to do this in code, then first you shouldn't depend view code as Tamar already pointed out. You can do any form and its controls in code (with the exception of one or two activex controls maybe) but you need to understand how to code container type controls. First, to add a class from a class library you need to sepcify its source. ie:
add object myContainer as MyBeautifulContainer from myClasslib.vcx
wouldn't work. Instead you would need to define a class in your code like this:
define class form40 as form
* ...
add object myContainer as MyContainer with ...
* ...
enddefine
define class myContainer as MyBeautifulContainer from myClasslib.vcx
* additiobnal code if any
enddefine
Second, you would need to create your inner controls first and then add as needed to create the outermost object.
AT designtime, you could go to command window, pop up a code window:
modify command [enter]
and then using ASELOBJ() function you can get a reference to any object on the form you are designing. Onece you have the desired reference(s), you can add and arrange objects within that code window programmatically, select the code and execute selection (erase the controls, correct your code and retry if you can't do it right for the first time). That is temporary "do and throw away" style builder.
We are trying to automate one of our desktop application using UFT but we are facing problem with telerik controls. UFT is unable to identify controls for eg • Custom DropDownList (Telerik.WinControls.UI.RadDropDownList) and 3rd party GridControl (Telerik.WinControls.UI.RadGridView) UFT not able to access.
Please tell me is it possible to automate telerik control using UFT or we need some additional setting for this ..
We can automate telrik controls using UFT. The biggest problem in doing so is that UFT does not know how to identify the objects and all of the objects will be identified as RAD controls.
You will have to write your own functions to execute tests on these controls. First you will have to find out which native function or property can be used for a particular control(this is a time consuming process), after that you will have to write your own function to either set the native property or call the native function to perform the operation on the control
Below is the example of what I will create in UFT for executing tests on telrik controls within UFT
Below is the example of such a function to set the text on telrik controls
'''This function will set the text for the telrik controls
'''OprObject is the reference of the object, name is the name string for the object to write the logs, object type will decide which native operation to be performed and value to be set is the actual value to be set
Public Function SetText(ByRef OprObject, ByVal ObjectName, Byval ObjectType, ByVal ValueToBeSet)
'''Check if the object is loaded
CheckLoaded(OprObject, true, ObjectName, ObjectType)
Select Case UCASE(ObjectType)
Case "COMBOBOX"
'''For RadComboBox this should work, not sure because I have only worked on a web based telrik app
OprObject.Object.Text = ValueToBeSet
Case "TEXTBOX"
'''' For Text Box we can just use
OprObject.Click
OprObject.Type ValueToBeSet
''' add other cases here
end select
End Function
To get the list of native functions and properties add the RadControl to the OR and then add the RadControl in your keyword view like below
Browser("").........RadObject("").Object.
Once you type . after the object you will see the list of properties and functions there (Make sure that your application is open and your object is visible inside the application).
You can also do this with object spy, but object spy wont give the complete list(sometimes you will have nested objects which will not be visible in object spy like RadControl.Object.Customer.Name, where name will not be visible in object spy and when you try to set something to customer in code UFT will throw error).
I wont recommend using insight objects here, because then you will just be automating your whole application as image and any changes in the application will break your tests.
Is object spy able to identify the objects? Is uft able to click on the dropdown list? If no, you can still use "Insight object" identification technique. ie identify the very image of an object... Also if it is java based u could try and enable the java plugin...let me know what worked
Hi: I have created a very simple user defined control (a container) with the visual IDE of Visual Foxpro 9 and stored it into a VCX file (sisweb.vcx)
After that I've created (visually) a form and in the INIT event I've tried to instantiate the previous container control and add to the form:
oContainer=newobject("xContainer","sisweb.vcx")
ThisForm.AddObject("Contx","oContainer")
ThisForm.Contx.Width=230
Unfortunatelly, when trying to ADD the container object, it rises an error saying that oContainer doesn't exists.
Can you help me please?
When you want to add an object dynamically at run-time, you could do something like
Thisform.NewObject("Contx", "xContainer", "sisweb.vcx")
Thisform.Contx.Width = 230
Thisform.Contx.Visible = .T.
Where assigning the Visible property explicitly is important.
On the other hand, you could also add it "visually" in the Designer by dragging it from the Project Manager's "Classes" tab, or by using the bookshelf icon of the Form / Class Designer's "Controls" toolbar, or the "Toolbox" in the "Tools" menu
Sorry. i am officially new in Visual Basic.
I have created a TextBox in my form. In "View Code" i want to access the Text attribute
(I mean TextBox.Text)
,but the object only gives me these 4: Count,Item,LBound,UBound
Maybe you're changing the Index property instead of the TabIndex property so that it would become a control array thus UBound, LBound, Count and Item properties are present.
And i suspect you are using Visual Basic 6 instead of VB.Net.
See link here the VB6 has Index property that is for Control Array.
My guess, without seeing your code is that your syntax is somehow interacting with an array, try this code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TextBox1.Text = "Hello World"
End Sub
End Class
Note: The above code represents the default names for a Form, a new TextBox dragged and dropped onto the designer inside of the form's Load event handler.
Are you possibly copying and pasting a textbox rather than double clicking the object in the toolbox. If you look in the name of the object in the properties window you would see txtName(0)
In the course of the development of a Resharper plugin, I'd like to show an error message to a user when they incorrectly use a context action. Is there a way to pop up a window in Visual Studio to communicate the Resharper exception message to the user? I'm developing a plugin with Resharper 8 and VS 2012
You can always use MessageBox - ReSharper also provides a MessageBox static class that provides a number of helper methods to make it easy to display what you want. It also allows for adding "message box handlers" so that you don't actually display a message box during testing.
Alternatively, if you're creating a context action, and you're (indirectly) deriving from BulbActionBase, your ExecutePsiTransaction method (which should do all the work) can return an Action<ITextControl>. This allows you to return an action that will execute after the quick fix/context action has completed, which can be anything from positioning the caret, changing the selection, executing a template or showing a tooltip as an error.
You can return something like this:
return tc => myLocks.QueueReadLock("MyContextAction", () => {
myTooltipManager.Show("Something went wrong!",
lifetime => new TextControlPopupWindowContext(lifetime, tc, myLocks, myActionManager);
});
This is using a number of fields: IShellLocks myLocks, ITooltipManager myTooltipManager and IActionManager myActionManager. These can be injected into a component's constructor by ReSharper's component model, or you can get them with solution.GetComponent<IShellLocks>, etc.
What's happening is that you're returning an action that takes in an ITextControl, and which immediately queues up another action to run, on the UI thread, with the read lock taken. This second action tells the tooltip manager to show an error message as a tooltip, and provides a factory method for creating a popup window context (the lifetime parameter is created and disposed by the call to Show, and allows for cleanup of the context).
You could also look at the ShowAtCaret extension method to ITooltipManager - I can't remember offhand where Show will place the tooltip.