Hi Francesco,
The problem is when the delay is outside the control of the PRG code
(eg. a SQL query) where control is transferred to some other non-PRG
process and the PRG process must wait until it completes - In this
case, anything in the PRG code cannot help as is not running.
As I mentioned, in Windows this can be handled with a second thread -
I have no idea what to do in other operating systems.
Randy.
At 02:10 PM 6/12/2008, you wrote:
Hi Pripal and others,
sorry to jump in and if I miss something, but, reading fastly I have
understood that you have problem with long loops or intensive jobs.
In Windows I have solved it using code I have written and attached here.
Use it inside heavy loop as shown in example on top of file.
Please test it because I haven't tested alone (it is extracted from
a lib of mine). So, probably, I missed some header needed.
If you find usefull please add to SVN.
Best Regards
Francesco Saverio Giudice
Pritpal Bedi ha scritto:
Hello Przemek
<<<
It's problem with GUI GTs: GTWVT and GTXWC. In the most
of GUI system application has to redraw its screen contents.
Probaly in each OS some hacks exists which alows to move
this job to OS. F.e. on some X-Window systems it's possible
to set bitamp as window background and it will be redrawn
automatically by window manager so GT only have to update
this bitamp on output. Probably sth like that exists also
for MS-Windows. But because it will be hack which can cause
troubles in portability I left it for the future.
Exactly this I wanted for GTWVG but could not find a better way.
<<<
BTW I do not like that GTWVG draws into two areas: directly
to window and to internal bitamp. IMHO it will be much
easier to update only internal bitmap and restore the
screen from this bitamp or if possible to make it window
background as I wrote above.
As I said I could not find other ways to achieve this.
May be my knowledge in WinAPI was very limited then.
Can you please give me a clue how this can be changed.
A line or two of code will be enough to move into that direction.
<<<
Please remember that we also need common system for
inspecting incomming events.
For this point in mind I just suggested HB_GTE_INKEY
but still has not been accepted by the group.
<<<
So far I'm using my
own library which uses select() for it (in *nixes
select() can watch for any type of handles not only
for sockets like in MS-Win). Anyhow it will be very
nice to have a solution on Harbour level which will
work also in MS-Windows and as I said I plan to work
on it.
For sure I will wait for it to happen.
Regards
Pritpal Bedi
/*
2006 (C) Francesco Saverio Giudice
hb_SystemMessageRelease( <nMilliseconds> ) -> <lQuit>
This function releases application message queue.
It is usefull inside a heavy loop or file or dbf handling and it
will empty message queue like Screen Updating.
It will wait until or time will expires or an keyoboard or mouse
event will be intercepted in queue or queue
will be empty.
Parameters :
nMilliseconds = 0 is INFINITE or a limited milliseconds time
Returns:
lQuit = .T. if there is a WM_QUIT inside message queue
(to be handled from application)
Example:
....
DO WHILE !Eof()
field->name := cName
...
// Release Windows Application Queue
IF hb_SystemMessageRelease()
// WM_QUIT intercepted
EXIT
ENDIF
SKIP
ENDDO
....
*/
#define HB_OS_WIN_32_USED
#include <windows.h>
#include "hbapiitm.h"
#include "item.api"
BOOL hb_SystemMessageRelease( int iMsec )
{
int iQuit = (int) FALSE;
HANDLE hDummyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
/* Begin the operation and continue until it is complete
or until the user clicks the mouse or presses a key. */
while (MsgWaitForMultipleObjects(1, &hDummyEvent, FALSE, ( iMsec
== 0, INFINITE, iMsec ), QS_ALLINPUT | QS_ALLPOSTMESSAGE) == WAIT_OBJECT_0 + 1)
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
switch(msg.message)
{
case WM_QUIT:
{
iQuit = (int) msg.wParam;
goto stopLoop;
}
default:
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (!iQuit)
{
goto stopLoop;
}
}
stopLoop:
CloseHandle( hDummyEvent );
return iQuit;
}
HB_FUNC( HB_SYSTEMMESSAGERELEASE )
{
hb_retl( hb_SystemMessageRelease( ( ISNIL( 1 ) ? 0 : hb_parni( 1 ) ) ) );
}
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour