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

How To Display User Defined Browse Window In A Top Level Window? 1

Status
Not open for further replies.

InOverMyHead

Technical User
Feb 19, 2003
4
US
I just changed an program so that it no longer loads in the foxpro window, it now loads into the main switchboard window which I have set SHOWWINDOW = 2 and the remaining forms to SHOWWINDOW = 1. I call these forms from the switchboard form and have added _screen.visible=.F. and READ EVENTS to the MAIN program, which in turn calls up the switchboard.
Everything works fine - except - I have three forms that make use of User Defined Browse windows. With the removal of the vfp window these browse windows no longer appear. I did not code these and know nothing of how they work.
I've spent the better part of the day researching and trying what made sense to me but with no aviail.
Am I correct in that somehow I set the SHOWWINDOW value in this user defined window to 1?
Any help would be most greatly appreciated.

CODE FROM BROWSE BUTTON THAT LAUNCHES BROWSE WINDOW:
*(This reflects changes I have made to IN WINDOW from it's *previous setting of IN WINDOW SCREEN to IN WINDOW *frmAddCat. frmAddCat is the name of the form that appears *in the top level window in which I need to browse to *appear. I also added the wndCmdBrowse.showwindow = 1.)

LOCAL lcMaintable, lnSelect, lcKey, lcUseAgain, lcOnError, lcOnEnter

lnSelect = SELECT()
lcMainTable = Thisform.DataEnvironment.Maintable.Alias


SELECT (lcMainTable)

lcKey = catname
lcUseAgain = pcAutoDataDirectory + "addcat"

USE (lcUseAgain) AGAIN IN 0 ALIAS brwAddcat ORDER catname
SELECT brwAddcat
LOCATE FOR catname = lcKey
IF (!FOUND())
LOCATE FOR .T.
ENDIF


DEFINE WINDOW wndAddcatBrowse ;
AT 1, 1 ;
SIZE 20, 20 ;
IN WINDOW frmAddcat ;
NAME wndCmdBrowse ;
FONT "Arial", 9 ;
DOUBLE ;
NOCLOSE NOFLOAT NOGROW NOMDI NOMINIMIZE NOZOOM

lcOnError = ON("ERROR")
ON ERROR POP KEY ALL

lcOnEnter = ON("ENTER")
ON KEY LABEL ENTER KEYBOARD ;
IIF(WEXIST("Find"), "{ENTER}", "{CTRL+W}") PLAIN CLEAR


wndCmdBrowse.showwindow = 1
wndCmdBrowse.WindowState = 2



wndCmdBrowse.Show()
BROWSE NORMAL NOEDIT NOAPPEND NODELETE NOMENU ;
TITLE "Categories" ;
WINDOW cmdAddcatBrowse
wndCmdBrowse.Release()

ON KEY LABEL ENTER &lcOnEnter
ON ERROR &lcOnError

IF (LASTKEY() = 27)
* User pressed ESCAPE
* Leave value of lcKey alone - return use to pre-Browse record
ELSE
lcKey = brwAddcat.catname
ENDIF

USE IN brwAddcat
SELECT (lcMaintable)
LOCATE FOR catname = lcKey


Thisform.ShowGets()
SELECT(lnSelect)
 
Your problem is taht you are mixing "old code" with newer OOP type coding, when Define window came out you couldn't do top level windows (and you still cannot). My suggestions is either
1.Using a grid on a new form to show the records.
2. Define a window class in your main program where in a class you can specify a top-levl window. Example put this in you main program:
Code:
DEFINE CLASS BrowseWindow as Form
 titlebar = 0
 Showwindow = 1 &&Top level
 autocenter = .t.
 WindowState = 2
 name = "BrowseWindow"
ENDDEFINE


And in the click event of the button to browse the records use:
oBrowse= CREATEOBJECT("BrowseWindow")
oBrowse.SHOW()
BROWSE IN WINDOW BrowseWindow

And if you need make the browse window full screen adjust the SYSMETRIC of the form to the size of your screen.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike, thanks!
I just did what you suggested and in less than 10 minutes all of my browse windows are functioning again. That is outstanding as I spent a good many hours yesterday trying to figure this out (and more when I got home!)

One thing I did noticed is that the standard foxpro CTRL-F search is now gone. I am assuming this is because I have dumped the foxpro window??
So my question is does anyone know of an easy way to re-gain this function in the browse window, or an easy to make alternative? This is a good size table with 3,000 products and scrolling to find a product is not really a viable search method.
I am not a programmer so "easy" is the key word here...
Thanks in advance for any help.
 
InOverMyHead

Although one would think that adding a top-level menu right on the form that would include the "Edit" part of the default VFP menu, that allows you to access the find screen, woudl work, sich is not the case. This might require a little thinking. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,
I have been searching both on the net and through the old posts here trying to answer my own question and haven't been able to so far. However, I did notice that quite often when questions arise concerning functionality in browse windows the concensus seems to be not to use a browse window at all, but to use a grid on a form instead. Would you agree with this?

My situation is that I can't really write code. I have this program that was pretty much written for me, and I've tweaked it here and there for our company needs, but that's about the limit to my "expertise".

When I first added the code you supplied, I was thrilled to see the browse windows finally working. On closer inspection I noticed I was now able to edit the fields in the browse window - something I didn't want to occur. After intersecting your code with the existing code in different combinations I was able to get the windows to work, with no editing allowed, and to select/return the proper record by pressing my return key. My point is to me that was a major accomplishment and pressed me to the limits of my abilities to work in the code.

I feel comfortable in creating a grid from a table, if that's what you would suggest, but I'm not sure about any underlying code that would be involved to keep the features I now have, while adding the simple search capability we desperately need.

Thanks for your help.

Ron
 
InOverMyHead

I have been searching both on the net and through the old posts here trying to answer my own question and haven't been able to so far. However, I did notice that quite often when questions arise concerning functionality in browse windows the concensus seems to be not to use a browse window at all, but to use a grid on a form instead. Would you agree with this?

As I posted in my original reply, yes using a grid would be more in-line with the current technology and more in-line with the OOP (Object oriented programming) way of doing things.

When I first added the code you supplied, I was thrilled to see the browse windows finally working. On closer inspection I noticed I was now able to edit the fields in the browse window - something I didn't want to occur.

That is correct. My suggest for the code should have respect your original code, where I said:
BROWSE IN WINDOW BrowseWindow
It should have read :
BROWSE NORMAL NOEDIT NOAPPEND NODELETE NOMENU IN WINDOW browseWindow

I feel comfortable in creating a grid from a table, if that's what you would suggest, but I'm not sure about any underlying code that would be involved to keep the features I now have, while adding the simple search capability we desperately need.

If you choose to go with the grid option (which I would recommend, but lets see if we can fix the Browse issue first), Ramani has written an FAQ on an incremental search in a grid, found in faq184-1214.

I'm still pondering the find feature you had in the original browse window, but at least you no-edit has been resolved.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
In a completely different tack, which is not in-line with modern technology, but is really just a hack (but, I think, a really neat hack...) you could use the FreeWindow function in faq184-2555 to just free the Child Browse Window (child to the main VFP window) and make it a top level window, then use the TakeWindow function (in the same faq) to embed the browse window into your top level window.

It might take a little messing around with the order of things to get it to work just right, but in the end you could use your original BROWSE statements, and they would end up as top level windows.
 
Thanks for the replies.
I finally just created a form, assigned various text and combo boxes for the fields in the table, and used vfp 6's find foundation class to add search capabilities to the form.
All works great and I actually have more control over the information displayed and can format it in a way that is much more appealing and easier for the end user to comprehend.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top