Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Menu - Displaying open form names 3

Status
Not open for further replies.

jimoo

Programmer
Jun 2, 2003
1,111
US
I must be braindead this week.

I am trying to create a menu with the standard "Window" item next to last, just prior to "Help" - Pretty Standard.

I am unable to get it list all the names of the open forms. I have a MDI environment where same form (different customer) will can be open. I need for the user to have the ability to cycle from one form to another using the menu option.



Jim Osieczonek
Delta Business Group, LLC
 
How about this?

Code:
IF _screen.formCount>=1 
 FOR i = 1 TO _screen.formCount
  ?_screen.forms(i).name
 ENDFOR 
ENDIF

Brian
 
That may be part of the solution. I Want to load these items, and remove them from the menu item "WINDOW"

In other words, the behavior is very similar to word or excel where you can select the "Window" menu option and a list of all open documents will appear. I don't recall if there is a VFP BAR # that does this for you. I have found cycle & arrange, but that is not what I am looking for.

If there is no bar, I will need to manually add/delete the item each time a new form is open & that is kind of sloppy.



Jim Osieczonek
Delta Business Group, LLC
 
Jim,

Here's how I do it:

- Launch the menu designer. Select Menu / Quick Menu. That'll give you a menu populated with the standard VFP menu.

- Delete all the menus except Window and Help.

- On the Window menu, delete the items that you don't need (such as Command Window and Dockable).

- Customise the Help menu to meet your specific needs.

- Generate and save the result as Wmenu (for example).

- Create your normal application menu, leaving out Window and Help. Call it, say, Amenu.

- In your main program:
DO Amenu.MPR
DO Wmenu.MPR

You will see the menus in the right order, and, most importantly, the Window menu will have the standard behaviour, which includes displaying a list of open forms.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
When I build a menu, I start with a Quick Menu. Leave the Window item on the main menu. Take off things like Hide, Clear, Cycle...things you won't need. VFP will take care of the rest, including adding and removing open forms.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Hi Jim.

>> I am trying to create a menu with the standard "Window" item next to last, just prior to "Help" - Pretty Standard. <<

You need to create the Window pad of your main menu with a "dummy" bar that can be removed in the menu's cleanup code like so:

Code:
RELEASE BAR 1 OF Window

Then, you really need either your form manager or form class to handle adding the name of the form to the window menu when the form is instantiated like so:

Code:
LOCAL lnNoMenu, lcNameID, lcCommand
IF CNTBAR("Window") = 0 OR GETBAR("Window", CNTBAR("Window")) < 0
   lnNoMenu = CNTBAR("Window") + 1
ELSE
   lnNoMenu = GETBAR("Window", CNTBAR("Window")) + 1
ENDIF
DEFINE BAR lnNoMenu OF Window PROMPT THIS.oActiveForm.Caption AFTER _MLAST
lcFormID = THIS.oActiveform.cFormID
lcCommand = 'ON SELECTION BAR ' + TRANSFORM( lnNoMenu ) + ' of Window '
lcCommand = lcCommand + "oFormManager.ActivateForm( '" + lcFormID + "' )"
&lcCommand

Finally, you need a method to remove the form name from the window menu when the form is destroyed - something similar to this:

Code:
LOCAL lnBar, lcCaption
FOR lnBar = CNTBAR("Window") TO 1 STEP -1
  IF PRMBAR("Window", GETBAR("Window", lnBar)) == THIS.oActiveForm.caption
     RELEASE BAR GETBAR("Window", lnBar) OF Window
     EXIT
  ENDIF
ENDFOR






Marcia G. Akins
 
Thank Gang - greatly appreciated & the non-profit that I am writing this for (free) also appreciates your help.

Mike - I tried your suggestion and only the second menu showed up.

do myapp.mpr
do addon.mpr && window & help

I don't know why it didn't work correctly because I have looked at other samples and that is how they call multiple menus.


Craig - Worked great. I am still toying with Marcia's code though because it will provide me more flexibility in displaying only forms I want to display. I see how it goes with the app.

Marcia - Thanks! I like it. As I mentioned - I like the added control.


I am using Craig's suggestion for now unless I need the added control.

Thanks again everyone.


Jim Osieczonek
Delta Business Group, LLC
 
Jim,

I tried your suggestion and only the second menu showed up.

My fault. I should have added:

- Go to the General Options dialogue (in the menu designer) and select Append.

Still, Craig's and Marcia's solutions are good too. The reason I do it the way I suggested is that the resulting menu is pretty generic; I use exactly the same menu now in all my apps.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top