⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dirindex.cpp

📁 mini http server,可以集成嵌入到程序中,实现简单的web功能
💻 CPP
📖 第 1 页 / 共 2 页
字号:
					{ ::SendMessage( hWndTag, WM_SETTEXT, 0, (LPARAM)"10" ); }
	
				if ( ::SendMessage( hWndTruncate, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
					{ ::SendMessage( hWndTruncate, WM_SETTEXT, 0, (LPARAM)"20" ); }
	
				// Axiliary Files
				::SendMessage( hWndHeader,BM_SETCHECK, TRUE, 0 );
				::SendMessage( hWndFooter,BM_SETCHECK, TRUE, 0 );
				::SendMessage( hWndDescription, BM_SETCHECK, TRUE, 0 );
	
				// SizeFormat
				SendMessage( GetDlgItem( hDlg, IDC_DECIMAL ), BM_SETCHECK, BST_UNCHECKED, 0 );
				SendMessage( GetDlgItem( hDlg, IDC_ABBREV ), BM_SETCHECK, BST_CHECKED, 0 );
				SendMessage( GetDlgItem( hDlg, IDC_FORMAT ), BM_SETCHECK, BST_UNCHECKED, 0 );
				break;
	
			/*
			** DOS style HTML index
			*/
			case 4:
				// Column 'Type' = index 0
				::SendMessage( hWndColumns, LB_SETSEL, FALSE, 0 );
	
				// Column 'Name' = index 1
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 1 );
	
				// Column 'AltName' = index 2
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 2 );
	
				// Column 'Size' = index 3
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 3 );
	
				// Column 'Date' = index 4
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 4 );
	
				// Column 'Description' = index 5
				::SendMessage( hWndColumns, LB_SETSEL, FALSE, 5 );
	
				// SortColumn '(none)' = index 0
				::SendMessage( hWndSortCol, CB_SETCURSEL, 0, 0 );
	
				// Sort Flags
				::SendMessage( hWndHyperlink, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndICase, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndDescending, BM_SETCHECK, FALSE, 0 );
	
				// Options
				::SendMessage( hWndTag, WM_SETTEXT, 0, (LPARAM)"" );
				::SendMessage( hWndTruncate, WM_SETTEXT, 0, (LPARAM)"" );
	
				// Axiliary Files
				::SendMessage( hWndHeader, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndFooter, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndDescription, BM_SETCHECK, FALSE, 0 );
	
				// SizeFormat
				SendMessage( GetDlgItem( hDlg, IDC_DECIMAL ), BM_SETCHECK, BST_UNCHECKED, 0 );
				SendMessage( GetDlgItem( hDlg, IDC_ABBREV ), BM_SETCHECK, BST_UNCHECKED, 0 );
				SendMessage( GetDlgItem( hDlg, IDC_FORMAT ), BM_SETCHECK, BST_CHECKED, 0 );
				break;
	
			/*
			** 'Text with Tabs' index
			*/
			case 5:
				// Column 'Type' = index 0
				::SendMessage( hWndColumns, LB_SETSEL, FALSE, 0 );
	
				// Column 'Name' = index 1
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 1 );
	
				// Column 'AltName' = index 2
				::SendMessage( hWndColumns, LB_SETSEL, FALSE, 2 );
	
				// Column 'Size' = index 3
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 3 );
	
				// Column 'Date' = index 4
				::SendMessage( hWndColumns, LB_SETSEL, TRUE, 4 );
	
				// Column 'Description' = index 5
				::SendMessage( hWndColumns,LB_SETSEL, TRUE, 5 );
	
				// SortColumn '(none)' = index 0
				::SendMessage( hWndSortCol, CB_SETCURSEL, 0, 0 );
	
				// Sort Flags
				::SendMessage( hWndHyperlink, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndICase, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndDescending, BM_SETCHECK, FALSE, 0 );
	
				// Options
				::SendMessage( hWndTag, WM_SETTEXT, 0, (LPARAM)"" );
				::SendMessage( hWndTruncate, WM_SETTEXT, 0, (LPARAM)"" );
	
				// Axiliary Files
				::SendMessage( hWndHeader, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndFooter, BM_SETCHECK, FALSE, 0 );
				::SendMessage( hWndDescription, BM_SETCHECK, FALSE, 0 );
	
				// SizeFormat
				SendMessage( GetDlgItem( hDlg, IDC_DECIMAL ), BM_SETCHECK, BST_CHECKED, 0 );
				SendMessage( GetDlgItem( hDlg, IDC_ABBREV ), BM_SETCHECK, BST_UNCHECKED, 0 );
				SendMessage( GetDlgItem( hDlg, IDC_FORMAT ), BM_SETCHECK, BST_UNCHECKED, 0 );
				break;
	
			/*
			** Custom index, this isn't handled here
			*/
			case 6:
				EnableWindow( hWndSortCol, FALSE );
				EnableWindow( hWndColumns, FALSE );
				EnableWindow( hWndHyperlink, FALSE );
				EnableWindow( hWndICase, FALSE );
				EnableWindow( hWndDescending, FALSE );
				EnableWindow( hWndTag, FALSE );
				EnableWindow( hWndTruncate, FALSE );
				EnableWindow( hWndHeader, FALSE );
				EnableWindow( hWndFooter, FALSE );
				EnableWindow( hWndDescription, FALSE );
				EnableWindow( GetDlgItem( hDlg, IDC_DECIMAL ), FALSE );
				EnableWindow( GetDlgItem( hDlg, IDC_ABBREV ), FALSE );
				EnableWindow( GetDlgItem( hDlg, IDC_FORMAT ), FALSE );
				break;
	
			default:
				assert(0);
			}
		__iCurrentLayout = iNewLayout;
		Internal_ColumnsChanged( hDlg );
		Internal_SortColumnChanged( hDlg );
	}

	BOOL DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
	    {
	    enum { BUF_SIZE=1023 };
	    char szBuf[BUF_SIZE+1];

		switch (uMsg)
			{
			case WM_INITDIALOG:
				{
				const char *pA = M_LookupValue( pConfig, "General", "Admin" );
				hWndColumns = GetDlgItem( hDlg, IDC_COLUMNS );
				hWndSortCol = GetDlgItem( hDlg, IDC_SORTCOL );
				hWndHyperlink = GetDlgItem( hDlg, IDC_HLINK );
				hWndICase = GetDlgItem( hDlg, IDC_ICASE );
				hWndDescending = GetDlgItem( hDlg, IDC_DESCEND );
				hWndTag = GetDlgItem( hDlg, IDC_TAG );
				hWndTruncate = GetDlgItem( hDlg, IDC_TRUNCATE );
				hWndHeader = GetDlgItem( hDlg, IDC_HEAD );
				hWndFooter = GetDlgItem( hDlg, IDC_FOOT );
				hWndDescription = GetDlgItem( hDlg, IDC_DESCR );
	
				assert( hWndColumns );
				assert( hWndSortCol && hWndHyperlink );
				assert( hWndICase && hWndDescending );
				assert( hWndTag && hWndTruncate );
				assert( hWndHeader && hWndFooter && hWndDescription );
				assert( pA );
	
				/* --- just for sanity --- */
				::SendMessage( hWndTag, EM_SETLIMITTEXT, 256, 0 );
				::SendMessage( hWndTruncate, EM_SETLIMITTEXT, 256, 0 );
	
				/* --- Layout --- */
				switch (atoi(M_LookupValue(pConfig,"DirIndex","Layout")))
					{
					case 1:
						SET_LAYOUT( 1 ); break;
					case 2:
						SET_LAYOUT( 2 ); break;
					case 3:
						SET_LAYOUT( 3 ); break;
					case 4:
						SET_LAYOUT( 4 ); break;
					case 5:
						SET_LAYOUT( 5 ); break;
					case 6:
						SET_LAYOUT( 6 );
						EnableWindow( hWndSortCol, FALSE );
						EnableWindow( hWndColumns, FALSE );
						EnableWindow( hWndHyperlink, FALSE );
						EnableWindow( hWndICase, FALSE );
						EnableWindow( hWndDescending, FALSE );
						EnableWindow( hWndTag, FALSE );
						EnableWindow( hWndTruncate, FALSE );
						EnableWindow( hWndHeader, FALSE );
						EnableWindow( hWndFooter, FALSE );
						EnableWindow( hWndDescription, FALSE );
						EnableWindow( GetDlgItem( hDlg, IDC_DECIMAL ), FALSE );
						EnableWindow( GetDlgItem( hDlg, IDC_ABBREV ), FALSE );
						EnableWindow( GetDlgItem( hDlg, IDC_FORMAT ), FALSE );
						break;
					default:
						return (FALSE);
					}
	
				/* --- Columns --- */
				::SendMessage( hWndColumns, LB_ADDSTRING, 0, (LPARAM)"Type" );
				::SendMessage( hWndColumns, LB_ADDSTRING, 0, (LPARAM)"Name" );
				::SendMessage( hWndColumns, LB_ADDSTRING, 0, (LPARAM)"AltName" );
				::SendMessage( hWndColumns, LB_ADDSTRING, 0, (LPARAM)"Size" );
				::SendMessage( hWndColumns, LB_ADDSTRING, 0, (LPARAM)"Date" );
				::SendMessage( hWndColumns, LB_ADDSTRING, 0, (LPARAM)"Description" );
	
				int iColumns = atoi( M_LookupValue( pConfig, "DirIndex", "Columns" ));
				int i = 0;
				for (;i<COLUMNCOUNT;i++) {
					if ( iColumns & (1 << i) )
						{ ::SendMessage( hWndColumns, LB_SETSEL, TRUE, i ); };
					}
				Internal_ColumnsChanged( hDlg );
	
				/* --- Sort-Column --- */
				::SendMessage( hWndSortCol, CB_ADDSTRING, 0, (LPARAM)"(none)" );
				::SendMessage( hWndSortCol, CB_ADDSTRING, 0, (LPARAM)"Type" );
				::SendMessage( hWndSortCol, CB_ADDSTRING, 0, (LPARAM)"Name" );
				::SendMessage( hWndSortCol, CB_ADDSTRING, 0, (LPARAM)"Size" );
				::SendMessage( hWndSortCol, CB_ADDSTRING, 0, (LPARAM)"Date" );
				::SendMessage( hWndSortCol, CB_ADDSTRING, 0, (LPARAM)"Description" );
	
				const char *pVal = M_LookupValue( pConfig, "DirIndex", "SortColumn" );
				if ( ::SendMessage(hWndSortCol,CB_SELECTSTRING,0,(LPARAM)pVal)==CB_ERR )
					{ ::SendMessage( hWndSortCol, CB_SETCURSEL, 0, 0 ); };
	
				Internal_SortColumnChanged( hDlg );
	
				/* --- Sorting-Flags --- */
				i = atoi(M_LookupValue( pConfig, "DirIndex", "SortFlags" ));
				::SendMessage( hWndHyperlink, BM_SETCHECK, (WPARAM)(i & 1), 0 );
				::SendMessage( hWndICase, BM_SETCHECK, (WPARAM)(i & 2), 0 );
				::SendMessage( hWndDescending, BM_SETCHECK, (WPARAM)(i & 4), 0 );
	
				/* --- Options --- */
				pVal = M_LookupValue( pConfig, "DirIndex", "TagNew" );
				::SendMessage( hWndTag, WM_SETTEXT, 0, (LPARAM)pVal );
				pVal = M_LookupValue( pConfig, "DirIndex", "Truncate" );
				::SendMessage( hWndTruncate, WM_SETTEXT, 0, (LPARAM)pVal );
	
				/* --- File Flags --- */
				i = atoi(M_LookupValue( pConfig, "DirIndex", "FileFlags" ));
				::SendMessage( hWndHeader, BM_SETCHECK, (WPARAM)(i & 1), 0 );
				::SendMessage( hWndFooter, BM_SETCHECK, (WPARAM)(i & 2), 0 );
				::SendMessage( hWndDescription, BM_SETCHECK, (WPARAM)(i & 4), 0 );
	
				/* --- Size-Format --- */
				pVal = M_LookupValue( pConfig, "DirIndex", "SizeFormat" );
				if ( pVal && !strcmp( pVal, FMT_DECIMAL ))
					{ SET_FORMAT( DECIMAL ); }
				else if ( pVal && !strcmp( pVal, FMT_ABBREV ))
					{ SET_FORMAT( ABBREV ); }
				else if ( pVal && !strcmp( pVal, FMT_FORMAT ))
					{ SET_FORMAT( FORMAT ); }
				else
					{ return (FALSE); }
	
				Unchanged( hDlg );
				};
				break;
	
			case WM_COMMAND:
				if ( GET_WM_COMMAND_CMD(wParam, lParam)==BN_CLICKED )
					{
					switch( GET_WM_COMMAND_ID( wParam, lParam) )
						{
						case IDC_INDEX1:
							Internal_LayoutChanged( hDlg, 1 ); break;
						case IDC_INDEX2:
							Internal_LayoutChanged( hDlg, 2 ); break;
						case IDC_INDEX3:
							Internal_LayoutChanged( hDlg, 3 ); break;
						case IDC_INDEX4:
							Internal_LayoutChanged( hDlg, 4 ); break;
						case IDC_INDEX5:
							Internal_LayoutChanged( hDlg, 5 ); break;
						case IDC_INDEX6:
							Internal_LayoutChanged( hDlg, 6 ); break;
						case IDC_DECIMAL:
							__pCurrentSizeFmt = FMT_DECIMAL; break;
						case IDC_ABBREV:
							__pCurrentSizeFmt = FMT_ABBREV; break;
						case IDC_FORMAT:
							__pCurrentSizeFmt = FMT_FORMAT; break;
						default:;
						};
					/* --- mark property sheet as modified --- */
					Changed( hDlg );
					}
				if ( GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE )
					{
					if ( GET_WM_COMMAND_ID( wParam, lParam) == IDC_SORTCOL )
						{
						Internal_SortColumnChanged( hDlg );
						/* --- mark property sheet as modified --- */
						Changed( hDlg );
						}
					}
				if ( GET_WM_COMMAND_CMD(wParam, lParam) == LBN_SELCHANGE )
					{
					if ( GET_WM_COMMAND_ID( wParam, lParam) == IDC_COLUMNS )
						{
						Internal_ColumnsChanged( hDlg );
						/* --- mark property sheet as modified --- */
						Changed( hDlg );
						}
					}
				if ( GET_WM_COMMAND_CMD(wParam, lParam)==EN_CHANGE )
					{
					/* --- mark property sheet as modified --- */
					Changed( hDlg );
					}
				break;
	
			case WM_DESTROY:
				break;
	
			case WM_NOTIFY:
				switch( ((NMHDR *)lParam)->code )
					{
					case PSN_QUERYCANCEL:
						return SHEET->Cancel(pInterface, hDlg);
					
					case PSN_KILLACTIVE:
						{
						/* --- Layout --- */
						M_ReplaceValue( pConfig, "DirIndex", "Layout",
							itoa( __iCurrentLayout, szBuf, 10 ));
	
						/* --- Columns --- */
						int iColumns = 0;
						int iItems[COLUMNCOUNT];
						ZeroMemory( &iItems, sizeof(iItems) );
						int i = ::SendMessage( hWndColumns, LB_GETSELITEMS,
							COLUMNCOUNT, (LPARAM)&iItems );
	
						for (;i>0;i--)
							{ iColumns += 1 << iItems[i-1]; }
						M_ReplaceValue( pConfig, "DirIndex", "Columns",
							itoa( iColumns,szBuf,10 ));	
	
						/* --- Sort-Column --- */
						*szBuf = 0;
						int iIdx = ::SendMessage( hWndSortCol,	CB_GETCURSEL, 0, 0 );
						::SendMessage( hWndSortCol, CB_GETLBTEXT, iIdx , (LPARAM)&szBuf );
						if ( szBuf && !strcmp(szBuf, "(none)" )) { *szBuf = 0; };
						M_ReplaceValue( pConfig, "DirIndex", "SortColumn", szBuf );
	
						/* --- Sorting-Flags --- */
						iIdx = 0;
						if ( ::SendMessage( hWndHyperlink, BM_GETCHECK, 0, 0 ))
							{ iIdx += 1; };
						if ( ::SendMessage( hWndICase, BM_GETCHECK, 0, 0 ))
							{ iIdx += 2; };
						if ( ::SendMessage( hWndDescending, BM_GETCHECK, 0, 0 ))
							{ iIdx += 4; };
						M_ReplaceValue( pConfig, "DirIndex", "SortFlags",
							itoa( iIdx,szBuf,10 ));
	
						/* --- Options --- */
						*szBuf = 0;
						::SendMessage( hWndTag, WM_GETTEXT, BUF_SIZE, (LPARAM)szBuf );
						M_ReplaceValue( pConfig, "DirIndex", "TagNew", szBuf );
						*szBuf = 0;
						::SendMessage( hWndTruncate, WM_GETTEXT, BUF_SIZE, (LPARAM)szBuf );
						M_ReplaceValue( pConfig, "DirIndex", "Truncate", szBuf );
	
						/* --- Size-Format --- */
						M_ReplaceValue( pConfig, "DirIndex", "SizeFormat", __pCurrentSizeFmt );
	
						/* --- File Flags --- */
						iIdx = 0;
						if ( ::SendMessage( hWndHeader, BM_GETCHECK, 0, 0 ))
							{ iIdx += 1; };
						if ( ::SendMessage( hWndFooter, BM_GETCHECK, 0, 0 ))
							{ iIdx += 2; };
						if ( ::SendMessage( hWndDescription, BM_GETCHECK, 0, 0 ))
							{ iIdx += 4; };
						M_ReplaceValue( pConfig, "DirIndex", "FileFlags",
							itoa( iIdx,szBuf,10 ));
	
						SetWindowLong( hDlg, DWL_MSGRESULT, FALSE );
						return (TRUE);
						}
	
					case PSN_APPLY:
						return SHEET->SaveConfig(pInterface, hDlg);

					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 );
        };

    DirIndexPage *pPage = (DirIndexPage *)::GetWindowLong( hDlg, DWL_USER );
    return pPage ? pPage->DialogProc( hDlg, uMsg, wParam, lParam ) : FALSE;
}

/*____________________________________________________________________________*\
 *
 Function:
 Synopsis:
 Description:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int DirIndexPage_constructor( PIObject *pObj,
	int iArgc, const char *ppArgv[] )
{
	return IFaceBase_constructor( pObj, PI_NEW( DirIndexPage( pObj,
		iArgc, ppArgv ) ) );
}

#if 0
/*___+++CNF_BEGIN+++___*/
	<Class>
		Name DirIndexPageClass
		Type LogicExtension
		Library IntrFace
		OnClassLoad IFaceBase_onClassLoad
		Constructor DirIndexPage_constructor
		CopyConstructor IFaceBase_copyConstructor
		Destructor IFaceBase_destructor
		Execute IFaceBase_execute
	</Class>

	<Object>
		Name DirIndexPage
		Class DirIndexPageClass
	</Object>

/*___+++CNF_END+++___*/
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -