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

browse window coding question

Status
Not open for further replies.

MDoom

Programmer
Aug 31, 2001
52
US
I have a screen where certain fields will open a browse window to validate values that go into that field. When the browse window opens the user can choose the value with the the mouse or arrow keys, press enter and the browse window closes and the value appears in the field on the screen. The problem is that if the user presses the left mouse anywhere outside of the browse window, the browse window closes without any value placed in the field. I have the code set to close the browse window when the enter key is pressed. What code will keep the browse window active even if the left mouse is pressed outside the window, or somehow deactivate the left mouse?
Thanks
 
Not sure if I understand the circumstances, but try this...

Create a window using:

DEFINE WINDOW <windowname> NOCLOSE

This defines a window that can only be closed in a program, so you will have more control over when it is closed. The window could also be closed from the command window, but I assuming that it isn't visible while your program is running. You can close the window with RELEASE WINDOWS. When you create the Browse window, use:

BROWSE FIELDS.... WINDOW <windowname>

Does this sound like it will solve your issue?

dz
 
Here's the code for the validation of the field on the screen (the look up table and field are named 'status'). When entering a value that doesn't match the status table a browse window will open. The problem again is to not allow it to close with a left mouse click outside of the browse window:

IF USED(&quot;status&quot;)
SELECT status
SET ORDER TO 0
ELSE
SELECT 0
USE (LOCFILE(&quot;d:\emplap~1\tables\status.dbf&quot;,&quot;DBF&quot;,&quot;Where is status?&quot;));
AGAIN ALIAS status ;
ORDER 0
ENDIF


DEFINE WINDOW 'stat' ;
AT 19, .4;
SIZE 13.3, 47;
IN WINDOW 'wz_win';
TITLE &quot;Choose Employee Status&quot; ;
FONT &quot;MS Sans Serif&quot;, 8 ;
NOFLOAT ;
NOCLOSE ;
NOMINIMIZE ;
SYSTEM ;
ZOOM GROW
MOVE WINDOW 'stat' CENTER

LOCATE FOR m.status=status.status
IF !FOUND()
DO stat_prg
ENDIF

USE
SELECT emp_rep && Table where screen pulls data
RETURN


PROCEDURE stat_prg
SELECT status
GOTO TOP
ON KEY LABEL ENTER DO stat_deact
BROWSE NOMODIFY NOAPPEND NODELETE WINDOW 'stat';
FIELDS status :H='Status', descript :H = 'Status Description';
FONT 'MS Sans Serif', 10
ON KEY LABEL ENTER
_curobj=7

RETURN

PROCEDURE stat_deact
m.status=status.status && Put your choice into the status field
RELEASE WINDOW 'stat'
USE

RETURN

 
Hmm, you defined the Window with the NOCLOSE option, so I guess that doesn't work. I can think of two other options but one would require you to add a button to your window, and the other is kind of a kluge that may or may not work.

1. You could add a button to the screen and make it READ MODAL. The user would be required to press the button to close the window, and they would hear a beep if they press the mouse button outside the window. You could also check what was entered in the VALID clause of the button, if desired.

2. You could try:

ON KEY LABEL LEFTMOUSE DO <procedure>

In that procedure, you could check to see if the Window 'stat' is on top with the WONTOP() function. If the window isn't on top, DO stat_prg. If WONTOP() doesn't work, you might try WVISIBLE() and WEXIST(). Like I said, I don't know if this will work, but it's worth a try and relatively easy to implement.

Good luck. If you try any of these and have time to come back, it would be interesting to know if they worked or not.
 
Generally speaking, if I want to have the most control over how the user interacts with the screens/windows, I will create a separate Screen within which the user will make their pop-up choices.

When I compile the project I make certain that the pop-up selection screen is set Modal and has a button within it to Close it and return to the original screen.

If you need to have a large number of pop-ups that incorporate browses, then I would try to make a single pop-up selection screen which can vary to meet the needs.

You may already be doing this, or not, and, if so, I apologize for stating the obvious. Are you using Spinners, Lists, etc. wherever possible to avoid having to use an actual pop-up Browse screen for user selection?

Good Luck,
jrbbldr
jrbbldr@yahoo.com


 
Most of the lookup data in tables is too large to display in spinners, lists etc. A browse window works well though I may try a seperate screen. Thanks for the suggestions.
 
From a program, include SAVE in the BROWSE command.

ie
BROWSE ;
FIELDS status :H='Status', ;
descript :H='Status Description' ;
NOMODIFY NOAPPEND NODELETE ;
SAVE ;
WINDOW 'stat';
FONT 'MS Sans Serif', 10

Steven S
Professional Foxpro developer for DOS/Windows/Unix platforms since 1989.
clogic@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top