|
-
August 1st, 2001, 07:18 AM
#1
Application Idle
i have an application with 60 forms, and atleast 40 simultaneous users use it,
so are the database connections.my problem is to end the application if it is idle for more than 20 minutes. From my application i call an excelobject to print reports which takes a max of 2-3 hours depending on the report so ordinary keyboard hit and mouse movement tracking is not useful.
Many thanks in Advance
-
August 1st, 2001, 07:34 AM
#2
Re: Application Idle
One possible way to do this is to set the screen saver inactivity time to 30 minutes and when the screensaver is triggered, shut down your application.
Write an application which finds your application (using FindWindow() API call) and sends it a WM_CLOSE message. Then create an Exe and rename it's extension to .scr of this program and put its name in the [screensave] section of the win.ini (or use the controlk panel to make it the selected screensaver)
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
-
August 1st, 2001, 07:41 AM
#3
Re: Adding to Clearcode
..And if you need a way to set the screensaver via Vb code, have a look at VBnet
and search for "screensaver" or "SystemParametersInfo".
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood,
Bruno Paris and all the other wonderful people who made and make Codeguru
a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 2nd, 2001, 01:33 AM
#4
Re: Application Idle
thanks for responding ,
but as i have said that i cant use the concept of a screen saver because of the report generation which will take place for more than 2 to 3 hours
and during this time the keyboard and mouse will be idle but not the excel application which will be called from vb to spool the report by the excel object component
and as far as EventsVB.ocx control is concerned i tried it once and it gave a message that .hwnd property is not supported
plz try to resolve my problem
Many thanks again
-
August 2nd, 2001, 02:49 AM
#5
Re: Application Idle
The way to use the EventVB.OCX is to put the control on your application's main form and put the following in the form load event:
private Sub Form_Load()
VBEventWindow1.ParentForm = me.hWnd
'The hWnd property is from the VB form...
End Sub
However, if I understand properly what you want to know is that the Excel application is no longer loaded or just that it has completed spooling?
In the former case you can use FindWindow() and cycle your VB app in a DoEvents loop until it returns zero.
In the latter case you can declare your link to the xl applications WithEvents thus:
Dim withevents xlApp as Excel.Application
(Note that WithEvents is only valid for declarations inside a class or form in VB5/6)
Then when your application has finished spooling to the xl application, have it attempt to close the xl workbook and trap that in your program using the
private Sub xlApp_WorkbookBeforeClose(byval Wb as Excel.Workbook, Cancel as Boolean)
End Sub
event...
Hope this helps,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
-
August 2nd, 2001, 08:11 AM
#6
Re: Application Idle
Ooh - there is another way.
If you take a note of your CPU usage before launching excel and then monitor that then when it drops back down to what it was before you launched Excel, your report is complete and your application can close.
The exact values involved may take some fine tuning but to find out what your CPU usage is at any given time,
private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (byval hKey as Long, byval lpValueName as string, byval lpReserved as Long, lpType as Long, lpData as Any, lpcbData as Long) as Long
private Const HKEY_DYN_DATA = &H80000006 'reg key root
public Function GetCPUUsage() as Long
Dim data as Long
Dim hret as Long
hret = RegQueryValueEx(HKEY_DYN_DATA , "PerfStats\StatData\KERNEL\CPUUsage", 0&, REG_DWORD, data, 4)
GetCPUUsage = data
End Function
Hope this helps,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|