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

On screen maximize...do - I want to run a procedure on screen maximize 1

Status
Not open for further replies.

ahaws

Programmer
Nov 28, 2001
355
US
Good Morning All-
Sometimes my users will minimize my program to run another, but the problem being is the user must enter there employee number before my program starts and the employee number is a global public variable. However, If a clerk uses a program just by maximizing the screen, the person who is logged in might not be the person using the program at that time...
So I would like to know if there is a way to run a .prg when the screen is maximized so they can enter their employee number. I didnt see a onmaximize event or what not. Is there such a thing?

Thanks in advance
Angie
 
Hi Chris-
I havent tried it yet, but the only thing that I can think of as to why it may not work is that I have several forms within my app...so the user could virtually minimize at any point within the program. I would have to put this behind every form, or could I do a sniplet like

for i = 1 to forms.count do
allforms.resize()
&&code
endfor

or could I make it to where they cannot minimize until on the first screen? Is there a way to make it where they cannot minimize?

Thanks
Angie
 
Hi again!
That works great, but still would like to know how and when to call the resize() event to run the employee number retreival code. It really isnt a 'form'that the user is maximizing, it is the _screen that is maximized and minimized. So, at anytime the screen is min or maxed, is the resize() event called? How as a programmer would I know when the _screen.windowstate changes so I can call the code?

I guess I'm having a Monday on a Tuesday.

Thanks
Angie
 
Chris,
Note that the "tricks" in your FAQ don't work in VFP 8.0 SP1. You'll need to use BINDEVENTS() to get similar results. (The 'official' reason for making these stop working is because they could cause an application to become unstable.)

Rick
 
Chris,
Actually the whole FAQ - you can't &quot;add&quot; methods to the _SCREEN object. <s>

A program as simple as:
Code:
PUBLIC oHook
_Screen.AddObject(&quot;oHook&quot;,&quot;MyHook&quot;) && now screen resize event captured...

DEFINE CLASS MyHook AS Custom
  oScreen = _Screen

  PROCEDURE oScreen.Resize && attach VFP code to object's event when this class initialized
    Messagebox(&quot;New size: &quot;+transform(_vfp.width,&quot;9999&quot;);
      +&quot;x&quot;+transform(_vfp.height, &quot;9999&quot;))
  ENDPROC
ENDDEFINE
Fails at &quot;PROCEDURE oScreen.Resize&quot; in the ADDOBJECT() call with:
Program Error
Unknown member OSCREEN.

Cancel Suspend Ignore Help

Note: This worked fine in VFP 5.0 all the way up to 8.0 before SP1.

Rick
 
Hi Angie

May be you can do something like the following..

1. myForm.InitEvent

IF VARTYPE(ThisForm.tTime) = &quot;U&quot;
ThisForm.AddProperty(&quot;tTime&quot;,DATETIME())
ENDIF

2. myForm.KeyPreview = .t.

3. myForm.KeyPressEvent
IF (DATETIME()-ThisForm.tTime) > 60 && more than one minute
WAIT WINDOW &quot;You are caught.. Do a fresh Login.. &quot;
** Do a employee number acceptance to start with
ENDIF
ThisForm.tTime = DATETIME()
DODEFAULT()

The idea is that whenever there is no keyboard activity for more than 60 seconds, the employee has to make a fresh login. Probably, the employee has not minimised but went away. This can capture that also.

Another way is to do the same thing thru a timer event.
The timer event infact can popup a login box and leave the form at that condition, till the user either logs in or simply shut down thru a button in that login form.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Hi Ramani-
I was thinking of trying to use a timer last night, but wasnt sure if I could do it and if so, how to. I will try your suggestion and let you know how it goes...thanks so much for you help.
Angie
 
Hi Ramani-
Works great, but here's another question....what if -
After say 5 minutes the program is idle (no keystrokes, no clicks) I want to close program down automatically.
What property needs to be set to see whether or not there has been a keystroke or click within 5 minutes?? It would have to be global since I have many forms within my app...

All help is appreciated!
Angie
 
Hi Angie,

Put the code in your main.Prg before the main event is called...

ON SHUTDOWN DO myShutDown

At the end of the programme..
********************
PROCEDURE myShutDown
CLEAR EVENTS
QUIT
ENDPROC
********************

Then in the above timer explained, you can add the code..
IF (DATETIME()-ThisForm.tTime) > 60*5 && 5 minutes
DO myShutDown
ENDIF

One important point is that, you may have to cleanup and do some query unload whatever to take care of any open data entries.. (abort or save). In an average situation, probably just ignore the work-in-progress and quit (the user gets the punishment for small data entry in progress and leaving unattended).

(I will dream like some hibernation to save work in progress and then return back.. may be future VFP version can help to do that by captring the whole thing with a single command, may be HIBERNATE().)

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top