📄 synplot.cpp
字号:
// SynPlot.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include "SynPlot.h"
// Mesage 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;
}
HINSTANCE g_instance;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Get the plot object that was saved when the window was created.
CPlot *pThis = (CPlot *) GetWindowLong(hWnd, GWL_USERDATA);
switch (message)
{
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
int wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(g_instance, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
break;
case WM_CREATE:
{
// Save away the clock object passed to CreateWindow.
CREATESTRUCT *pCreate = (CREATESTRUCT *) lParam;
SetWindowLong(hWnd, GWL_USERDATA,
(long) pCreate->lpCreateParams);
pThis = (CPlot *) pCreate->lpCreateParams;
}
// If plot initialization fails, exit.
if (!pThis->OnCreate(hWnd))
DestroyWindow(hWnd);
// Register for timer messages once a second.
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);
pThis->OnPaint(hdc);
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
ATOM RegisterWindowClass(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_SYNPLOT);
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_SYNPLOT;
wcex.lpszClassName = "SYNPLOT";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
// Create the plot object.
CPlot plot(hInstance);
// Initialize global stuff
RegisterWindowClass(hInstance);
g_instance = hInstance;
TCHAR szTitle[MAX_PATH];
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_PATH);
HWND hWnd = CreateWindow("SYNPLOT", szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, 0, 0, hInstance, &plot);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
HACCEL hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SYNPLOT);
// Main message loop:
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -