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

📄 editor.c

📁 Unreal irc 服务器源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
					SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_PASTE, (LPARAM)MAKELONG(FALSE,0));				SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_UNDO, (LPARAM)MAKELONG(FALSE,0));				wsprintf(szText, "Line: 1");				SetWindowText(hStatus, szText);			}			return TRUE;		}		case WM_WINDOWPOSCHANGING:		{			GetClientRect(hDlg, &rOld);			return FALSE;		}		case WM_SIZE:		{			DWORD new_width, new_height;			HWND hRich;			RECT rOldRich;			DWORD old_width, old_height;			DWORD old_rich_width, old_rich_height;			if (hDlg == hFind)				return FALSE;			new_width =  LOWORD(lParam);			new_height = HIWORD(lParam);			hRich  = GetDlgItem(hDlg, IDC_TEXT);			SendMessage(hStatus, WM_SIZE, 0, 0);			SendMessage(hTool, TB_AUTOSIZE, 0, 0);			old_width = rOld.right-rOld.left;			old_height = rOld.bottom-rOld.top;			new_width = new_width - old_width;			new_height = new_height - old_height;			GetWindowRect(hRich, &rOldRich);			old_rich_width = rOldRich.right-rOldRich.left;			old_rich_height = rOldRich.bottom-rOldRich.top;			SetWindowPos(hRich, NULL, 0, 0, old_rich_width+new_width, 				old_rich_height+new_height,				SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOZORDER);			bzero(&rOld, sizeof(RECT));			return TRUE;		} 		case WM_NOTIFY:			switch (((NMHDR *)lParam)->code) 			{				case EN_SELCHANGE: 				{					HWND hWnd = GetDlgItem(hDlg, IDC_TEXT);					DWORD start, end, currline;					static DWORD prevline = 0;					unsigned char buffer[512];					chars.cbSize = sizeof(CHARFORMAT2);					SendMessage(hWnd, EM_GETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);					if (chars.dwMask & CFM_BOLD && chars.dwEffects & CFE_BOLD)						SendMessage(hTool, TB_CHECKBUTTON, (WPARAM)IDC_BOLD, (LPARAM)MAKELONG(TRUE,0));					else						SendMessage(hTool, TB_CHECKBUTTON, (WPARAM)IDC_BOLD, (LPARAM)MAKELONG(FALSE,0));					if (chars.dwMask & CFM_UNDERLINE && chars.dwEffects & CFE_UNDERLINE)						SendMessage(hTool, TB_CHECKBUTTON, (WPARAM)IDC_UNDERLINE, (LPARAM)MAKELONG(TRUE,0));					else						SendMessage(hTool, TB_CHECKBUTTON, (WPARAM)IDC_UNDERLINE, (LPARAM)MAKELONG(FALSE,0));					SendMessage(hWnd, EM_GETSEL,(WPARAM)&start, (LPARAM)&end);					if (start == end) 					{						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_COPY, (LPARAM)MAKELONG(FALSE,0));						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_CUT, (LPARAM)MAKELONG(FALSE,0));					}					else 					{						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_COPY, (LPARAM)MAKELONG(TRUE,0));						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_CUT, (LPARAM)MAKELONG(TRUE,0));					}					if (SendMessage(hWnd, EM_CANUNDO, 0, 0)) 						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_UNDO, (LPARAM)MAKELONG(TRUE,0));					else						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_UNDO, (LPARAM)MAKELONG(FALSE,0));					if (SendMessage(hWnd, EM_CANREDO, 0, 0)) 						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_REDO, (LPARAM)MAKELONG(TRUE,0));					else						SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_REDO, (LPARAM)MAKELONG(FALSE,0));					currline = SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)-1, 0);					currline++;					if (currline != prevline) 					{						wsprintf(buffer, "Line: %d", currline);						SetWindowText(hStatus, buffer);						prevline = currline;					}				return TRUE;			}			case TTN_GETDISPINFO: 			{				LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT) lParam;				lpttt->hinst = NULL;				switch (lpttt->hdr.idFrom) 				{					case IDM_NEW:						strcpy(lpttt->szText, "New");						break;					case IDM_SAVE:						strcpy(lpttt->szText, "Save");						break;					case IDM_CUT:						strcpy(lpttt->szText, "Cut");						break;					case IDM_COPY:						strcpy(lpttt->szText, "Copy");						break;					case IDM_PASTE:						strcpy(lpttt->szText, "Paste");						break;					case IDM_UNDO:						strcpy(lpttt->szText, "Undo");						break;					case IDM_REDO:						strcpy(lpttt->szText, "Redo");						break;					case IDC_BOLD:						strcpy(lpttt->szText, "Bold");						break;					case IDC_UNDERLINE:						strcpy(lpttt->szText, "Underline");						break;					case IDC_COLOR:						strcpy(lpttt->szText, "Text Color");						break;					case IDC_BGCOLOR:						strcpy(lpttt->szText, "Background Color");						break;					case IDC_GOTO:						strcpy(lpttt->szText, "Goto");						break;					case IDC_FIND:						strcpy(lpttt->szText, "Find");						break;				}				return TRUE;			}			case NM_DBLCLK:				DialogBox(hInst, "GOTO", hDlg, (DLGPROC)GotoDLG);				return (TRUE);		}								return (TRUE);		case WM_COMMAND:			if (LOWORD(wParam) == IDC_BOLD) 			{				hWnd = GetDlgItem(hDlg, IDC_TEXT);				if (SendMessage(hTool, TB_ISBUTTONCHECKED, (WPARAM)IDC_BOLD, (LPARAM)0) != 0) 				{					chars.cbSize = sizeof(CHARFORMAT2);					chars.dwMask = CFM_BOLD;					chars.dwEffects = CFE_BOLD;					SendMessage(hWnd, EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);					SendMessage(hWnd, EM_HIDESELECTION, 0, 0);					SetFocus(hWnd);				}				else 				{					chars.cbSize = sizeof(CHARFORMAT2);					chars.dwMask = CFM_BOLD;					chars.dwEffects = 0;					SendMessage(hWnd, EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);					SendMessage(hWnd, EM_HIDESELECTION, 0, 0);					SetFocus(hWnd);				}				return TRUE;			}			else if (LOWORD(wParam) == IDC_UNDERLINE) 			{				hWnd = GetDlgItem(hDlg, IDC_TEXT);				if (SendMessage(hTool, TB_ISBUTTONCHECKED, (WPARAM)IDC_UNDERLINE, (LPARAM)0) != 0) 				{					chars.cbSize = sizeof(CHARFORMAT2);					chars.dwMask = CFM_UNDERLINETYPE;					chars.bUnderlineType = CFU_UNDERLINE;					SendMessage(hWnd, EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);					SendMessage(hWnd, EM_HIDESELECTION, 0, 0);					SetFocus(hWnd);				}				else 				{					chars.cbSize = sizeof(CHARFORMAT2);					chars.dwMask = CFM_UNDERLINETYPE;					chars.bUnderlineType = CFU_UNDERLINENONE;					SendMessage(hWnd, EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);					SendMessage(hWnd, EM_HIDESELECTION, 0, 0);					SetFocus(hWnd);				}				return TRUE;			}			if (LOWORD(wParam) == IDC_COLOR) 			{				DialogBoxParam(hInst, "Color", hDlg, (DLGPROC)ColorDLG, (LPARAM)WM_USER+10);				return 0;			}			if (LOWORD(wParam) == IDC_BGCOLOR)			{				DialogBoxParam(hInst, "Color", hDlg, (DLGPROC)ColorDLG, (LPARAM)WM_USER+11);				return 0;			}			if (LOWORD(wParam) == IDC_GOTO)			{				DialogBox(hInst, "GOTO", hDlg, (DLGPROC)GotoDLG);				return 0;			}			if (LOWORD(wParam) == IDC_FIND)			{				static FINDREPLACE fr;				bzero(&fr, sizeof(FINDREPLACE));				fr.lStructSize = sizeof(FINDREPLACE);				fr.hwndOwner = hDlg;				fr.lpstrFindWhat = findbuf;				fr.wFindWhatLen = 255;				hFind = FindText(&fr);				return 0;			}							hWnd = GetDlgItem(hDlg, IDC_TEXT);			if (LOWORD(wParam) == IDM_COPY) 			{				SendMessage(hWnd, WM_COPY, 0, 0);				return 0;			}			if (LOWORD(wParam) == IDM_SELECTALL) 			{				SendMessage(hWnd, EM_SETSEL, 0, -1);				return 0;			}			if (LOWORD(wParam) == IDM_PASTE) 			{				SendMessage(hWnd, WM_PASTE, 0, 0);				return 0;			}			if (LOWORD(wParam) == IDM_CUT) 			{				SendMessage(hWnd, WM_CUT, 0, 0);				return 0;			}			if (LOWORD(wParam) == IDM_UNDO) 			{				SendMessage(hWnd, EM_UNDO, 0, 0);				return 0;			}			if (LOWORD(wParam) == IDM_REDO) 			{				SendMessage(hWnd, EM_REDO, 0, 0);				return 0;			}			if (LOWORD(wParam) == IDM_DELETE) 			{				SendMessage(hWnd, WM_CLEAR, 0, 0);				return 0;			}			if (LOWORD(wParam) == IDM_SAVE) 			{				int fd;				EDITSTREAM edit;				OPENFILENAME lpopen;				if (!file) 				{					unsigned char path[MAX_PATH];					path[0] = '\0';					bzero(&lpopen, sizeof(OPENFILENAME));					lpopen.lStructSize = sizeof(OPENFILENAME);					lpopen.hwndOwner = hDlg;					lpopen.lpstrFilter = NULL;					lpopen.lpstrCustomFilter = NULL;					lpopen.nFilterIndex = 0;					lpopen.lpstrFile = path;					lpopen.nMaxFile = MAX_PATH;					lpopen.lpstrFileTitle = NULL;					lpopen.lpstrInitialDir = DPATH;					lpopen.lpstrTitle = NULL;					lpopen.Flags = (OFN_ENABLESIZING|OFN_NONETWORKBUTTON|							OFN_OVERWRITEPROMPT);					if (GetSaveFileName(&lpopen))						file = path;					else						break;				}				fd = open(file, _O_TRUNC|_O_CREAT|_O_WRONLY|_O_BINARY,_S_IWRITE);				edit.dwCookie = 0;				edit.pfnCallback = BufferIt;				SendMessage(GetDlgItem(hDlg, IDC_TEXT), EM_STREAMOUT, (WPARAM)SF_RTF|SFF_PLAINRTF, (LPARAM)&edit);				RTFToIRC(fd, RTFBuf, strlen(RTFBuf));				free(RTFBuf);				RTFBuf = NULL;				SendMessage(GetDlgItem(hDlg, IDC_TEXT), EM_SETMODIFY, (WPARAM)FALSE, 0);					return 0;			}			if (LOWORD(wParam) == IDM_NEW) 			{				unsigned char text[1024];				BOOL newfile = FALSE;				int ans;				if (SendMessage(GetDlgItem(hDlg, IDC_TEXT), EM_GETMODIFY, 0, 0) != 0) 				{					sprintf(text, "The text in the %s file has changed.\r\n\r\nDo you want to save the changes?", file ? file : "new");					ans = MessageBox(hDlg, text, "UnrealIRCd", MB_YESNOCANCEL|MB_ICONWARNING);					if (ans == IDNO)						newfile = TRUE;					if (ans == IDCANCEL)						return TRUE;					if (ans == IDYES) 					{						SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDM_SAVE,0), 0);						newfile = TRUE;					}				}				else					newfile = TRUE;				if (newfile == TRUE) 				{					unsigned char szText[256];					file = NULL;					strcpy(szText, "UnrealIRCd Editor - New File");					SetWindowText(hDlg, szText);					SetWindowText(GetDlgItem(hDlg, IDC_TEXT), NULL);				}				break;			}			break;		case WM_USER+10: 		{			HWND hWnd = GetDlgItem(hDlg, IDC_TEXT);			EndDialog((HWND)lParam, TRUE);			chars.cbSize = sizeof(CHARFORMAT2);			chars.dwMask = CFM_COLOR;			chars.crTextColor = (COLORREF)wParam;			SendMessage(hWnd, EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);			SendMessage(hWnd, EM_HIDESELECTION, 0, 0);			SetFocus(hWnd);			break;		}		case WM_USER+11: 		{			HWND hWnd = GetDlgItem(hDlg, IDC_TEXT);			EndDialog((HWND)lParam, TRUE);			chars.cbSize = sizeof(CHARFORMAT2);			chars.dwMask = CFM_BACKCOLOR;			chars.crBackColor = (COLORREF)wParam;			SendMessage(hWnd, EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&chars);			SendMessage(hWnd, EM_HIDESELECTION, 0, 0);			SetFocus(hWnd);			break;		}		case WM_CHANGECBCHAIN:			if ((HWND)wParam == hClip)				hClip = (HWND)lParam;			else				SendMessage(hClip, WM_CHANGECBCHAIN, wParam, lParam);			break;		case WM_DRAWCLIPBOARD:			if (SendMessage(GetDlgItem(hDlg, IDC_TEXT), EM_CANPASTE, 0, 0)) 				SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_PASTE, (LPARAM)MAKELONG(TRUE,0));			else				SendMessage(hTool, TB_ENABLEBUTTON, (WPARAM)IDM_PASTE, (LPARAM)MAKELONG(FALSE,0));			SendMessage(hClip, WM_DRAWCLIPBOARD, wParam, lParam);			break;		case WM_CLOSE: 		{			unsigned char text[256];			int ans;			if (SendMessage(GetDlgItem(hDlg, IDC_TEXT), EM_GETMODIFY, 0, 0) != 0) 			{				sprintf(text, "The text in the %s file has changed.\r\n\r\nDo you want to save the changes?", file ? file : "new");				ans = MessageBox(hDlg, text, "UnrealIRCd", MB_YESNOCANCEL|MB_ICONWARNING);				if (ans == IDNO)					EndDialog(hDlg, TRUE);				if (ans == IDCANCEL)					return TRUE;				if (ans == IDYES) 				{					SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDM_SAVE,0), 0);					EndDialog(hDlg, TRUE);				}			}			else				EndDialog(hDlg, TRUE);			break;		}		case WM_DESTROY:			ChangeClipboardChain(hDlg, hClip);			break;	}	return FALSE;}

⌨️ 快捷键说明

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