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

📄 librarymain.cpp

📁 一个图书馆信息查询系统。是根据学校图书馆的实际情况调查后开发
💻 CPP
字号:

#define WIN32_LEAN_AND_MEAN
#include "resource.h"
#include "register.h"
#include "AdmBase.h"

#include "SysAdmTask.h"

#include "ReaderBase.h"
#include "ReaderBook.h"
#include "ReaderTask.h"

#include "ComAdmReader.h"
#include "ComAdmBook.h"
#include "ComAdmTask.h"

USERINFO g_userinfo = {1, UT_COMADM};
HINSTANCE g_hInst;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstCur, HINSTANCE hInstPrev, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASS wc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wc.hIcon			= LoadIcon(hInstCur, (LPCTSTR)IDI_BRAND);
	wc.hInstance		= hInstCur;
	wc.lpfnWndProc		= WndProc;
	wc.lpszClassName	= "Standard";
	wc.lpszMenuName		= (LPCTSTR)IDR_MENUMAIN;
	wc.style			= CS_HREDRAW | CS_VREDRAW;
	RegisterClass(&wc);

	HWND hWnd = CreateWindow(wc.lpszClassName, "X Library", WS_OVERLAPPEDWINDOW,
      0, 0, 0, 0, NULL, NULL, hInstCur, NULL);
	if(!hWnd)
		return 0;
	
	int w = GetDeviceCaps(GetDC(GetDesktopWindow()), HORZRES);
	int h = GetDeviceCaps(GetDC(GetDesktopWindow()), VERTRES);
	MoveWindow(hWnd, w/2-250, h/2-200, 500, 400, TRUE);
	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);
	
	g_hInst = hInstCur;

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

	UnregisterClass(wc.lpszClassName, hInstCur);
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) 
	{
		/*根据用户类型的不同设置不同的菜单*/
		case WM_CREATE:
			Register(hWnd, &g_userinfo);
			if(UT_SYSADM == g_userinfo.ut)
			{
				HMENU hMenu = LoadMenu(g_hInst, (LPCTSTR)IDR_MENU_SYSADM);
				SetMenu(hWnd, hMenu);
			}
			else if(UT_COMADM == g_userinfo.ut)
			{
				HMENU hMenu = LoadMenu(g_hInst, (LPCTSTR)IDR_MENU_COMADM);
				SetMenu(hWnd, hMenu);
			}
			else if(UT_READER == g_userinfo.ut)
			{
				HMENU hMenu = LoadMenu(g_hInst, (LPCTSTR)IDR_MENU_READER);
				SetMenu(hWnd, hMenu);
			}
 			return 0;

		case WM_COMMAND:
			{
				int wmId	= LOWORD(wParam); 
				int wmEvent = HIWORD(wParam); 
 				switch (wmId)
				{
					case IDM_SYSADM_INFO:
						AdmBase(hWnd, &g_userinfo);
						break;
					case IDM_SYSADM_TASK:
						SysAdmTask(hWnd);
						break;

					case IDM_READER_INFO:
						ReaderBase(hWnd, &g_userinfo);
						break;
					case IDM_READER_BOOK:
						ReaderBook(hWnd);
						break;
					case IDM_READER_TASK:
						ReaderTask(hWnd, &g_userinfo);
						break;

					case IDM_COMADM_INFO:
						AdmBase(hWnd, &g_userinfo);
						break;

					case IDM_COMADM_BOOK:
						ComAdmBook(hWnd);
						break;

					case IDM_COMADM_READER:
						ComAdmReader(hWnd);
						break;

					case IDM_COMADM_TASK:
						ComAdmTask(hWnd);
						break;
				}
			}
			return 0;

		case WM_DESTROY:
			DestroyWindow(hWnd);
			PostQuitMessage(0);
			return 0;
    }

	return DefWindowProc(hWnd, message, wParam, lParam);
}

⌨️ 快捷键说明

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