Main menu in a FoxPro 9 app - visual-foxpro

If you use the Visual FoxPro 9 Application Framework to create a desktop standalone application and add a database and form, the exported exe shows a Quick Start on load which shows the form to select.
If one wants to show up his own MAIN MENU form on the exe load, what's the way to do it? Using Set Main on the Menu Form does not work.
Here is a visual representation of the idea.

In its simplest steps then, aside from the "Wizards" you can use to build forms and bind to data environments, tables, grids, etc maybe this will help.
Create an empty project.
CREATE PROJECT MyApp
Go to the documents tab and add a new form. Put a few buttons as you've described on it. One of the buttons, allow to close the form, such as "Exit". Double click this exit button and put in the code
CLEAR EVENTS
THISFORM.RELEASE()
Since there are no "data entry" elements on this form, we need something to make it keep focus. Buttons alone don't just "do" that. Go to the properties sheet of the form and go down to "Window Type" and set it to "Modal" - meaning, keep this form up until its intentionally closed. (This also keeps as a baseline for you calling any OTHER forms from this one for your application.) Save the form, such as "MyMainForm".
Click on the "Code" tab of the project and do a new "Program". In its simplest context, put in
DO FORM MyMainForm
READ EVENTS
Save the program, such as MyStartupProgram. Once saved in the project, right-click on this program and select "Set Main" for this to be considered the single entry point to your entire application. Save, build the project and run it. You should be good to go.

Related

how to open a .dsr crystal report in vb6 needs startup form

I have a DSR file containing a crystal report, but everytime I try to run the project, the error Must have start up form pops up. As far as I can tell, I have a crptEmployeep9infoView ICR designer in the project explorer window only.
The VB IDE is telling you it doesn't know how to start the application.
Go to the Project properties page.
Ensure the General tab is selected.
On the top right, there is a drop down box labeled "Startup Object"
You should have either a start up form selected, or "Sub Main" selected.
If neither of these options exist, create a form, or open a BAS file and create a Sub Main. This object should then run your report.

How do I add a window from the resources as a child window?

I am creating a windows using win32:
HWND mainWnd = CreateWindow(...);
Now I can add gui elements as children of mainWnd. However this soon becomes a bit tedious and I want to use the designer built into Visual Studio to help me.
I noticed that under Add Resource there is a Dialog entry. Among the dialogs IDD_FORMVIEW seems the most general so I added one of these. Next I added gui elements to it using the designer.
Now I want to use this as a child of my mainWnd. How do I do this?
I found some examples using DialogBox, but I do not want a separate dialog, I want this window as a child of my mainWnd.
The designer in Visual Studio is appropriate for creating dialog boxes, not arbitrary windows.
That being said, there are a couple of approaches (in increasing order of difficulty):
Make your main window a dialog. Petzold's book has an example of using a dialog as the main window of the program. (If I recall correctly, it's the calculator example.)
Create the dialog and, before you show it, change its style to WS_CHILD, change its extended style to WS_EX_CONTROLPARENT, and parent it to your main window. For all the navigation stuff to work, you'll have to add IsDialogMessage calls in your message pump. This is do-able, but it's likely hard to get everything working well.
A mixture of 1 and 2 where you create one dialog for your main window, then create a second dialog for the content (with DS_CONTROL), and put the second dialog in the first. I've never tried this approach myself, but it seems like it should work.
Write your own code to parse the dialog resource and create the child windows, which is basically re-doing a lot of the work that CreateDialog does for you.
Given your desire to use the GUI to design the UI, I suspect only the first solution is simple enough that you would be interested.
Use the CreateDialog API to create the window from the resource. If you do not want it to look like a dialog then remove the titlebar style from the resource properties.
To use a dialog created from a dialog resource template you have to specify the DS_CONTROL window style in the template.
Read more about dialog boxes here.
Dialog resources are explained here

Data Driven Coded UI Testing in Visual Studio

I am curious about an issue in Coded UI Testing. For example I created a button named Button1. I did assertions and everything is fine. Then I changed this button's name to Button2. Now, do I have to write my assertions again or is Coded UI Test can suit in every different name change. Notice that I am not doing any input or parameter changes, I am just changing user interface. Thanks for your replies.
You should be able to change the test code easily to cope with a name change like that. Open the UI Map file in the UI Map editor; ie double-click on the uimap.uitest file in solution explorer. In the left hand pane expand the method and select the action that clicks the button. That should open the relevant control in the right hand pane. Alternatively just find the control for the button in the right pane. View the properties of the button and click on the ellipsis of the "(collection)" value of SearchProperties or the FilterProperties. One of the items shown should be the old name of the button, just rename it there.

VS2010: How to see GUI

I need to know how to open the form of a program I am debugging.
I loaded an existing solution into VS2010, I can see the code, but I want to see the GUI part of the project, click on buttons and see what part of the code they take me to, set breakpoints where I feel like.
I don't know how to see the GUI in VS2010, where can I do that?
Also, where would be a good resource to learn the ins and outs of VS2010?
Depending on how the UI was created, there may or may not be a way to see the UI at design time. Particularly if this is an older Windows UI application, it's likely that the windows are created entirely in code, and there is no design-time UI for you to see.
There is a dialog editor, for dialog windows that are defined in resource (*.rc) files. CTRL-SHIFT-E brings up the Resource Viewer and you can look for things under the Dialog node. It is possible that your main window is a dialog-style window, as that's one of the options you get when you create a new MFC-based application.
Otherwise, your only option to see what your UI looks like is to run the program and see. Tracking down which UI elements do which actions in your program will require finding the appropriate event handlers or message handler methods (again, depending on what UI framework, if any, is in use) and setting breakpoints.
The generic answer is:
Hit F5 to starting Debugging mode. (Or under the Debug menu choose Start Debugging)
But it depends on how your project is setup and what type of project it is if F5 will work that easily for you.
What kind of program/language are you using?
With a form, I believe you have to File-->Open-->Project/Solution
Now if its a website, you would open Website. If you tried to open a windows form under a website then you wont see the design.
Typically you would just double click your form name (form1.cs) because then your design view will pop up or hit Shift+F7 or rightclick --> view designer. Then just double click whatever tools you have on your form (like a button) and it will automatically go to the button code.
If its a website, then it would be under website1.aspx while the code sits in website1.aspx.cs
But if none of that helps, here is a good place to learn this stuff
VisualStudioWalkthroughs

Need ActiveX control to embed Excel into a dialog

I'm building an "import from Excel" function. It has to be in a DLL, called from a non-MFC app. Has to provide an image of the spreadsheet that users can drag a select box around (to select cells), then click an IMPORT button, and have the right thing happen. Having trouble getting the spreadsheet up, having a button adjacent to it, and having it happen in a DLL.
I went the route of an MFC dialog inside a DLL, but was blocked in trying to bring up an OLE client for excel on a window on the dialog. Only support I found for showing Excel using OLE required an SDI. I was able to get the automation functions to work, and I could read the cells and paint a "fake image" of them on my dialog... but I'm afraid that's going to be in non-compliance with my requirements.
So I tried creating an SDI. I was able to create an SDI that brought up Excel as an OLE Client. I was able to handle the "selection change" event, and go the cell data I needed. I was foiled at this point by 2 items:
Could not make this SDI work in an MFC DLL. Crash in CWinApp constructor, asserting that the AfxGetThread wasn't null. Moved "theApp" to be locally scoped within the single exported DLL function, but still couldn't get it to work, but with different symptoms: crashed when added AFX_MANAGE_STATE(AfxGetStaticModuleState( )); to exported DLL function, if I didn't use that, the OnInitInstance never was entered. Tried adding a call to the app's Run() function, but that didn't help. I can post this code if someone thinks they have an idea what the problem is.
Could not present a toolbar while the Excel client item was active. I could put my "import" (and other options) on the menubar at the top, but that's not evident enough. Even a floating toolbar was closed. It makes sense that it would do this, since it would be confusing to have a toolbar present that couldn't take actions on the currently active item... but in my case, it's a problem.
So now I'm thinking I need to go back to the dialog approach, and embed an ActiveX control that brings up an excel spreadsheet file to import.
Must either allow me to handle the selection change event, or must allow me to find what cells are selected (or were most recently selected if clicking the "import" button on my dialog causes the selected cells to become unselected).
It must also come with reasonable licensing terms, as this will be used in a commercial application that is widely-available to the public.
If anyone knows of a "quick fix" to either of the approaches I had been trying, that would be useful too.
Hope someone can help me!
If you just want to embed Excel, you don't need anything.
Just embed it into a standard OCX host control.

Resources