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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse issue within application.com

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
392
GB
Hi,

I have an application that's running fine within "Developer". The application has a "Pageframe" with a Tab that I use to Browse various Database files. When running the compiled .com program, if I try to browse any of the database files the program "locks up".
This same command works fine in "Developer"

I have the following in the "start.prg" file that calls the Menu page which in turn calls the "Pageframe"

SET SYSMENU OFF

IF WVISIBLE ('STANDARD')
RELEASE WINDOW 'STANDARD'
ENDIF



Regards,
David
 
Ok Guys, you win! No matter where I look I see the same comments over & over, use a "grid control" instead of a "browse" so that is what I've done and it works fine! I am also beginning to see further advantages in using a "grid" over "Browse".

Now, can I use one "form" to selectively display different databases or do I need one form for each database? I guess that's one advantage of "Browse", you select your database and then browse it.

Regards,
David
 
Another question if I may!!

When in Browse you could hit "Esc" to close the Browse Window, I put a "ON ESCAPE RETURN" in the Forms "GOT FOCUS" to close the form but this does not work. How should I go about closing the form with the escape key?

Regards,
David
 
If you are already using forms it's a natural thing to use controls to display data and the grid has all the options a browse has, too. BROWSE is a developer tool to quickly open a table in edit mode. The grid simply needs it's recordsource = tablealias (typically dbf name without bdf extension), and it's recordsourcetype to alias and then works like a browse, because a brows is nothing else but a grid in a form anchroed to it's sides.

The form is closed via the upper right close button, and as I already said CTRL+F4 is the hotkey to close forms.
If you want to define your own way the closing is done by [tt]THISFORM.Release()[/tt], but caution! You can't define ON KEY LABEL whatever THISFORM.Release(), as the code you predifne with ON statements is not run in the context of the object making the definition, it has no context at all, it's like running a prg with the code inside, but what is available is _SCREEN.ActiveForm. There are situations though, when there is no active form.

Overall it's not recommended to define ON KEY LABELs as you have a) hotkeys via sysmmenu and context menu, toolbars and you can also define access keys for your own controls via \< prefix of letter in labels, eg if you set a commandbutton caption to "e\<xit" CTRL+X causes it's click event to run. You shouldn't override system hotkeys, though.

Bye, Olaf.
 
The easiest way to close a form via the ESC key is to have a Close button on the form. In the button's Click event, put your [tt]Thisform.RELEASE[/tt] as usual. Then set the button's Cancel property to .T.

When the user hits ESC, the effect will be to move focus to the button, and then execute the Click event, causing the form to close.

By the way, glad to hear you have gone over to using a grid. This is definitely a good move on your part.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes, I forgot the CANCEL/OK button concept of VFP.

.Cancel is the one property, making a button a cancel button, and on that topic the other property to mention is the .Default property, making the button the default (OK) button. The cancel button is triggered by ESC, the default/OK button is triggered by RETURN or ENTER (unless another button has focus). You have to add two buttons for getting this form behaviour of a dialog, all forms only react to the close button, which has the CTRL+F4 hotkey (easy to remember via ALT+F4 exit hotkey for all windows apps including Windows itself).

Bye, Olaf.
 
Along with what Mike and Olaf have said, on the subject of ON: don't.

ON KEY LABEL was invented when there was no better way. That is no longer the case. Pretty much the only ON commands you should be using are ON ERROR and ON SHUTDOWN. Any time you find yourself using ON KEY LABEL you're probably working too hard and not getting the result you want anyway so come here and ask for help, 'kay?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top