+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+ }
+}
+
+// ============================================================================
+// implementation of IO redirection support classes
+// ============================================================================
+
+#if wxUSE_STREAMS
+
+// ----------------------------------------------------------------------------
+// wxPipeInputStreams
+// ----------------------------------------------------------------------------
+
+wxPipeInputStream::wxPipeInputStream(HANDLE hInput)
+{
+ m_hInput = hInput;
+}
+
+wxPipeInputStream::~wxPipeInputStream()
+{
+ if ( m_hInput != INVALID_HANDLE_VALUE )
+ ::CloseHandle(m_hInput);
+}
+
+bool wxPipeInputStream::CanRead() const
+{
+ if ( !IsOpened() )
+ return FALSE;
+
+ DWORD nAvailable;
+
+ // function name is misleading, it works with anon pipes as well
+ DWORD rc = ::PeekNamedPipe
+ (
+ m_hInput, // handle
+ NULL, 0, // ptr to buffer and its size
+ NULL, // [out] bytes read
+ &nAvailable, // [out] bytes available
+ NULL // [out] bytes left
+ );
+
+ if ( !rc )
+ {
+ if ( ::GetLastError() != ERROR_BROKEN_PIPE )
+ {
+ // unexpected error
+ wxLogLastError(_T("PeekNamedPipe"));
+ }
+
+ // don't try to continue reading from a pipe if an error occured or if
+ // it had been closed
+ ::CloseHandle(m_hInput);
+
+ wxPipeInputStream *self = wxConstCast(this, wxPipeInputStream);
+
+ self->m_hInput = INVALID_HANDLE_VALUE;
+ self->m_lasterror = wxSTREAM_EOF;
+
+ nAvailable = 0;