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

📄 winmain.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 2 页
字号:
	MoveWindow(gui.hwndUserEditButton, cx - 140, cy - cy_status -20, 140, 20, TRUE);}static BOOL guiOnSetCursor(HWND hwnd, HWND hwndCursor, UINT codeHitTest, UINT msg){	POINT p;		if(hwnd == hwndCursor && codeHitTest == HTCLIENT) {		GetCursorPos(&p);		ScreenToClient(hwnd, &p);		if(PtInRect(&gui.rectHDivider, p))			SetCursor(LoadCursor(0, IDC_SIZENS));				return TRUE;	}		return FORWARD_WM_SETCURSOR(hwnd, hwndCursor, codeHitTest, msg, DefWindowProc);}static void guiOnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags){	POINT p;		p.x = x;	p.y = y;		if( PtInRect(&gui.rectHDivider, p) ) {		SetCapture(hwnd);		gui.mode |= MODE_HDIVIDE;	}}static void guiOnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags){	ReleaseCapture();	gui.mode &= ~(MODE_HDIVIDE|MODE_VDIVIDE);}static void guiOnCaptureChanged(HWND hwndNewCapture){	gui.mode &= ~(MODE_HDIVIDE|MODE_VDIVIDE);}static void guiOnMouseMove(HWND hwnd, int x, int y, UINT keyFlags){	int offset, cy_console, cy_users;	RECT r;		if( gui.mode & MODE_HDIVIDE ) {		offset = y - gui.rectHDivider.top;		if( !offset ) return;		cy_console = gui.rectConsole.bottom - gui.rectConsole.top;		cy_users = gui.rectUsers.bottom - gui.rectUsers.top;				if( cy_console + offset <= 0)			offset = -cy_console;		else if( cy_users - offset <= 0)			offset = cy_users;					cy_console += offset;		cy_users -= offset;		if( cy_console + cy_users == 0 ) return;		gui.y_ratio = (cy_console<<10) / (cy_console + cy_users);		GetClientRect(hwnd, &r);		guiOnSize(hwnd, 0, r.right, r.bottom);		InvalidateRect(hwnd, NULL, FALSE);	}}extern int gui_printf(const char *format, ...){	va_list arglist;	va_start(arglist, format);	return gui_lvprintf(eventlog_level_error, format, arglist);}extern int gui_lprintf(t_eventlog_level l, const char *format, ...){	va_list arglist;	va_start(arglist, format);	return gui_lvprintf(l, format, arglist);}extern int gui_lvprintf(t_eventlog_level l, const char *format, va_list arglist){	char buff[4096];	int result;	COLORREF clr;		result = vsprintf(buff, format, arglist);		switch(l) {		case eventlog_level_none:			clr = RGB(0, 0, 0);			break;		case eventlog_level_trace:			clr = RGB(255, 0, 255);			break;		case eventlog_level_debug:			clr = RGB(0, 0, 255);			break;		case eventlog_level_info:			clr = RGB(0, 0, 0);			break;		case eventlog_level_warn:			clr = RGB(255, 128, 64);			break;		case eventlog_level_error:			clr = RGB(255, 0, 0);			break;		case eventlog_level_fatal:			clr = RGB(255, 0, 0);			break;		default:			clr = RGB(0, 0, 0);	}		guiAddText(buff, clr);	return result;}static void guiOnUpdates (){	ShellExecute(NULL, "open", "www.pvpgn.org", NULL, NULL, SW_SHOW );}static void guiOnAnnounce (HWND hwnd){	DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ANN), hwnd, (DLGPROC)AnnDlgProc);}static void guiOnUserStatusChange (HWND hwnd){	int  index;	index = SendMessage(gui.hwndUsers, LB_GETCURSEL, 0, 0);	SendMessage(gui.hwndUsers, LB_GETTEXT, index, (LPARAM)selected_item);	DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_KICKUSER), hwnd, (DLGPROC)KickDlgProc);	SendMessage(gui.hwndUsers, LB_SETCURSEL, -1, 0);}static void guiOnAbout (HWND hwnd){	DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hwnd, (DLGPROC)AboutDlgProc);}static void guiOnServerConfig(){	ShellExecute(NULL, "open", "notepad.exe", "conf\\bnetd.conf", NULL, SW_SHOW );}extern void guiOnUpdateUserList(){	t_connection * c;	t_elem const * curr;	t_account * acc;	char UserCount[80];		SendMessage(gui.hwndUsers, LB_RESETCONTENT, 0, 0);		LIST_TRAVERSE_CONST(connlist(),curr)	{		if (!(c = elem_get_data(curr))) continue;		if (!(acc = conn_get_account(c))) continue;				SendMessage(gui.hwndUsers, LB_ADDSTRING, 0, (LPARAM)account_get_name(acc));	}		sprintf(UserCount, "%d", connlist_login_get_length());	strcat (UserCount, " user(s) online:");	SendMessage(gui.hwndUserCount,WM_SETTEXT,0,(LPARAM)UserCount);}static void guiAddText(const char *str, COLORREF clr){	int start_lines, text_length, end_lines;	CHARRANGE cr;	CHARRANGE ds;	CHARFORMAT fmt;	text_length = SendMessage(gui.hwndConsole, WM_GETTEXTLENGTH, 0, 0);		if ( text_length >30000 ) {		ds.cpMin = 0;		ds.cpMax = text_length - 30000;		SendMessage(gui.hwndConsole, EM_EXSETSEL, 0, (LPARAM)&ds);		SendMessage(gui.hwndConsole, EM_REPLACESEL, FALSE, 0);	}		cr.cpMin = text_length;	cr.cpMax = text_length;		SendMessage(gui.hwndConsole, EM_EXSETSEL, 0, (LPARAM)&cr); 		fmt.cbSize = sizeof(CHARFORMAT);	fmt.dwMask = CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD|CFM_ITALIC|CFM_STRIKEOUT|CFM_UNDERLINE;	fmt.yHeight = 160;	fmt.dwEffects = 0;	fmt.crTextColor = clr;	strcpy(fmt.szFaceName,"Courier New");		SendMessage(gui.hwndConsole, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);	SendMessage(gui.hwndConsole, EM_REPLACESEL, FALSE, (LPARAM)str);}static void guiDEAD(char *message){	char *nl;	char errorStr[4096];	char *msgLastError;		FormatMessage(		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,		NULL,		GetLastError(),		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),		(LPTSTR) &msgLastError,		0,		NULL);		nl = strchr(msgLastError, '\r');	if(nl) *nl = 0;		sprintf(errorStr, "%s\nGetLastError() = '%s'\n", message, msgLastError);		LocalFree(msgLastError);	MessageBox(0, errorStr, "guiDEAD", MB_ICONSTOP|MB_OK);	exit(1);}static void guiMoveWindow(HWND hwnd, RECT* r){	MoveWindow(hwnd, r->left, r->top, r->right-r->left, r->bottom-r->top, TRUE);}static void guiClearLogWindow(void){	SendMessage(gui.hwndConsole, WM_SETTEXT, 0, 0);}static void guiKillTrayIcon(void){	NOTIFYICONDATA dta;		dta.cbSize = sizeof(NOTIFYICONDATA);	dta.hWnd = gui.hwnd;	dta.uID = IDI_TRAY;	dta.uFlags = 0;	Shell_NotifyIcon(NIM_DELETE, &dta);}BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){	switch(Message) {		case WM_INITDIALOG:			return TRUE;		case WM_COMMAND:			switch(LOWORD(wParam)) {				case IDOK:					EndDialog(hwnd, IDOK);					break;			}			break;		default:			return FALSE;	}		return TRUE;}BOOL CALLBACK AnnDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){	t_message *message;		switch(Message) {		case WM_INITDIALOG:			return TRUE;		case WM_COMMAND:			switch(LOWORD(wParam)) {				case IDOK:					{						int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT1));												if(len > 0) {							char* buf;							buf = (char*)GlobalAlloc(GPTR, len + 1);							GetDlgItemText(hwnd, IDC_EDIT1, buf, len + 1);														if ((message = message_create(message_type_error,NULL,NULL,buf))) {								message_send_all(message);								message_destroy(message);							}														GlobalFree((HANDLE)buf);							SetDlgItemText(hwnd, IDC_EDIT1, "");						} else {							MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);						}						break;					}			}			break;		case WM_CLOSE:			EndDialog(hwnd, IDOK);			break;		default:			return FALSE;	}	return TRUE;}BOOL CALLBACK KickDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){	switch(Message) {		case WM_INITDIALOG:			if (selected_item[0]!= 0) {				SetDlgItemText(hwnd, IDC_EDITKICK, selected_item);			}						return TRUE;		case WM_COMMAND:			switch(LOWORD(wParam)) {				case IDC_KICK_EXECUTE:					{						t_connection * conngui;						t_account * accountgui;						BOOL messageq;						BOOL kickq;						char temp[60];						char ipadr[110];						messageq = FALSE;						kickq = FALSE;												GetDlgItemText(hwnd, IDC_EDITKICK, selected_item, 32);												conngui = connlist_find_connection_by_accountname(selected_item);						accountgui = accountlist_find_account(selected_item);												if (conngui == NULL) {							strcat(selected_item," could not be found in Userlist!");							MessageBox(hwnd,selected_item,"ERROR", MB_OK);						} else {							HWND hButton = GetDlgItem(hwnd, IDC_CHECKBAN);							HWND hButton1 = GetDlgItem(hwnd, IDC_CHECKKICK);							HWND hButton2 = GetDlgItem(hwnd, IDC_CHECKADMIN);							HWND hButton3 = GetDlgItem(hwnd, IDC_CHECKMOD);							HWND hButton4 = GetDlgItem(hwnd, IDC_CHECKANN);														if (SendMessage(hButton2 , BM_GETCHECK, 0, 0)==BST_CHECKED) {								account_set_admin(accountgui);								account_set_command_groups(accountgui, 255);								messageq = TRUE;							}														if (SendMessage(hButton3 , BM_GETCHECK, 0, 0)==BST_CHECKED) {								account_set_auth_operator(accountgui,NULL,1);								messageq = TRUE;							}														if (SendMessage(hButton4 , BM_GETCHECK, 0, 0)==BST_CHECKED) {								account_set_strattr(accountgui,"BNET\\auth\\announce","true");								messageq = TRUE;							}														if (SendMessage(hButton , BM_GETCHECK, 0, 0)==BST_CHECKED) {								unsigned int	i_GUI;																strcpy (temp, addr_num_to_addr_str(conn_get_addr(conngui), 0));																for (i_GUI=0; temp[i_GUI]!=':'; i_GUI++)									ipadr[i_GUI]=temp[i_GUI];																ipadr[i_GUI]= 0;																strcpy(temp," a "); 								strcat(temp,ipadr);								handle_ipban_command(NULL,temp);																temp[0] = 0;								strcpy(temp," has been added to IpBanList");								strcat(ipadr,temp);								if (messageq == TRUE) {									strcat(ipadr," and UserStatus changed");									MessageBox(hwnd,ipadr,"ipBan & StatusChange", MB_OK);									messageq = FALSE;									kickq = FALSE;								}								else									MessageBox(hwnd,ipadr,"ipBan", MB_OK);							}														if (SendMessage(hButton1 , BM_GETCHECK, 0, 0)==BST_CHECKED) {								conn_set_state(conngui,conn_state_destroy);								kickq = TRUE;							}														if ((messageq == TRUE)&&(kickq == TRUE)) {								strcat (selected_item,"has been kicked and Status has changed"); 																MessageBox(hwnd,selected_item,"UserKick & StatusChange", MB_OK);							}														if ((kickq == TRUE)&&(messageq == FALSE)) {								strcat (selected_item," has been kicked from the server");								MessageBox(hwnd,selected_item,"UserKick", MB_OK);							}														if ((kickq == FALSE)&&(messageq == TRUE)) {								strcat (selected_item,"'s Status has been changed");								MessageBox(hwnd,selected_item,"StatusChange", MB_OK);							}														selected_item[0] = 0;						}						break;					}			}			break;		case WM_CLOSE:			EndDialog(hwnd, IDC_EDITKICK);			break;		default:			return FALSE;	}	return TRUE;}#endif

⌨️ 快捷键说明

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