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.
Related
I am creating a MFC application based on example: https://github.com/microsoft/VCSamples/tree/master/VC2010Samples/MFC/Visual%20C%2B%2B%202008%20Feature%20Pack/WordPad
now i want to change the way to expand font name drop list in toolbar from DOWN key to F4. It seems i need to get the combobox and call SetExtenedUI(FALSE) on it, but i dont know where to do it.
To change the extended UI flag on a CComboBox, you call its CComboBox::SetExtendedUI member. When you have a CMFCToolBarFontComboBox you need to get to its combo box first. Since it inherits from CMFCToolBarComboBoxButton you can use its CMFCToolBarComboBoxButton::GetComboBox member to get a CComboBox*.
CMFCToolBarFontComboBox* pFontButton = ...;
CComboBox* pComboBox = pFontButton->GetComboBox();
pComboBox->SetExtendedUI(FALSE);
finally i switched to CComboBoxEx which works fine
I'm still learning GWT, yet already have to face some kind of challenge for a work I have to do. Can't show any specific code so I'll try to explain it well.
Here's the situation: A certain class "Navigator" creates and save the Presenter instances of my architecture to allow reusing them. There is a method show() inside that same class that actually displays the view related but that system only works full screen by calling RootPanel.get().
What i'd like to do is showing that presenter instance's view inside of a flex panel element declared in a class myView (related to a class myPresenter) that basically uses Flex Panel to structure it's content.
To make it maybe more clear:
class myView{
...
flexPanel.setWidget(firstWIdget)
flexPanel.setWidget(secondWidget) //secondWidget to be replaced by a "thirdWidget"
...
}
I'd like the secondWidget to be replaced by another one, let's call it thirdWidget, that consists of a specific presenter instance's view.
To resume, I'd like my presenter instance's view to not go full screen but only occupy a certain area of the screen.
The displaying is managed almost entirely programmatically, means very limited use of css files and no use at all of xml ui files.
How can I manage this ?
Thanks
Use a SimplePanel as a container for your views returned by your Navigation class instead of adding them directly to root panel, and use that instance of SimplePanel where ever you want.
I have a sap.m.TabContainer control with multiple sap.m.TabContainerItem controls. Each of the TabContainerItem controls have a number of their own controls on them. I have created a custom control (DBPanel) with a label and text field. It also has an enabled property for which I have overridden the setEnabled(boolean) method to enable/disable the internal text field within DBPanel. There are five (5) of these DBPanel controls on a specific TabContainerItem. When I call setEnabled(true) on each of these DBPanels, only three of the five become enabled. When I switch to another TabContainerItem and then back to this one, the final two DBPanels are also enabled. It is almost as if the TabContainerItem needs to be re-rendered. But I have read elsewhere that if rerender or invalidate need to be specifically called then there is something wrong with the code.
Any help would be appreciated.
Thank you
At your overridden method, you can try to call the original method that is extended. If you don't need extra logic rather than disabling or enabling it, you don't need to extend that method but I guess you have some.
First check whether superclass implements the method and then call the
method with the original arguments
if (DBPanel.prototype.setEnabled)
DBPanel.prototype.setEnabled.apply(this, arguments);
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
Right now, I'm working on my first WP7 app and have run into some questions, which I haven't been able to answer despite reading what I could find online. Please consider an app that has a main page, a parameters page and a results page. In the parameters page, the user can enter or update numbers in various textboxes. Hitting the back button takes the user back to the main page, where there is a button called "Calculate". Hitting that button should take the data, perform a calculation with it and take the user to the results page presenting a grid with the results.
In a file called Calculator.cs I have a class called Calculator inside a folder called Models. I also have my MainViewModel.cs, ParametersViewModel.cs, and ResultsViewModel.cs files inside the ViewModels folder and the corresponding MainPage.xaml, along with Parameters.xaml and Results.xaml inside a folder called Views. I'm assuming that all the data will be manipulated within the instance of the Calculator class and then a results set will be returned and directed to Results.xaml. I'm just at a loss as to where to instantiate the Calculator class, pass it data, then retrieve the results. I'm also somewhat puzzled how I will trigger the automatic navigation to the Results page when the calculation is done.
Any help with this would be greatly appreciated.
UPDATE: Passing a complex object to a page while navigating in a WP7 Silverlight application has some more info on the same subject. I can go into App.xaml.cs and add something like this:
public class Foobar
{
public string barfoo = "hah!";
}
public static Foobar myfoob = new Foobar();
Then access it from a ViewModel page, e.g. AboutViewModel.cs, like this:
public AboutViewModel()
{
string goo = App.myfoob.barfoo;
}
But at this point I'm still uncertain what unforseen effects that might have. I'm going to tackle serialization/tombstoning at this point to see what happens with either this approach or by using the same DataContext across pages. Otherwise, one of the posters in the link above mentioned serializing the params and passing them between pages. My concern there would be whether or not there is a character limit as with HTTP GET. Seems there is: URI Limits in Silverlight
There are of course lots of possible designs - and lots of them are correct in different ways!
Here's one I might use:
The Calculate button press should trigger the Navigate to the Results page
On navigate to, the Results page should show some animation (maybe just a progress bar)
On navigate to, the Results page should create a new ResultsViewModel, passing in the MainViewModel as parameters
the constructor (or some init method) of the ResultsViewModel should spark up a thread to do the calculation
when this calculation is complete, then the relevant properties of the ResultsViewModel will get set
at which point the databinding on the Results page will clear the animation and show the results
Other solutions are definitely available - will be interested to read what other people suggest and prefer.
As an aside, one thing to watch out for on your Results page is tombstoning - could be an interesting challenge!