Last edited by Cimperiali; April 12th, 2003 at 09:18 AM.
...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.
Howe to take screenshots of current form every 5 minutes and save them as bmp files:
Download attached zip file. It is a working Vb example. Open it by doubleclicking on the Vbp file.
To capture entire screen, look for next reply...
Last edited by Cimperiali; April 11th, 2003 at 07:36 AM.
...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.
Previous example captured only current form. To capture whole screen, I did it a bit different:
...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.
This third example is the same as above, but it has one extra feature: reduces size of saved Bmp to 256 (or less, if you enter code and modify passed values) colors. This is usefiul to reduce size of Bmp saved (around 1/3 lighter each).
Wraning: in this example as in the previous one, I changed the timer to trig every 3 seconds instead of every 5 minutes (to test without waiting too much)...
The module that reduces colors of Bmp is not mine: code comes from http://www.Planet-Source-Code.com/vb...36162&lngWId=1 Credits on this feature must go to that author. I modified a bit the code changing all the "if...end if" in a more structured "If...ElseIf...End If"
...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.
Fourth... as per request by one user, the same code as last one with a different filename....
...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.
Fourth... as per request by one user, the same code as last one with a different filename....
I've just tried using this as an example for a program I'm working on. It seems to work.
I'm curious why you used the SetTimer/Killtimer, instead of the timer component in vb.
Because the originalrequest where all this started from was to take
a screenshot every 5 minutes. With Api Timer, you can set that intreval without
having to skip cycles as you have to do with a "normal" timer control.
...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.
Because the originalrequest where all this started from was to take
a screenshot every 5 minutes. With Api Timer, you can set that intreval without
having to skip cycles as you have to do with a "normal" timer control.
Thanks for the explantion- but do you mean skip CPU cycles?
Why is that an issue based on the original 5 minute interval?
Where is it documented that the vb timer skips cycles, and the timer that you used does not?
I don't believe I have read anything about this cycle issue, in regard to the timers.
SetTimer
The SetTimer function creates a timer with the specified time-out value.
UINT SetTimer(
HWND hWnd, // handle of window for timer messages
UINT nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // address of timer procedure
);
Parameters
hWnd
Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
nIDEvent
Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored.
uElapse
Specifies the time-out value, in milliseconds.
lpTimerFunc
Pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc <timers_52xv.htm>.
If lpTimerFunc is NULL, the system posts a WM_TIMER <timers_1w6q.htm> message to the application queue. The hwnd member of the message's MSG <JavaScript:alink_1.Click()> structure contains the value of the hWnd parameter.
Return Values
If the function succeeds, the return value is an integer identifying the new timer. An application can pass this value, or the string identifier, if it exists, to the KillTimer <timers_88xe.htm> function to destroy the timer.
If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError <errors_3uwi.htm>.
Remarks
An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER.
The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.
Thanks for the explantion- but do you mean skip CPU cycles?
Why is that an issue based on the original 5 minute interval?
Nah, Cimperiali is talking about the maximum interval that you can set the timers to. The native VB timer object has a maximum interval of 65,535 ms, which is just over a minute. Therefore, if the interval is set to 1 minute, 4 out of every 5 _Timer events need to be disregarded, in order to achieve the 5 minute interval requested. With the API timer, you can set an actual 5 minute interval (I presume, haven't tried) so there is no need to "skip cycles".
Nah, Cimperiali is talking about the maximum interval that you can set the timers to. The native VB timer object has a maximum interval of 65,535 ms, which is just over a minute. Therefore, if the interval is set to 1 minute, 4 out of every 5 _Timer events need to be disregarded, in order to achieve the 5 minute interval requested. With the API timer, you can set an actual 5 minute interval (I presume, haven't tried) so there is no need to "skip cycles".
Nah, Cimperiali is talking about the maximum interval that you can set the timers to. The native VB timer object has a maximum interval of 65,535 ms, which is just over a minute. Therefore, if the interval is set to 1 minute, 4 out of every 5 _Timer events need to be disregarded, in order to achieve the 5 minute interval requested. With the API timer, you can set an actual 5 minute interval (I presume, haven't tried) so there is no need to "skip cycles".
Cimperiali - I hope I interpreted your post right
Wait- now I'm confused. Both timers have a 65535 ms interval resolution- at least from my documentation.
So I don't see how you could get much over 1 minute with either timer.
The application in captureandsave256bmp.zip works fine. But I wonder why the author save the file as BMP, cant it be saved as jpg or other format which would reduce the file size?
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.