📄 logfile.cpp
字号:
*pszBuf = '\0';
pszBuf[iBufSize] = '\0';
/*
** safety only
*/
if ( ::SendMessage( hWndList, LB_GETTEXTLEN, 0, 0 ) >= iBufSize )
{
::MessageBox( hDlg, "Logging specification too long",
"Internal Error", MB_OK );
break;
};
::SendMessage( hWndList, LB_GETTEXT, i, (LPARAM)pszBuf );
M_AddValue( pConfig, "Logfiles", "Logging", pszBuf );
};
::SetWindowLong( hDlg, DWL_MSGRESULT, FALSE );
return (TRUE);
};
int Win32Create( Interface &tWindow )
{
/* --- property sheet pages should not be created --- */
return PIAPI_ABORT;
};
BOOL DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
enum { BUF_SIZE=1023 };
char szBuf[BUF_SIZE+1];
int aTabstop[2];
switch (uMsg)
{
case WM_INITDIALOG:
HourglassOn();
{
const char *pTmp;
int iTmp;
hWndList = GetDlgItem( hDlg, IDC_LIST );
hWndType = GetDlgItem( hDlg, IDC_TYPE );
hWndPath= GetDlgItem( hDlg, IDC_PATH );
hWndAdd = GetDlgItem( hDlg, IDC_ADD );
hWndReplace = GetDlgItem( hDlg, IDC_REPLACE );
hWndDelete= GetDlgItem( hDlg, IDC_DELETE );
assert( hWndList && hWndType && hWndPath );
assert( hWndAdd && hWndReplace && hWndDelete );
::EnableWindow( hWndAdd, FALSE );
::EnableWindow( hWndReplace, FALSE );
::EnableWindow( hWndDelete, FALSE );
/*
** Load all logging types.
*/
iTmp = 0;
for(;; iTmp++ )
{
pTmp = M_LookupValueEx( pConfig, "Internal",
"LoggingTypes", iTmp );
if ( !pTmp )
{ break; };
::SendMessage( hWndType, CB_ADDSTRING, 0, (LPARAM)pTmp );
};
/*
** Limit edit field lengths, really just a sanity thing
*/
::SendMessage( hWndPath, EM_SETLIMITTEXT, 256, 0 );
/*
** Setup tabstops
*/
aTabstop[0] = 0;
aTabstop[1] = 75;
::SendMessage( hWndList, LB_SETTABSTOPS, 2, (LPARAM)&aTabstop );
/*
** Load all logfiles
*/
iTmp = 0;
for(;; iTmp++ )
{
pTmp = M_LookupValueEx( pConfig, "Logfiles",
"Logging", iTmp );
if ( !pTmp )
{ break; };
if ( ::SendMessage( hWndList, LB_ADDSTRING, 0,
(LPARAM)pTmp )>=0 )
{
Internal_addLine( pTmp );
}
else
{ break; /* error */; };
};
}
HourglassOff();
break;
case WM_DESTROY:
{
int i;
int iCount = ::SendMessage( hWndList, LB_GETCOUNT, 0, 0 );
/* --- remove old ones first --- */
DblListIterator x( lTypes );
DblListIterator y( lPaths );
for( i=0; i<iCount; i++, x++, y++ )
{
/*
** Delete this entry in lists
*/
assert( !x.BadIndex() && !y.BadIndex() );
PI_DELETE( (PIString *)x.Current() );
PI_DELETE( (PIString *)y.Current() );
};
lTypes.Clear();
lPaths.Clear();
};
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDC_ADD:
{
int i;
*szBuf = '\0';
::SendMessage( hWndType, WM_GETTEXT, BUF_SIZE,
(LPARAM)szBuf );
for( i=0; i<BUF_SIZE && szBuf[i] && szBuf[i]!='\t';
i++ );
if ( szBuf[i] ) { szBuf[i] = '\0'; };
lTypes.Append( (DblList::type)PI_NEW( PIString( szBuf )
) );
szBuf[i++] = '\t';
::SendMessage( hWndPath, WM_GETTEXT, BUF_SIZE-i,
(LPARAM)&(szBuf[i]) );
lPaths.Append( (DblList::type)PI_NEW( PIString(
&(szBuf[i]) ) ) );
::SendMessage( hWndList, LB_ADDSTRING,0,(LPARAM)szBuf );
/*
** Clear edit fields, focus to list
*/
::SendMessage( hWndType, CB_SETCURSEL, (WPARAM)-1, 0 );
::SendMessage( hWndPath, WM_SETTEXT, 0, (LPARAM)"" );
::SetFocus( hWndList );
Changed( hDlg );
};
break;
case IDC_REPLACE:
{
/*
** Get selected item index
*/
int iCurSel = ::SendMessage(hWndList, LB_GETCURSEL,0,0);
/*
** Get text to add and add it to internal lists only
*/
int i;
*szBuf = '\0';
::SendMessage( hWndType, WM_GETTEXT, BUF_SIZE,
(LPARAM)szBuf );
for( i=0;i<BUF_SIZE && szBuf[i] && szBuf[i]!='\t';i++);
if ( szBuf[i] ) { szBuf[i] = '\0'; };
lTypes.Append( (DblList::type)PI_NEW(PIString(szBuf)));
szBuf[i++] = '\t';
::SendMessage( hWndPath, WM_GETTEXT, BUF_SIZE-i,
(LPARAM)&(szBuf[i]) );
lPaths.Append( (DblList::type)PI_NEW( PIString(
&(szBuf[i]) ) ) );
/*
** Delete the item from the list and internal lists
*/
::SendMessage( hWndList, LB_DELETESTRING, iCurSel, 0 );
PI_DELETE( (PIString *)lTypes.Detach( iCurSel) );
PI_DELETE( (PIString *)lPaths.Detach( iCurSel) );
/*
** Add new item to listbox
*/
::SendMessage( hWndList, LB_ADDSTRING,0,(LPARAM)szBuf);
/*
** Clear edit fields, focus to list
*/
::SendMessage( hWndType, CB_SETCURSEL, (WPARAM)-1, 0 );
::SendMessage( hWndPath, WM_SETTEXT, 0, (LPARAM)"" );
::SetFocus( hWndList );
Changed( hDlg );
};
break;
case IDC_PATH:
if ( GET_WM_COMMAND_CMD(wParam, lParam)==EN_CHANGE )
{ Internal_updateButtons( wParam, lParam ); };
break;
case IDC_DELETE:
{
int iCurSel = ::SendMessage( hWndList,LB_GETCURSEL,0,0);
::SendMessage(hWndList,LB_DELETESTRING,iCurSel,0 );
PI_DELETE( (PIString *)lTypes.Detach( iCurSel) );
PI_DELETE( (PIString *)lPaths.Detach( iCurSel) );
/*
** Clear edit fields, focus to list
*/
::SendMessage( hWndType, CB_SETCURSEL, (WPARAM)-1, 0 );
::SendMessage( hWndPath, WM_SETTEXT, 0, (LPARAM)"" );
::SetFocus( hWndList );
Changed( hDlg );
};
break;
case IDC_TYPE:
if ( GET_WM_COMMAND_CMD(wParam, lParam)==CBN_SELCHANGE )
{
::SendMessage( hWndList,LB_SETCURSEL,(WPARAM)-1,0);
Internal_updateButtons( wParam, lParam );
};
break;
case IDC_LIST:
if ( GET_WM_COMMAND_CMD(wParam, lParam)==LBN_SELCHANGE )
{
int iSel = SendMessage( hWndList,
LB_GETCURSEL, 0, 0 );
if ( iSel!=LB_ERR )
{
assert( iSel>=0 && iSel<lTypes.Size() );
::EnableWindow( hWndDelete, TRUE );
int iIndex = ::SendMessage( hWndType,
CB_FINDSTRINGEXACT,
(WPARAM)-1, (LPARAM)(const char *)
*((PIString *)lTypes[iSel]) );
::SendMessage( hWndType, CB_SETCURSEL, (WPARAM)
(iIndex==CB_ERR ? -1 : iIndex), 0 );
::SendMessage( hWndPath, WM_SETTEXT, 0,
(LPARAM)(const char *)*
((PIString *)lPaths[iSel]) );
};
};
break;
default:;
}
break;
case WM_NOTIFY:
switch( ((NMHDR *)lParam)->code )
{
case PSN_QUERYCANCEL:
return SHEET->Cancel( pInterface, hDlg );
case PSN_KILLACTIVE:
return Internal_save( hDlg, szBuf, BUF_SIZE );
default:
return (FALSE);
};
break;
default:
return (FALSE);
};
return (TRUE);
};
};
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
static BOOL CALLBACK fnDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
if ( uMsg==WM_INITDIALOG )
{
::SetWindowLong( hDlg, DWL_USER, ((LPPROPSHEETPAGE)lParam)->lParam );
};
LogFilePage *pPage = (LogFilePage *)::GetWindowLong( hDlg, DWL_USER );
return pPage ? pPage->DialogProc( hDlg, uMsg, wParam, lParam ) : FALSE;
}
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int LogFilePage_constructor( PIObject *pObj,
int iArgc, const char *ppArgv[] )
{
return IFaceBase_constructor( pObj, PI_NEW( LogFilePage( pObj,
iArgc, ppArgv ) ) );
}
#if 0
/*___+++CNF_BEGIN+++___*/
<Class>
Name LogFilePageClass
Type LogicExtension
Library IntrFace
OnClassLoad IFaceBase_onClassLoad
Constructor LogFilePage_constructor
CopyConstructor IFaceBase_copyConstructor
Destructor IFaceBase_destructor
Execute IFaceBase_execute
</Class>
<Object>
Name LogFilePage
Class LogFilePageClass
</Object>
/*___+++CNF_END+++___*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -