RFT - Check if a menu item is enabled or disabled - rft

I am using RTF (.Net) to write test scripts for an application created in VC++. In this VC++ application there is a Menu Item 'View', under which there is a sub menu item 'ConView'. The ConView is set the 'enabled' True at the design time and then at runtime it is set to False or True depending on some other values in the app. So, the sub menu item ConView could be enabled or disabled at runtime.
When I create the test object of the sub menu item using RFT, the .enabled property of the ConView is always TRUE even though it is actually disabled.
Questions - Does RFT consider the property value that was set at the design time and not consider anything changed at the runtime?
How do get the actual property of the submenu item by using RFT.
Thanks.

I have only experience using the Java edition of RFT to test Java and web applications. Given this setting, the property values change at runtime.
Could it be that in your case not the .enabled property changes at runtime but some other property? You can find out the values of all properties when you start to create a properties verification point for your object (when you are asked to select the properties to be included in the verification point). Just cancel the creation of the verification point (since you are only interessted in looking at the available properties and its values), then create a new properties verification point when the state of your object has changed—hopefully some property changed as well and can be used as an indicator to determine the state of your object.

1 Can you please provide your code?
2 Try yoursubitem.isShowing(). I also think that yoursubitem.isEnabled() is the wrong method.
3 Call the method yoursubitem.getProperties(): I think it should return a hashmap. Set a breakpoint there and you can see all the properties of yoursubitem. Look there for further possibilities to check out the state of yoursubitem.

Related

VBA Adding a User Defined Control to Userform at Runtime

So I've made the following control in Design Mode then added the control to a new page Custom in my toolbox.
Now, what would I use for the progID parameter in Controls.Add()? How do I look up this value? Controls.Add("Forms.Frame.1") adds a regular frame, not the desired custom control.
As far as I am aware, you do not generate a new progID with a custom control. Per the MSDN documentation for custom/modified controls:
Note: When you drag a control onto the Control Toolbox, you only transfer the advanced property values.
So only the properties are transferred; the actual control is still of the same type/s as the one you created it from. Further, it looks like this progID is "a unique system-wide string that the Windows operating system can use to identify your control's type." So unless you are up to coding your own control, it looks as though you're just passing properties to the custom toolbox controls you create there.
You'll have to just replicate the custom control each time you want to add it. Just create a sub with all the correct properties and call it. Not what you were looking for, but it'll get the job done.

undo for non textbox controls

new to .net coming from vba decided to rewrite a management app using vb.net and SQL Server.
Started writing the base library for my application.
I created custom controls to use in my application that would expose a Zoom function, background color for the current active control a .modified property similar to the one available in textbox and some extra other properties (SQLTableName, SQLColumnName, ...) to enable iterating through a container (form) for modified controls and Update/Insert into a SQL table via a SQLProcessClass.
Concurrently I'd like to also implement a simple undo functionality.
My first idea was to add a PrevValue variable set in the OnEnter event if the Modified property is False, exposing an OldValue property and an Undo method in the custom controls.
However I found that the TextBoxBaseClass already exposes an Undo method and that there is an UndoEngineClass available.
Unfortunately the vs helpfile does not give examples of how to use / implement that class.
Could someone explain the usage of the UndoEngine class non-textbox controls and if it is advisable to use it or rather write my own (as I first intended to do - I also found some interesting articles about undo/redo classes) but why reinvent the wheel in case .net already provides a class for it.
thks

How Can I Comprehensively Manage my VBA UserForm's Properties?

I am writing my first VBA Add-In under Microsoft Office Word 2007 with Windows 7 Pro/64. Part of this Add-In is a UserForm. Using the Visual Basic editor that runs from Word, I find there are two ways of viewing, and two ways of modifying a UserForm's properties:
View all properties from Object Browser (F2)
View some properties and edit them from Properties Window (F4)
Manually enter and edit any property from the Code window (F7)
Here is a screenshot of my Properties and Code windows:
A problem I find is that the Properties Window contains only a subset of the UserForm's properties (notice that CanPaste, CanRedo, and CanUndo don't appear in Properties), and changes made in the Properties Window are overridden by changes made in the Code window (e.g., at runtime, Me.Caption from the Code window above overrides the Caption field in Properties).
I suppose I should avoid using Properties at all then, and enter all settings via UserForm_Initialize as shown above. But (a) for some settings, Properties makes several settings at once. For example, selecting Verdana Bold from Properties equals Font = Verdana and Font.Bold = True in Code. And (b) it seems Properties sets the subset of properties it controls to defaults of its choosing, and if I change them I can't see what they started out as.
I therefore desire unified and comprehensive access to all my UserForm's properties at once, including the aforementioned default settings. Does anyone know how to reveal a UserForm's default settings as code, or to automatically open all its current settings in the Code window? Is there an umbrella mechanism I'm not aware of?
I'm not a veteran VBA programmer, but I can't believe my experience is unique. I've searched the 'net in vain for a solution. How do you with more experience manage this dilemma?
You use the Properties window to set appearance-related properties at design time. Those property values will then always apply unless you explicitly change them at run-time with VBA code.
Properties that don't relate to appearance, such as CanPaste and CanRedo relate to the state of the form at run-time, so it doesn't make sense to have them configurable at design-time.
You can change nearly all of the properties at run-time, whether it is in the Initialize event or elsewhere. You can even add controls at run-time, but your changes won't be persisted once the instance of the form terminates.

Editing settings for individual plugins

I have a vb.net project that loads "plugin" dlls at runtime to crunch some data in slightly different ways and return the results. To do that, all the plugins implement the same interface, so the GUI couldn't care less how the plugin arrives at its final dataset, just so long as all the plugins deliver it back to the GUI in the same way.
I'd like to set up per-plugin options in addition to the main program options. I have an options form that accepts an object of type System.Configuration.ApplicationSettingsBase and displays the contents in a PropertyGrid control, so it'll show any My.Settings object the same way. Question is, how do I pull the My.Settings object out from a plugin that's loaded at run-time?
Figured it out. I used the My.Settings for each class library to hold the individual settings, and in my plugin interface, specified that each plugin should implement its own RaiseOptions() method, which would create a new instance of an options form, push the My.Settings object to the form, and then display those settings on the form's PropertyGrid control. Since the plugin is doing the calling, it is set to use the correct My.Settings object (rather than the My.Settings object from the GUI).
It did require adding a few references so that a class library could display a form properly, but IntelliSense was pretty good at pointing out exactly what I needed.

vb.net getsettings

I need a form width a checkbox "Don't show this again" for my winform,
but how can i make this so when my Form1 loads it checks the state of the checkbox using the getsettings option?
How can is save the checkbox state to the registery? and how do i get the state?
If Form2.Checkbox.checked = Getsettings() Then
Form2.showdialog
Else
Goto Skip
End IF
Skip:
Windows Forms has built-in support for that, you don't need to write any code. Select your check box. In the Properties window, scroll to the top on expand the "ApplicationSettings" node. Click on "Checked" and drop-down the combobox. Click New. Set the Name property to something meaningful.
Done. Your check box will always restore with the last selection that the user selected. Don't call Show() when it is turned on, dispose the form right away.
The main crux of the question is "how do I read and write value to and from the registry."
See here for a great overview complete with code.
You're beginner so here are a few tips on your code sample:
Name your objects more verbosely. Form2 will mean nothing to you a few hours from now.
Do not use Goto. Just don't. Please. You either show the dialog or you don't. The whole Else block with the Goto in it is just not necessary.
Few more things you'll need to do to get this working:
Handle the CheckBox checked event and write either a 1 or 0 (or T or F) to a registry value
Read that registry value in your GetSettings method
You might want to pass a parameter to GetSettings that specifies exactly which setting you need because you'll probably want to reuse that method for other settings as well