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

How to deactivate popup?

Status
Not open for further replies.

pcwc66

IS-IT--Management
Dec 14, 2001
163
US
I have the following coding:
on key label ctrl+A do popup1
on key label ctrl+B do popup2

popup1 has the following coding:
define popup pop1
define bar 1 of pop1 prompt 'first'
define bar 2 of pop1 prompt 'second'
define bar 3 of pop1 prompt 'third'
on selection popup pop1 wait wind program()
activate popup pop1
deactivate popup pop1
release popups pop1

popup2 has the following coding:
define bar 1 of pop2 prompt 'fourth'
define bar 2 of pop2 prompt 'fifth'
define bar 3 of pop2 prompt 'sixth'
on selection popup pop2 wait wind program()
activate popup pop2
deactivate popup pop2
release popups pop2

After I hit ctrl+A, the popup pop1 shows up. Then, I hit ctrl+B, the popup pop2 shows up. The problem is that the popup pop1 is still on the screen. If I just simply hide pop1 in the beginning of popup2, hitting ctrl+A again will error out since the pop1 is already defined. If I deactivate pop1 in the beginning of popup2, the program flow goes back to popup1.

One solution that I can think of is to keyboard ctrl+B at the end of popup1. I also need to revise the popup2 coding to:

if popup pop1 has been defined (on the screen) (how can I code this?)
deactivate popup pop1
endif
define bar 1 of pop2 prompt 'fourth'
define bar 2 of pop2 prompt 'fifth'
define bar 3 of pop2 prompt 'sixth'
on selection popup pop2 wait wind program()
activate popup pop2
deactivate popup pop2
release popups pop2

I know that I can use popup('pop1') to check whether it is defined. However if I have more popups, I cannot specify the specific popup name and popup() will return empty since pop1 is not activated after I hit ctrl+B.


Thank you for any help.

 
Hi


on key label ctrl+A do popup1
on key label ctrl+B do popup2

popup1 has the following coding:
** Push key and pop key can help you solve
** users activating simultaneously the popups
** That is better unless you have some other reason.
PUSH KEY CLEAR
define popup pop1
define bar 1 of pop1 prompt 'first'
define bar 2 of pop1 prompt 'second'
define bar 3 of pop1 prompt 'third'
on selection popup pop1 DEACTIVATE POPUP
activate popup pop1
** If you want to trap ESC key pressed.. with READKEY()
IF BAR() > 0
WAIT WINDOW PROGRAM()
ENDIF
POP KEY ALL
**
popup2 has the following coding:
PUSH KEY CLEAR
define bar 1 of pop2 prompt 'fourth'
define bar 2 of pop2 prompt 'fifth'
define bar 3 of pop2 prompt 'sixth'
on selection popup pop2 DEACTIVATE POPUP
activate popup pop2
** If you want to trap ESC key pressed.. with READKEY()
IF BAR() > 0
WAIT WINDOW PROGRAM()
ENDIF
POP KEY ALL

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
Merry Christmas & Happy New Year
 
hi ramani,

I want to able to hit ctrl+B to do popup2 even though the popup pop1 is on the screen. Your coding will prohibit this.

I can get around this problem by having some global variables or objects to keep track what popup is currently defined. As of now, I cannot find any VFP function to tell me what popup is defined. Is there a way to get value stored by push popup?


Thank you.
 
Probably you can think of..

Define the popups when you start and simply do..

PUSH POPUP and POP POPUP just like PUSK KEY & POP KEY

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
Merry Christmas & Happy New Year
 
Hi ramani,

I'm not sure what you mean by using PUSH POPUP and POP POPUP. I don't know how you can get the value of the stack.


 
pcwc66,

Try this code. You might need to modify a bit to integrate the code into your apps.

** ---------------------
Private plQuit
Local llStart

Define popup pop1 from 1,1 shortcut
Define bar 1 of pop1 prompt 'first'
Define bar 2 of pop1 prompt 'second'
Define bar 3 of pop1 prompt 'third'
Define bar 4 of pop1 prompt '\<Quit'
On selection popup pop1 CheckPopup(program(), bar(), popup())

Define popup pop2 from 3,10 shortcut
Define bar 1 of pop2 prompt 'fourth'
Define bar 2 of pop2 prompt 'fifth'
Define bar 3 of pop2 prompt 'sixth'
Define bar 4 of pop2 prompt '\<Quit'
On selection popup pop2 CheckPopup(program(), bar(), popup())

On key label ctrl+A DeactivatePopup()
On key label ctrl+B DeactivatePopup()

plQuit = .F.
llStart = .T.
Do while !plQuit
Do case
Case (lastkey() = 1) or (llStart == .T.)
llStart = .F.
Activate popup pop1
Case (lastkey() = 2)
Activate popup pop2
EndCase
enddo
Release popup all
Wait clear


Procedure DeactivatePopup
Local lcPopup
lcPopup = popup()
If !empty(lcPopup)
Deactivate popup (lcPopup)
endif
EndProc


Function CheckPopup(tcProgram, tnBar, tcPopup)
Clear events
Wait tcProgram + ' ' + str(tnBar, 1) + ' ' + tcPopup ;
window nowait noclear
If (tnBar == 4)
plQuit = .T.
endif
Deactivate popup (tcPopup)
EndFunc
** ---------------------


Hope it helps

-- AirCon --
 
Oops. You don't need this line:

Clear events

Regards

-- AirCon --
 
I have tried something like this:

on key label ctrl+a definepopups(pop1)
on key label ctrl+b definepopups(pop2)

procedure definepopups
parameter newpopup
lcNewPopup = newpopup
if a popup has been defined
lcPopup = old popup
deactivate the old popup
lDefine = .t.
else
lcPopup = lcNewPopup
lDefine = .f.
endif
define lcPopup
activate lcPopup

** deactivate the old popup will cause VFP to go here

deactivate popup lcPopup
release popup lcPopup

if lDefine
lDefine = .f.
definepopups lcNewPopup ** this will define the new popup
endif

It is kind of working but then after hitting ctrl+a and ctrl+b, the next ctrl+a will not able to get out of the activate statement.

Thank you for any help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top