ctrl键+26个英文字母,分别是什么功能

Ctrl + A:全选(Select All)
Ctrl + B:将选中的文本加粗(Bold)
Ctrl + C:复制选中的文本或对象(Copy)
Ctrl + D:删除光标所在行或选中的内容(Delete)
Ctrl + E:将光标移到搜索框(Search Box)
Ctrl + F:在当前页面或文档中查找指定内容(Find)
Ctrl + G:在当前页面或文档中查找下一个匹配项(Find Next)
Ctrl + H:替换指定内容(Replace)
Ctrl + I:将选中的文本斜体显示(Italic)
Ctrl + J:显示下载列表(Downloads)
Ctrl + K:插入超链接(Insert Hyperlink)
Ctrl + L:选择地址栏(Location Bar)
Ctrl + M:发送邮件(Send Mail)
Ctrl + N:新建窗口或文档(New Window/Document)
Ctrl + O:打开文件(Open File)
Ctrl + P:打印当前页面或文档(Print)
Ctrl + Q:退出程序(Quit)
Ctrl + R:刷新页面或文档(Refresh)
Ctrl + S:保存当前页面或文档(Save)
Ctrl + T:新建标签页(New Tab)
Ctrl + U:查看网页源代码(View Page Source)
Ctrl + V:粘贴剪贴板中的内容(Paste)
Ctrl + W:关闭当前标签页或窗口(Close Tab/Window)
Ctrl + X:剪切选中的文本或对象(Cut)
Ctrl + Y:恢复上一步操作(Redo)
Ctrl + Z:撤销上一步操作(Undo)

下面是一个简单的英文文本编辑器的代码,其中实现了基本功能和部分附加功能Ctrl+A实现选中全部文字并变蓝色,Ctrl+C和Ctrl+V实现复制和粘贴功能Ctrl+S实现保存到文件,R、G、B分别实现文字颜色的变化,方向实现光标的移动。 ```cpp #include <windows.h> #include <string> #include <fstream> LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); const int ID_EDIT = 1; bool ctrlPressed = false; bool rPressed = false; bool gPressed = false; bool bPressed = false; COLORREF textColor = RGB(0, 0, 0); COLORREF bgColor = RGB(255, 255, 255); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { const char* CLASS_NAME = "SimpleTextEditor"; WNDCLASS wc = {}; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.lpszClassName = CLASS_NAME; RegisterClass(&wc); HWND hWnd = CreateWindowEx( 0, CLASS_NAME, "Simple Text Editor", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr, hInstance, nullptr ); MSG msg = {}; while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hEdit; switch (message) { case WM_CREATE: hEdit = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 0, 0, 0, 0, hWnd, (HMENU)ID_EDIT, GetModuleHandle(nullptr), nullptr ); break; case WM_SIZE: MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); break; case WM_COMMAND: if (LOWORD(wParam) == ID_EDIT) { if (HIWORD(wParam) == EN_UPDATE) { // text has been updated } } break; case WM_KEYDOWN: if (wParam == VK_CONTROL) { ctrlPressed = true; } else if (ctrlPressed) { if (wParam == 'A') { SendMessage(hEdit, EM_SETSEL, 0, -1); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, RGB(0, 0, 255)); } else if (wParam == 'C') { SendMessage(hEdit, WM_COPY, 0, 0); } else if (wParam == 'V') { SendMessage(hEdit, WM_PASTE, 0, 0); } else if (wParam == 'S') { char buffer[MAX_PATH]; OPENFILENAME ofn = {}; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFile = buffer; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_OVERWRITEPROMPT; if (GetSaveFileName(&ofn)) { std::ofstream file(ofn.lpstrFile); int length = GetWindowTextLength(hEdit); char* text = new char[length + 1]; GetWindowText(hEdit, text, length + 1); file << text; delete[] text; } } else if (wParam == 'R') { rPressed = true; gPressed = false; bPressed = false; textColor = RGB(255, 0, 0); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, textColor); } else if (wParam == 'G') { rPressed = false; gPressed = true; bPressed = false; textColor = RGB(0, 255, 0); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, textColor); } else if (wParam == 'B') { rPressed = false; gPressed = false; bPressed = true; textColor = RGB(0, 0, 255); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, textColor); } } else if (wParam == VK_LEFT) { int pos = SendMessage(hEdit, EM_GETSEL, 0, 0); SendMessage(hEdit, EM_SETSEL, pos - 1, pos - 1); } else if (wParam == VK_RIGHT) { int pos = SendMessage(hEdit, EM_GETSEL, 0, 0); SendMessage(hEdit, EM_SETSEL, pos + 1, pos + 1); } else if (wParam == VK_UP) { int line = SendMessage(hEdit, EM_LINEFROMCHAR, -1, 0); int pos = SendMessage(hEdit, EM_LINEINDEX, line - 1, 0); SendMessage(hEdit, EM_SETSEL, pos, pos); } else if (wParam == VK_DOWN) { int line = SendMessage(hEdit, EM_LINEFROMCHAR, -1, 0); int pos = SendMessage(hEdit, EM_LINEINDEX, line + 1, 0); SendMessage(hEdit, EM_SETSEL, pos, pos); } break; case WM_KEYUP: if (wParam == VK_CONTROL) { ctrlPressed = false; } else if (wParam == 'R') { if (!gPressed && !bPressed) { textColor = RGB(0, 0, 0); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, textColor); } rPressed = false; } else if (wParam == 'G') { if (!rPressed && !bPressed) { textColor = RGB(0, 0, 0); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, textColor); } gPressed = false; } else if (wParam == 'B') { if (!rPressed && !gPressed) { textColor = RGB(0, 0, 0); SendMessage(hEdit, EM_SETBKGNDCOLOR, 0, bgColor); SendMessage(hEdit, EM_SETTEXTCOLOR, 0, textColor); } bPressed = false; } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值