📄 fina.cpp
字号:
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,55,120,"Fina Examination Of Visual C++",lstrlen("Fina Examination Of Visual C++"));
TextOut(hDC,35,145,"This Is Win32 SDK Version For VC/C++",lstrlen("This Is Win32 SDK Version For VC/C++"));
TextOut(hDC,40,170,"Developed by 【 自动化981 】孫輝",lstrlen("Developed by 【 自动化981 】孫輝"));
ReleaseDC(hInfoWnd,hDC);
}
else if(PtInRect(&NextRect,ptPosUp))
{
HTREEITEM hNextItem;
hNextItem=TreeView_GetNextSibling(hTree,hChildItemNow);
if(hNextItem!=0)
{
TreeView_SelectItem(hTree,hNextItem);
}
else//item is classadditem
{
if(TreeView_GetParent(hTree,hChildItemNow)==0)
{
TreeView_SelectItem(hTree,hRootItem);
}
else if(bIsFaceAddItem1)
{
TreeView_SelectItem(hTree,TreeView_GetChild(hTree,hParentItemNow));
bIsFaceAddItem1=0;
}
else if(bIsDeletedItem)
{
TreeView_SelectItem(hTree,hClassItem[iClassNumber-2]);
bIsDeletedItem=0;
}
else
TreeView_SelectItem(hTree,hClassItem[iClassNumber-1]);
}
}
else if(PtInRect(&DelRect,ptPosUp))//del
{
HTREEITEM hDelItem;
if(hChildItemNow==hRootItem||hChildItemNow==hInfoItem||hChildItemNow==hMeItem)
{
}
else
{
if(hParentItemNow==hRootItem)//del class
{
if(hChildItemNow==hClassAddItem)
{
}
else
{
k=GetClassItemNum(hChildItemNow);
TreeView_DeleteItem(hTree,hChildItemNow);
for(u=k;u<iClassNumber;u++)
{
classroom[u]=classroom[u+1];
hClassItem[u]=hClassItem[u+1];
}
iClassNumber--;
hDataFile=_lopen("Fina.hui",OF_WRITE);
if(hDataFile==HFILE_ERROR)
{
MessageBox(hwnd,"Error Open Fina.hui","Warning...",MB_OK);
return 0;
}
if(_llseek(hDataFile,/*k*sizeof(struct classinfo)*/0,0)==HFILE_ERROR)
{
MessageBox(hwnd,"Error Seek Fina.hui","Warning...",MB_OK);
return 0;
}
for(u=0;u<iClassNumber+1;u++)
{
if(_lwrite(hDataFile,(LPSTR)&classroom[u],sizeof(struct classinfo))==HFILE_ERROR)
{
MessageBox(hwnd,"Error Write Deleting","Warning...",MB_OK);
return 0;
}
}
if(_lclose(hDataFile)==HFILE_ERROR)
{
MessageBox(hwnd,"Error Close Deleting","Warning...",MB_OK);
return 0;
}
bIsDeletedItem=1;
}
}
else//del student
{
m=GetClassItemNum(hParentItemNow);
n=GetStudentItemNum(m,hChildItemNow);
for(u=0;u<20;u++)
{
if(hChildItemNow==hFaceAddItem[u])
{
bIsDelFaceAddItem=1;
break;
}
}
if(bIsDelFaceAddItem)
{
bIsDelFaceAddItem=0;
}
else
{
TreeView_DeleteItem(hTree,hChildItemNow);
for(u=n;u<iStudentNumber[m];u++)
{
classroom[m].student[u]=classroom[m].student[u+1];
hFaceOnItem[m][u]=hFaceOnItem[m][u+1];
}
iStudentNumber[m]--;
hDataFile=_lopen("Fina.hui",OF_WRITE);
if(hDataFile==HFILE_ERROR)
{
MessageBox(hwnd,"Error Open Fina.hui","Warning...",MB_OK);
return 0;
}
// if(_llseek(hDataFile,m*sizeof(struct classinfo)+6*sizeof(struct subjectinfo)+sizeof(str)+n*sizeof(struct studentinfo)+3,0)==HFILE_ERROR)
if(_llseek(hDataFile,m*sizeof(struct classinfo),0)==HFILE_ERROR)
{
MessageBox(hwnd,"Error Seek Fina.hui Deleting Student","Warning...",MB_OK);
return 0;
}
if(_lwrite(hDataFile,(LPSTR)&classroom[m],sizeof(struct classinfo))==HFILE_ERROR)
{
MessageBox(hwnd,"Error Write Student Info","Warning...",MB_OK);
return 0;
}
if(_lclose(hDataFile)==HFILE_ERROR)
{
MessageBox(hwnd,"Error Close Fina.hui Deleting Student","Warning...",MB_OK);
return 0;
}
}
}
}
}
else if(PtInRect(&HelpRect,ptPosUp))
{
ShellExecute(NULL,"open","说明.txt",NULL,NULL,SW_MAXIMIZE);
}
else if(PtInRect(&HomePageRect,ptPosUp))
{
ShellExecute(NULL,"open","http://sun.zoking.net",NULL,NULL,SW_MAXIMIZE );
}
else if(PtInRect(&EmailRect,ptPosUp))
{
ShellExecute(NULL,"open","mailto:isunh@263.net",NULL,NULL,SW_MAXIMIZE );
}
}
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;
}
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.hIconSm=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;
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,
340,10,200,250,
hWnd,
(HMENU)NULL,
hInst,
NULL);
hImageList=ImageList_Create(IMAGEWIDTH,IMAGEHEIGHT,0,IMAGENUM,0);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_INFO));
idInfo=ImageList_Add(hImageList,hBitmap,NULL);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CLASS));
idClass=ImageList_Add(hImageList,hBitmap,NULL);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_FACEON));
idFaceOn=ImageList_Add(hImageList,hBitmap,NULL);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_FACEADD));
idFaceAdd=ImageList_Add(hImageList,hBitmap,NULL);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ROOT));
idRoot=ImageList_Add(hImageList,hBitmap,NULL);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ME));
idMe=ImageList_Add(hImageList,hBitmap,NULL);
hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CLASSADD));
idClassAdd=ImageList_Add(hImageList,hBitmap,NULL);
if(ImageList_GetImageCount(hImageList)<IMAGENUM)
{
MessageBeep(0xffffffff);
return 0;
}
if(TreeView_SetImageList(hTree,hImageList,idInfo)) MessageBeep(0xffffffff);
LoadString(hInst,IDS_ROOT,cTmpBuff,sizeof(cTmpBuff));
hRootItem=AddOneItem(hTree,TVI_ROOT,TVI_FIRST,cTmpBuff,idRoot);
LoadString(hInst,IDS_INFO,cTmpBuff,sizeof(cTmpBuff));
hInfoItem=AddOneItem(hTree,TVI_ROOT,TVI_LAST,cTmpBuff,idInfo);
LoadString(hInst,IDS_ME,cTmpBuff,sizeof(cTmpBuff));
hMeItem=AddOneItem(hTree,hInfoItem,TVI_LAST,cTmpBuff,idMe);
LoadString(hInst,IDS_CLASSADD,cTmpBuff,sizeof(cTmpBuff));
hClassAddItem=AddOneItem(hTree,hRootItem,TVI_LAST,cTmpBuff,idClassAdd);
ReflashTreeWnd();
return 1;
}
HTREEITEM AddOneItem(HWND hTreeWnd,HTREEITEM hParentItem,HTREEITEM hBrotherItem,LPSTR szText,int iImage)
{
TV_ITEM tvItem;
TV_INSERTSTRUCT tvInsertItem;
HTREEITEM hTreeItem;
tvItem.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tvItem.pszText=szText;
tvItem.cchTextMax=lstrlen(szText);
tvItem.iImage=iImage;
tvItem.iSelectedImage=iImage;
tvInsertItem.item=tvItem;
tvInsertItem.hParent=hParentItem;
tvInsertItem.hInsertAfter=hBrotherItem;
hTreeItem=(HTREEITEM)SendMessage(hTreeWnd,TVM_INSERTITEM,0,(LPARAM)(LPTV_INSERTSTRUCT)&tvInsertItem);
return(hTreeItem);
}
BOOL DelOneItem(HWND hTreeWnd,HTREEITEM hDelItem)
{
TreeView_DeleteItem(hTree,hDelItem);
return 1;
}
BOOL _stdcall InitOperateIcon(HWND hWnd,HDC hDc)
{
if(!DrawIcon(hDc,23,276,hExitIcon))
return 0;
TextOut(hDc,26,274+34,"Exit",sizeof("Exit")-1);
if(!DrawIcon(hDc,280,276,hHelpIcon))
return 0;
TextOut(hDc,282,274+34,"Help",sizeof("Help")-1);
if(!DrawIcon(hDc,230,276,hDelIcon))
return 0;
TextOut(hDc,226,274+34,"Delete",sizeof("Delete")-1);
if(!DrawIcon(hDc,180,276,hNextIcon))
return 0;
TextOut(hDc,182,274+34,"Next",sizeof("Next")-1);
if(!DrawIcon(hDc,130,276,hInfoIcon))
return 0;
TextOut(hDc,134,274+34,"Info",sizeof("Info")-1);
if(!DrawIcon(hDc,80,276,hPrevIcon))
return 0;
TextOut(hDc,82,274+34,"Prev",sizeof("Prev")-1);
return 1;
}
BOOL _stdcall CurPosSetting(HICON hNewIcon,RECT Rect)
{
HDC hDc;
hDc=GetDC(hwnd);
if(DrawIcon(hDc,Rect.left,Rect.top,hNewIcon))
{
ReleaseDC(hwnd,hDc);
return 0;
}
ReleaseDC(hwnd,hDc);
return 1;
}
BOOL CALLBACK CreateClassInfoWnd(HWND hParentWnd,HDC hParentDC)
{
char str[6][8]={{"学科一"},{"学科一"},{"学科二"},{"学科四"},{"学科五"},{"学科六"}};
int i;
SetBkMode(hParentDC,TRANSPARENT);
SetTextColor(hParentDC,RGB(0,0,0));
TextOut(hParentDC,15,5,"班级名称",lstrlen("班级名称"));
hgClassNameWnd=CreateWindowEx(0L,
"edit",
"班 名",
WS_CHILD|WS_VISIBLE|ES_LEFT,
90,5,170,15,
hParentWnd,
(HMENU)NULL,
hInst,
NULL);
TextOut(hParentDC,100,35,"学科名称",lstrlen("学科名称"));
TextOut(hParentDC,250,35,"学分",lstrlen("学分"));
for(i=0;i<6;i++)
{
TextOut(hParentDC,5,35+(1+i)*25,str[i],lstrlen(str[i]));
hgSubjectNameWnd[i]=CreateWindowEx(0L,
"edit",
"课 程",
WS_VISIBLE|WS_CHILD|ES_LEFT,
60,35+(i+1)*25,170,15,
hParentWnd,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -