Re: Win32 non blocking console input?
- From: NathanCBaker@xxxxxxxxx
- Date: Wed, 15 Oct 2008 20:37:51 -0700 (PDT)
On Oct 15, 5:04 am, Herbert Kleebauer <k...@xxxxxxxxx> wrote:
NathanCBa...@xxxxxxxxx wrote:
On Oct 14, 4:51 am, Herbert Kleebauer <k...@xxxxxxxxx> wrote:
Here it is in your favorite syntax:
I can live with the syntax, but does this work for you? Even if I
Why not just use a pop-up window??
A pop-up window in batch program? Seems the point-and-click generation
hasn't respect for anything! But how should this help, don't think
that MessageBox() has a time-out parameter.
Here you go:
program TimeGetc;
#include( "w.hhf" )
#include( "stdlib.hhf" )
static
hInstance: dword;
key: dword;
readonly
ClassName: string := "TimeGetcClass";
AppName: string := "Press a key!";
var
wc: w.WNDCLASSEX;
hwnd: dword;
procedure WndProc( hWnd:dword; uMsg:uns32; wParam:dword;
lParam:dword ); @stdcall;
begin WndProc;
if( uMsg = w.WM_DESTROY ) then
w.PostQuitMessage( 0 );
sub( eax, eax );
elseif( uMsg = w.WM_CREATE ) then
w.SetTimer( hWnd, 500, 3000, NULL );
elseif( uMsg = w.WM_TIMER ) then
w.KillTimer( hWnd, 500 );
w.SendMessage( hWnd, w.WM_DESTROY, 0, 0 );
mov( 0, key );
elseif( uMsg = w.WM_KEYDOWN ) then
w.KillTimer( hWnd, 500 );
w.SendMessage( hWnd, w.WM_DESTROY, 0, 0 );
mov( 1, key );
else
w.DefWindowProc( hWnd, uMsg, wParam, lParam );
endif;
end WndProc;
procedure QuickGet( window:dword );
var
msg: w.MSG;
begin QuickGet;
forever
w.GetMessage( msg, NULL, 0, 0 );
breakif( !eax );
w.TranslateMessage( msg );
w.DispatchMessage( msg );
endfor;
mov( msg.wParam, eax );
end QuickGet;
begin TimeGetc;
w.GetModuleHandle( NULL );
mov( eax, hInstance );
mov( @size( w.WNDCLASSEX ), wc.cbSize );
mov( w.CS_HREDRAW | w.CS_VREDRAW, wc.style );
mov( &WndProc, wc.lpfnWndProc );
mov( 0, wc.cbClsExtra );
mov( 0, wc.cbWndExtra );
mov( hInstance, wc.hInstance );
mov( w.COLOR_WINDOW+1, wc.hbrBackground );
mov( NULL, wc.lpszMenuName );
mov( ClassName, wc.lpszClassName );
w.LoadIcon( NULL, val w.IDI_APPLICATION );
mov( eax, wc.hIcon );
mov( eax, wc.hIconSm );
w.LoadCursor( NULL, val w.IDC_ARROW );
mov( eax, wc.hCursor );
w.RegisterClassEx( wc );
w.CreateWindowEx
(
0,
ClassName,
AppName,
w.WS_OVERLAPPED,
200,
200,
200,
200,
0,
0,
hInstance,
NULL
);
mov( eax, hwnd );
w.ShowWindow( hwnd, w.SW_SHOWDEFAULT );
w.UpdateWindow( hwnd );
// Ask the user to press a key within 3 seconds.
QuickGet( hwnd );
mov( key, eax );
if ( eax == 1 ) then
stdout.put( "A key was pressed!", nl );
else
stdout.put( "The event timed out!", nl );
endif;
// Give the user a second chance to press a key.
w.ShowWindow( hwnd, w.SW_SHOWDEFAULT );
w.UpdateWindow( hwnd );
w.SendMessage( hwnd, w.WM_CREATE, 0, 0 );
QuickGet( hwnd );
mov( key, eax );
if ( eax == 1 ) then
stdout.put( "A key was pressed!", nl );
else
stdout.put( "The event timed out!", nl );
endif;
end TimeGetc;
Nathan.
.
- References:
- Win32 non blocking console input?
- From: Herbert Kleebauer
- Re: Win32 non blocking console input?
- From: NathanCBaker
- Re: Win32 non blocking console input?
- From: Herbert Kleebauer
- Re: Win32 non blocking console input?
- From: NathanCBaker
- Re: Win32 non blocking console input?
- From: Herbert Kleebauer
- Win32 non blocking console input?
- Prev by Date: Re: Win32 non blocking console input?
- Next by Date: Re: Banks and economy
- Previous by thread: Re: Win32 non blocking console input?
- Next by thread: Re: Win32 non blocking console input?
- Index(es):
Relevant Pages
|
Loading