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

📄 fina.cpp

📁 本作品为一简单的数据库引擎,用于简单的学生成绩管理,包括班级课程设置、学分设置、学生成绩入录、总成绩计算和综合测评成绩.可以实时添加删除班级、删除添加同学,也可实时更改信息,自动保存和刷新.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
////////////////////////////////////////////////////////////
//Fina.cpp
//sUN hUI start at 15:32 4.8.2001
//
//
/////////////////////////////////////////////////////////////

#include "Fina.h"
/////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////

void InitRect(void)
{
	/*edge*/
	infoRect.left=10;
	infoRect.right=330;
	infoRect.top=10;
	infoRect.bottom=260;
	iconRect.left=10;
	iconRect.top=270;
	iconRect.right=330;
	iconRect.bottom=310+15;
	webRect.left=340;
	webRect.top=270;
    webRect.right=540;
	webRect.bottom=310+15;

	/*icon*/
	ExitRect.top=PrevRect.top=InfoRect.top=NextRect.top=DelRect.top=HelpRect.top=276;
	ExitRect.bottom=PrevRect.bottom=InfoRect.bottom=NextRect.bottom=DelRect.bottom=HelpRect.bottom=325;
	ExitRect.left=23;
	PrevRect.left=80;
	InfoRect.left=130;
	NextRect.left=180;
	DelRect.left=230;
	HelpRect.left=280;
	ExitRect.right=ExitRect.left+32;
	PrevRect.right=PrevRect.left+32;
	InfoRect.right=InfoRect.left+32;
	NextRect.right=NextRect.left+32;
	DelRect.right=DelRect.left+32;
	HelpRect.right=HelpRect.left+32;
	
	/*bmp*/
	EmailRect.left=343;
	EmailRect.top=274;
	EmailRect.right=510;
	EmailRect.bottom=294;
    HomePageRect.left=343;
	HomePageRect.top=299;
	HomePageRect.right=536;
	HomePageRect.bottom=320;

	InfoWndRect.left=11;
	InfoWndRect.top=11;
	InfoWndRect.right=327;
	InfoWndRect.bottom=257;
}

void InitIcon(void)
{
	hDelIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_DEL));
	hDelOnIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_DELON));
	hExitIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_EXIT));
	hExitOnIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_EXITON));
	hHelpIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_HELP));
	hHelpOnIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_HELPON));
	hNextIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_NEXT));
	hNextOnIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_NEXTON));
	hPrevIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_PREV));
	hPrevOnIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_PREVON));
	hInfoIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_INFO));
	hInfoOnIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_INFOON));
}

LRESULT CALLBACK MainProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	HTREEITEM OperatingItem,OperatedItem;
	HTREEITEM TmpItem;
	HPEN hPen,holdPen;
	HDC hTmpDc;
	HDC hDc;
	int i;
	BOOL bIsFaceAddItem;

	switch(msg)
	{
	case WM_CREATE:
		InitIcon();
		InitRect();

		hTree=NULL;
		iClassNumber=0;

		LoadString(hInst,IDS_ROOT,cTmpBuff,sizeof(cTmpBuff));
		SetWindowText(hWnd,cTmpBuff);

		InitTreeWnd(hWnd);
		ReflashTreeWnd();
		TreeView_SelectItem(hTree,hRootItem);
		{
			hInfoWnd=CreateWindowEx(0L,
	    		"static",
	    		"Infomation Showing",
		    	WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
	            infoRect.left+1,
	       		infoRect.top+1,
        		infoRect.right-infoRect.left-3,
		    	infoRect.bottom-infoRect.top-3,
    			hWnd,
	    		(HMENU)NULL,
		    	hInst,
	    		NULL);

			hShowWnd=CreateWindowEx(0L,
				"static",
				"RootTreeWnd",
				WS_CHILD|WS_VISIBLE|SS_BITMAP,
				10,80,10+100,80+76,
				hInfoWnd,
				(HMENU)NULL,
				hInst,
				NULL);
       		hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LOGO));
	        SendMessage(hShowWnd,STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hBitmap);

		}

		return 0;
	case WM_SIZE:
		SendMessage(hWnd,WM_PAINT,0,0L);
		UpdateWindow(hWnd);

		return 0;
	case WM_MOVE:
		SendMessage(hWnd,WM_PAINT,0,0L);
		UpdateWindow(hWnd);

		return 0;
	case WM_COMMAND:
		switch(HIWORD(wParam))
		{
    	case EN_KILLFOCUS:
			MessageBox(NULL,"o","a",MB_OK);
			return 0;
     	default:
			return 0;
		}

		return 0;
	case WM_PAINT:
		hDc=BeginPaint(hWnd,&Ps);

		SetBkMode(hDc,TRANSPARENT);

		InitOperateIcon(hWnd,hDc);


		DrawEdge(hDc,&infoRect,BDR_SUNKENINNER|BDR_RAISEDOUTER,BF_TOPLEFT|BF_BOTTOMRIGHT|BF_FLAT);
		DrawEdge(hDc,&webRect,BDR_SUNKENINNER|BDR_RAISEDOUTER,BF_TOPLEFT|BF_BOTTOMRIGHT|BF_FLAT);
		DrawEdge(hDc,&iconRect,BDR_SUNKENINNER|BDR_RAISEDOUTER,BF_TOPLEFT|BF_BOTTOMRIGHT|BF_FLAT);

		if(!hInfoWnd)
		   	hInfoWnd=CreateWindowEx(0L,
	    		"static",
	    		"Infomation Showing",
		    	WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
	            infoRect.left+1,
	       		infoRect.top+1,
        		infoRect.right-infoRect.left-3,
		    	infoRect.bottom-infoRect.top-3,
    			hWnd,
	    		(HMENU)NULL,
		    	hInst,
	    		NULL);

		SetTextColor(hDc,RGB(0,0,255));

		hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_EMAIL));
		hTmpDc=CreateCompatibleDC(hDc);
		hOldBitmap=SelectObject(hTmpDc,hBitmap);
		BitBlt(hDc,343,274,23,23,hTmpDc,0,0,SRCCOPY);
		
		hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_HOMEPAGE));
		hOldBitmap=SelectObject(hTmpDc,hBitmap);
		BitBlt(hDc,343,299,23,23,hTmpDc,0,0,SRCCOPY);
		SelectObject(hTmpDc,hOldBitmap);
		DeleteDC(hTmpDc);

		LoadString(hInst,IDS_EMAIL,cTmpBuff,sizeof(cTmpBuff));
		TextOut(hDc,369,278,cTmpBuff,20);
		LoadString(hInst,IDS_HOMEPAGE,cTmpBuff,sizeof(cTmpBuff));
		TextOut(hDc,369,303,cTmpBuff,25);

		SetTextColor(hDc,RGB(0,0,0));

		hPen=CreatePen(PS_SOLID,2,RGB(0,0,255));
        holdPen=SelectObject(hDc,hPen);
		MoveToEx(hDc,369,294,NULL);
		LineTo(hDc,510,294);
		MoveToEx(hDc,369,320,NULL);
		LineTo(hDc,536,320);
		SelectObject(hDc,holdPen);
		DeleteObject(hPen);
		DeleteObject(holdPen);

		EndPaint(hWnd,&Ps);

		return 0;
	case WM_NOTIFY:
		switch(((LPNMHDR)lParam)->code)
		{
		case TVN_SELCHANGING:
			if(hShowItem==NULL||hShowItem==hRootItem||hShowItem==hInfoItem||hShowItem==hMeItem)
			{
			}
			else
			{
				TmpItem=TreeView_GetParent(hTree,hShowItem);
				if(/*hShowItem!=hClassAdd*/1)
				{
					SaveData(TmpItem,hShowItem);
				}
			}

			if(hShowWnd)
				DestroyWindow(hShowWnd);
			InvalidateRect(hwnd,&InfoWndRect,1);
			UpdateWindow(hwnd);
			OperatingItem=(((NM_TREEVIEW *)lParam)->itemNew.hItem);
			if(OperatingItem==hRootItem)
			{

			}
			else if(OperatingItem==hInfoItem)
			{

			}
			else if(OperatingItem==hClassAddItem)
			{
			}

			return 0;
		case TVN_SELCHANGED:
			OperatedItem=(((NM_TREEVIEW *)lParam)->itemNew).hItem;
			TmpItem=TreeView_GetParent(hTree,OperatedItem);

			for(i=0;i<20;i++)
			{
				if(OperatedItem==hFaceAddItem[i])
				{
					bIsFaceAddItem=1;
					break;
				}
			}

			if(OperatedItem==hRootItem)
			{
				hShowWnd=CreateWindowEx(0L,
					"static",
					"RootTreeWnd",
					WS_CHILD|WS_VISIBLE|SS_BITMAP,
					10,80,10+100,80+76,
					hInfoWnd,
					(HMENU)NULL,
					hInst,
					NULL);
        		hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LOGO));
		        SendMessage(hShowWnd,STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hBitmap);

			}
			else if(OperatedItem==hClassAddItem)
			{
				HDC hDC;
				hShowWnd=CreateWindowEx(0L,
					"static",
					"ClassInfoWnd",
					WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
					InfoWndRect.left,
					InfoWndRect.top,
					InfoWndRect.right-InfoWndRect.left,
					InfoWndRect.bottom-InfoWndRect.top,
					hInfoWnd,
					(HMENU)NULL,
					hInst,
					NULL);
				hDC=GetDC(hShowWnd);
				if(TmpItem==hRootItem)//addclass
				{
					CreateClassInfoWnd(hShowWnd,hDC);
	//				SetClassInfoWndContent(GetClassItemNum(OperatedItem));
				}
				else//addstudent
				{
//					TmpItem=TreeView_GetParent(hTree,OperatedItem);

//					CreateStudentInfoWnd(hShowWnd,hDC);
				}

				ReleaseDC(hShowWnd,hDC);
			}
/*			else if(TmpItem==hRootItem)
			{
				HDC hDC;
				hShowWnd=CreateWindowEx(0L,
					"static",
					"ClassInfoWnd",
					WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
					InfoWndRect.left,
					InfoWndRect.top,
					InfoWndRect.right-InfoWndRect.left,
					InfoWndRect.bottom-InfoWndRect.top,
					hInfoWnd,
					(HMENU)NULL,
					hInst,
					NULL);
				hDC=GetDC(hShowWnd);
			}*/
			else if(OperatedItem==hInfoItem)
			{
				HDC hDC;
				hDC=GetDC(hInfoWnd);
				hShowWnd=CreateWindowEx(0L,
					"static",
					"hRootTreeWnd",
					WS_CHILD|WS_VISIBLE|SS_BITMAP,
					10,50,10+100,50+76,
					hInfoWnd,
					(HMENU)NULL,
					hInst,
					NULL);
        		hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LOGO));
		        SendMessage(hShowWnd,STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hBitmap);
				SetBkMode(hDC,TRANSPARENT);
				SetTextColor(hDC,RGB(0,0,0));
				TextOut(hDC,110,140,"hello world",lstrlen("hello world"));
				ReleaseDC(hInfoWnd,hDC);	
			}
			else if(TmpItem==hRootItem&&OperatedItem!=hClassAddItem)//classItem
			{
				HDC hDC;
				hShowWnd=CreateWindowEx(0L,
					"static",
					"ClassInfoWnd",
					WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
					InfoWndRect.left,
					InfoWndRect.top,
					InfoWndRect.right-InfoWndRect.left,
					InfoWndRect.bottom-InfoWndRect.top,
					hInfoWnd,
					(HMENU)NULL,
					hInst,
					NULL);
				hDC=GetDC(hShowWnd);
				CreateClassInfoWnd(hShowWnd,hDC);
				SetClassInfoWndContent(GetClassItemNum(OperatedItem));

				ReleaseDC(hShowWnd,hDC);
			}
			else if(OperatedItem==hMeItem)
			{

			}
//			else if(OperatedItem==hFaceAddItem&&OperatedItem!=hShowItem)
			else if(bIsFaceAddItem)
			{
				HDC hDC;
				hShowWnd=CreateWindowEx(0L,
					"static",
					"ClassInfoWnd",
					WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
					InfoWndRect.left,
					InfoWndRect.top,
					InfoWndRect.right-InfoWndRect.left,
					InfoWndRect.bottom-InfoWndRect.top,
					hInfoWnd,
					(HMENU)NULL,
					hInst,
					NULL);
				hDC=GetDC(hShowWnd);

				CreateStudentInfoWnd(hShowWnd,hDC);

				ReleaseDC(hShowWnd,hDC);
				bIsFaceAddItem=0;				
			}
			else//studentItem
			{
			}
			hShowItem=OperatedItem;
			break;
		default:
			break;

		}
		return 0;
	case WM_DESTROY:
		_lclose(hDataFile);
//		KillTimer(hwnd,26);
		PostQuitMessage(0);
		return 0;
	case WM_MOUSEMOVE:
		ptMouseOld=ptMouseNew;
		ptMouseNew.x=LOWORD(lParam);
		ptMouseNew.y=HIWORD(lParam);

		if(PtInRect(&ExitRect,ptMouseNew)&&(!PtInRect(&ExitRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
			CurPosSetting(hExitOnIcon,ExitRect);
		}
		else if(PtInRect(&ExitRect,ptMouseOld)&&(!PtInRect(&ExitRect,ptMouseNew)))
		{
			ReleaseCapture();
			CurPosSetting(hExitIcon,ExitRect);
		}

		if(PtInRect(&PrevRect,ptMouseNew)&&(!PtInRect(&PrevRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
			CurPosSetting(hPrevOnIcon,PrevRect);
		}
		else if(PtInRect(&PrevRect,ptMouseOld)&&(!PtInRect(&PrevRect,ptMouseNew)))
		{
			ReleaseCapture();
			CurPosSetting(hPrevIcon,PrevRect);
		}

		if(PtInRect(&InfoRect,ptMouseNew)&&(!PtInRect(&InfoRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
			CurPosSetting(hInfoOnIcon,InfoRect);
		}
		else if(PtInRect(&InfoRect,ptMouseOld)&&(!PtInRect(&InfoRect,ptMouseNew)))
		{
			ReleaseCapture();
			CurPosSetting(hInfoIcon,InfoRect);
		}

		if(PtInRect(&NextRect,ptMouseNew)&&(!PtInRect(&NextRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
			CurPosSetting(hNextOnIcon,NextRect);
		}
		else if(PtInRect(&NextRect,ptMouseOld)&&(!PtInRect(&NextRect,ptMouseNew)))
		{
			ReleaseCapture();
			CurPosSetting(hNextIcon,NextRect);
		}

		if(PtInRect(&DelRect,ptMouseNew)&&(!PtInRect(&DelRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
			CurPosSetting(hDelOnIcon,DelRect);
		}
		else if(PtInRect(&DelRect,ptMouseOld)&&(!PtInRect(&DelRect,ptMouseNew)))
		{
			ReleaseCapture();
			CurPosSetting(hDelIcon,DelRect);
		}

		if(PtInRect(&HelpRect,ptMouseNew)&&(!PtInRect(&HelpRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
			CurPosSetting(hHelpOnIcon,HelpRect);
		}
		else if(PtInRect(&HelpRect,ptMouseOld)&&(!PtInRect(&HelpRect,ptMouseNew)))
		{
			ReleaseCapture();
			CurPosSetting(hHelpIcon,HelpRect);
		}

		if(PtInRect(&EmailRect,ptMouseNew)&&(!PtInRect(&EmailRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
		}
		else if(PtInRect(&EmailRect,ptMouseOld)&&(!PtInRect(&EmailRect,ptMouseNew)))
		{
			ReleaseCapture();
		}

		if(PtInRect(&HomePageRect,ptMouseNew)&&(!PtInRect(&HomePageRect,ptMouseOld)))
		{
    		SetCursor(LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND)));
			SetCapture(hWnd);
		}
		else if(PtInRect(&HomePageRect,ptMouseOld)&&(!PtInRect(&HomePageRect,ptMouseNew)))
		{
			ReleaseCapture();
		}

		return 0;		
	default:
		return DefWindowProc(hWnd,msg,wParam,lParam);
	}

	return 0;
}
/*
void MoveInfoWnd()
{
	SetWindowPos(hInfoShowWnd,HWND_TOP,0,iTmpY,100,40,SWP_NOSIZE|SWP_SHOWWINDOW);
	iTmpY++;

	if(iTmpY>=150)
	{
		KillTimer(hInfoShowWnd,26);
		InvalidateRect(hwnd,NULL,1);
		UpdateWindow(hwnd);
	}


}
*/
BOOL InitProgram(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;
	HBITMAP hBackBitmap;
	HBRUSH hBackBrush;

	hBackBitmap=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BACK));
	hBackBrush=CreatePatternBrush(hBackBitmap);
	DeleteObject(hBackBitmap);

	memset(&wcex,0,sizeof(WNDCLASSEX));
	wcex.cbSize=(sizeof(WNDCLASSEX));
	wcex.lpszClassName="Fina";
	wcex.hInstance=hInstance;
	wcex.lpfnWndProc=(WNDPROC)MainProc;
	wcex.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MAIN));
	wcex.hbrBackground=(HBRUSH)CreateSolidBrush(RGB(102,255,153));//hBackBrush;
	wcex.hCursor=LoadCursor(NULL,IDC_ARROW);
	wcex.lpszMenuName=NULL;//MAKEINTRESOURCE(IDM_MAIN);
	wcex.cbClsExtra=0;
	wcex.cbWndExtra=0;
	wcex.style=0;
	wcex.hIconSm=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MAIN));

	if(!RegisterClassEx(&wcex))
		return FALSE;

	return TRUE;
}

HWND CALLBACK InitMainWnd(HINSTANCE hInstance)
{
	return (CreateWindowEx(0L,
		"Fina","Fina",
		WS_VISIBLE|WS_MINIMIZEBOX|WS_SYSMENU|CS_OWNDC|CS_HREDRAW|CS_VREDRAW,
		100,100,550,360,
		NULL,
		(HMENU)NULL,
		hInstance,
		NULL));
}

int _stdcall WinMain(HINSTANCE hInstance,
					 HINSTANCE hPreInstance,
					 LPSTR lpCmdLine,
					 int nCmdShow)
{
	MSG msg;

	hInst=hInstance;

	InitCommonControls();

	if(!InitProgram(hInstance))
		return 0;
	if((hwnd=InitMainWnd(hInstance))==(HWND)0)
	{
		MessageBeep(0xffffffff);
		return 0;
	}
	ShowWindow(hwnd,SW_SHOW);
	UpdateWindow(hwnd);

	while(GetMessage(&msg,NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;
}

BOOL _stdcall InitTreeWnd(HWND hWnd)
{
	HIMAGELIST hImageList;

	hTree=CreateWindowEx(WS_EX_CLIENTEDGE,
		WC_TREEVIEW,
		NULL,
		WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_SHOWSELALWAYS|TVS_HASBUTTONS,

⌨️ 快捷键说明

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