📄 perform.cpp
字号:
/*____________________________________________________________________________*\
*
Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*____________________________________________________________________________*|
*
* $Source: /cvsroot/pi3web/Pi3Web_200/Source/EnhPi3/Perform.cpp,v $
* $Date: 2003/05/13 18:41:58 $
*
Description:
\*____________________________________________________________________________*/
/* $SourceTop:$ */
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <assert.h>
#include "resrc1.h"
#include "Dialogs.h"
#include "Config.h"
/*____________________________________________________________________________*\
*
Description:
Definitions and global values
\*____________________________________________________________________________*/
static HWND hWndThreads = 0;
static HWND hWndRecv = 0;
static HWND hWndSend = 0;
static HWND hWndKeepOpen = 0;
static HWND hWndReverse = 0;
static HWND hWndAliveCount = 0;
static HWND hWndAliveTimeout = 0;
static HWND hWndDebug = 0;
static HWND hWndErrorLog = 0;
static HWND hWndExitAfter = 0;
static HWND hWndProcs = 0;
static HWND hWndReuse = 0;
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
static BOOL CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
hWndThreads = GetDlgItem( hDlg, IDC_THREADS );
hWndRecv = GetDlgItem( hDlg, IDC_RECV );
hWndSend = GetDlgItem( hDlg, IDC_SEND );
hWndKeepOpen = GetDlgItem( hDlg, IDC_KEEPALIVE );
hWndAliveCount = GetDlgItem( hDlg, IDC_ALIVECOUNT );
hWndAliveTimeout = GetDlgItem( hDlg, IDC_ALIVETIMEOUT );
hWndReverse = GetDlgItem( hDlg, IDC_REVERSE );
hWndDebug = GetDlgItem( hDlg, IDC_DEBUG );
hWndProcs = GetDlgItem( hDlg, IDC_PROCS );
hWndErrorLog = GetDlgItem( hDlg, IDC_ERRORLOG );
hWndExitAfter = GetDlgItem( hDlg, IDC_EXITAFTER );
hWndReuse = GetDlgItem( hDlg, IDC_REUSE );
assert( hWndThreads );
assert( hWndRecv && hWndSend );
assert( hWndKeepOpen && hWndReverse );
assert( hWndAliveCount && hWndAliveTimeout );
assert( hWndDebug && hWndProcs );
assert( hWndErrorLog && hWndExitAfter && hWndReuse );
/* --- just for sanity --- */
::SendMessage( hWndThreads, EM_SETLIMITTEXT, 256, 0 );
::SendMessage( hWndRecv, EM_SETLIMITTEXT, 256, 0 );
::SendMessage( hWndSend, EM_SETLIMITTEXT, 256, 0 );
::SendMessage( hWndProcs, EM_SETLIMITTEXT, 256, 0 );
::SendMessage( hWndExitAfter, EM_SETLIMITTEXT, 256, 0 );
::SendMessage( hWndThreads, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "Threads" ));
::SendMessage( hWndRecv, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "RecvTimeout" ));
::SendMessage( hWndSend, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "SendTimeout" ));
::SendMessage( hWndProcs, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "Processes" ));
::SendMessage( hWndExitAfter, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "ExitAfter" ));
if ( !stricmp( AD_lookupValue( __pConfig, "General", "KeepOpen" ), "On" ))
{ ::SendMessage( hWndKeepOpen, BM_SETCHECK, BST_CHECKED, 0 ); }
else
{
::SendMessage( hWndKeepOpen, BM_SETCHECK, BST_UNCHECKED, 0 );
::EnableWindow( hWndAliveCount, FALSE );
::EnableWindow( hWndAliveTimeout, FALSE );
};
::SendMessage( hWndAliveCount, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "KeepOpenCount" ));
::SendMessage( hWndAliveTimeout, WM_SETTEXT, 0,
(LPARAM)AD_lookupValue( __pConfig, "General", "KeepOpenTimeout" ));
if ( *AD_lookupValue( __pConfig, "General", "DNSReverseLookup" ))
{ ::SendMessage( hWndReverse, BM_SETCHECK, BST_CHECKED, 0 ); }
else
{ ::SendMessage( hWndReverse, BM_SETCHECK, BST_UNCHECKED, 0 ); };
if ( *AD_lookupValue( __pConfig, "General", "Debug" ))
{ ::SendMessage( hWndDebug, BM_SETCHECK, BST_CHECKED, 0 ); }
else
{ ::SendMessage( hWndDebug, BM_SETCHECK, BST_UNCHECKED, 0 ); };
if ( *AD_lookupValue( __pConfig, "General", "ErrorLog" ))
{ ::SendMessage( hWndErrorLog, BM_SETCHECK, BST_CHECKED, 0 ); }
else
{ ::SendMessage( hWndErrorLog, BM_SETCHECK, BST_UNCHECKED, 0 ); };
if ( *AD_lookupValue( __pConfig, "General", "ReuseThreads" ))
{ ::SendMessage( hWndReuse, BM_SETCHECK, BST_CHECKED, 0 ); }
else
{ ::SendMessage( hWndReuse, BM_SETCHECK, BST_UNCHECKED, 0 ); };
AD_UnChanged( hDlg );
}
break;
case WM_COMMAND:
if ( GET_WM_COMMAND_CMD(wParam, lParam)==EN_CHANGE
|| GET_WM_COMMAND_CMD(wParam, lParam)==BN_CLICKED )
{
switch( GET_WM_COMMAND_ID( wParam, lParam) )
{
case IDC_KEEPALIVE:
if ( ::SendMessage( hWndKeepOpen, BM_GETCHECK, 0, 0 )==BST_CHECKED )
{
::EnableWindow( hWndAliveCount, TRUE );
::EnableWindow( hWndAliveTimeout, TRUE );
}
else
{
::EnableWindow( hWndAliveCount, FALSE );
::EnableWindow( hWndAliveTimeout, FALSE );
};
break;
default:;
}
AD_Changed( hDlg );
}
break;
case WM_NOTIFY:
switch( ((NMHDR *)lParam)->code )
{
case PSN_QUERYCANCEL:
return AD_cancel( hDlg );
case PSN_KILLACTIVE:
if ( AD_IsChanged() )
{
enum { BUF_SIZE=1023 };
char szBuf[BUF_SIZE+1];
/*
** Threads
*/
*szBuf = 0;
SendMessage( hWndThreads, WM_GETTEXT, BUF_SIZE, (LPARAM)szBuf );
int iTest = atoi( szBuf );
if ( iTest<1 || iTest>512 )
{
/*
** Give message and abort change
*/
MessageBox( hDlg, "Threads must be in the range [1..512]",
"Configuration Error", MB_OK );
SetFocus( hWndThreads );
SendMessage( hWndThreads, EM_SETSEL, 0, -1 );
SetWindowLong( hDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE );
return (TRUE);
};
AD_replaceValue( __pConfig, "General", "Threads", szBuf );
/*
** Receive Timeout
*/
*szBuf = 0;
::SendMessage( hWndRecv, WM_GETTEXT, BUF_SIZE, (LPARAM)szBuf );
int iLen = strlen(szBuf);
for( iTest=0; iTest<iLen; iTest++)
{
if ( isalpha( szBuf[iTest] ) )
{
/*
** Give message and abort change
*/
MessageBox( hDlg, "Field contains alphanumeric characters.",
"Configuration Error", MB_OK | MB_ICONEXCLAMATION );
SetFocus( hWndRecv );
SendMessage( hWndRecv, EM_SETSEL, 0, -1 );
SetWindowLong( hDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE );
return (TRUE);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -