📄 showmsg.cpp
字号:
{0x0213, "WM_NEXTMENU"},
{0x0214, "WM_SIZING"},
{0x0215, "WM_CAPTURECHANGED"},
{0x0216, "WM_MOVING"},
{0x0217, "WM_DEVICEBROADCAST"},
{0x0218, "WM_POWERBROADCAST"},
{0x0219, "WM_DEVICECHANGE"},
{0x0220, "WM_MDICREATE"},
{0x0221, "WM_MDIDESTROY"},
{0x0222, "WM_MDIACTIVATE"},
{0x0223, "WM_MDIRESTORE"},
{0x0224, "WM_MDINEXT"},
{0x0225, "WM_MDIMAXIMIZE"},
{0x0226, "WM_MDITILE"},
{0x0227, "WM_MDICASCADE"},
{0x0228, "WM_MDIICONARRANGE"},
{0x0229, "WM_MDIGETACTIVE"},
{0x022A, "WM_DROPOBJECT"},
{0x022B, "WM_QUERYDROPOBJECT"},
{0x022C, "WM_BEGINDRAG"},
{0x022D, "WM_DRAGLOOP"},
{0x022E, "WM_DRAGSELECT"},
{0x022F, "WM_DRAGMOVE"},
{0x0230, "WM_MDISETMENU"},
{0x0231, "WM_ENTERSIZEMOVE"},
{0x0232, "WM_EXITSIZEMOVE"},
{0x0233, "WM_DROPFILES"},
{0x0234, "WM_MDIREFRESHMENU"},
{0x0281, "WM_IME_SETCONTEXT"},
{0x0282, "WM_IME_NOTIFY"},
{0x0283, "WM_IME_CONTROL"},
{0x0284, "WM_IME_COMPOSITIONFULL"},
{0x0285, "WM_IME_SELECT"},
{0x0286, "WM_IME_CHAR"},
{0x0290, "WM_IME_KEYDOWN"},
{0x0291, "WM_IME_KEYUP"},
{0x0300, "WM_CUT"},
{0x0301, "WM_COPY"},
{0x0302, "WM_PASTE"},
{0x0303, "WM_CLEAR"},
{0x0304, "WM_UNDO"},
{0x0305, "WM_RENDERFORMAT"},
{0x0306, "WM_RENDERALLFORMATS"},
{0x0307, "WM_DESTROYCLIPBOARD"},
{0x0308, "WM_DRAWCLIPBOARD"},
{0x0309, "WM_PAINTCLIPBOARD"},
{0x030A, "WM_VSCROLLCLIPBOARD"},
{0x030B, "WM_SIZECLIPBOARD"},
{0x030C, "WM_ASKCBFORMATNAME"},
{0x030D, "WM_CHANGECBCHAIN"},
{0x030E, "WM_HSCROLLCLIPBOARD"},
{0x030F, "WM_QUERYNEWPALETTE"},
{0x0310, "WM_PALETTEISCHANGING"},
{0x0311, "WM_PALETTECHANGED"},
{0x0312, "WM_HOTKEY"},
{0x0317, "WM_PRINT"},
{0x0318, "WM_PRINTCLIENT"},
{0x0360, "WM_QUERYAFXWNDPROC"},
{0x0361, "WM_SIZEPARENT"},
{0x0362, "WM_SETMESSAGESTRING"},
{0x0363, "WM_IDLEUPDATECMDUI"},
{0x0364, "WM_INITIALUPDATE"},
{0x0365, "WM_COMMANDHELP"},
{0x0366, "WM_HELPHITTEST"},
{0x0367, "WM_EXITHELPMODE"},
{0x0368, "WM_RECALCPARENT"},
{0x0369, "WM_SIZECHILD"},
{0x036A, "WM_KICKIDLE"},
{0x036B, "WM_QUERYCENTERWND"},
{0x036C, "WM_DISABLEMODAL"},
{0x036D, "WM_FLOATSTATUS"},
{0x036E, "WM_ACTIVATETOPLEVEL"},
{0x036F, "WM_QUERY3DCONTROLS"},
{0x03E0, "WM_DDE_FIRST"},
{0x03E0, "WM_DDE_INITIATE"},
{0x03E1, "WM_DDE_TERMINATE"},
{0x03E2, "WM_DDE_ADVISE"},
{0x03E3, "WM_DDE_UNADVISE"},
{0x03E4, "WM_DDE_ACK"},
{0x03E5, "WM_DDE_DATA"},
{0x03E6, "WM_DDE_REQUEST"},
{0x03E7, "WM_DDE_POKE"},
{0x03E8, "WM_DDE_LAST"},
{0x03E8, "WM_DDE_EXECUTE"}
};
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_SHOWMSG, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
//open NOTEPAD.EXE to display Windows message
char NOTEPADPath[MAX_PATH];
memset(NOTEPADPath,0,sizeof(NOTEPADPath));
GetWindowsDirectory(NOTEPADPath,MAX_PATH);
strcat(NOTEPADPath,"\\NOTEPAD.EXE");
WinExec(NOTEPADPath,SW_SHOWNORMAL);
HWND hNOTEPADWND = NULL;
POINT NotePadPoint = {0};
NotePadPoint.x = 20;
NotePadPoint.y = 20;
hNOTEPADWND = FindWindow("NOTEPAD",NULL);
if(hNOTEPADWND == NULL)
{
MessageBox(NULL,"无法找到记事本!","error",MB_OK);
}
hSubOfNOTEPADWND = ChildWindowFromPoint(hNOTEPADWND,NotePadPoint);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SHOWMSG);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SHOWMSG);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCTSTR)IDC_SHOWMSG;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 200, 200, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
//Search message
MSGList MSGListtemp = {0};
memset(MSGListtemp.MSG,0,sizeof(MSGListtemp.MSG));
MSGListtemp.MSGNum = message;
PMSGList pMSGList = msglist;
for(int i = 0;i<=0x03E8;++i)
{
if(pMSGList->MSGNum == MSGListtemp.MSGNum)
{
strcpy(MSGListtemp.MSG,pMSGList->MSG);
break;
}
pMSGList++;
}
for(int j = 0;j<=50;++j)
{
int Char_int = 0;
Char_int = MSGListtemp.MSG[j];
if(Char_int)
{
PostMessage(hSubOfNOTEPADWND,WM_CHAR,(WPARAM)Char_int,1);
}
else
{
PostMessage(hSubOfNOTEPADWND,WM_CHAR,'\n',1);
break;
}
}
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -