📄 main.cpp
字号:
#include <windows.h>
#include "main.h"
/* Declare WindowsProcedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the classname into a global variable */
char Nombre[] = " _ ";
HINSTANCE hThisInstance;
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG ok; /* Here messages to the application is saved */
WNDCLASSEX win; /* Datastructure for the windowclass */
HMENU Mu; /* Handle of the menu */
/* The Window structure */
win.hInstance = hThisInstance;
win.lpszClassName = Nombre;
win.lpfnWndProc = WindowProcedure; /* This function is called by windows */
win.style = CS_DBLCLKS; /* Ctach double-clicks */
win.cbSize = sizeof(WNDCLASSEX);
/* Use default icon and mousepointer */
win.hIcon = LoadIcon(NULL, IDI_APPLICATION);
win.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
win.hCursor = LoadCursor(NULL, IDC_ARROW);
win.lpszMenuName = NULL; /* No menu */
win.cbClsExtra = 0; /* No extra bytes after the window class */
win.cbWndExtra = 0; /* structure or the window instance */
/* Use lightgray as the background of the window */
win.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
/* Register the window class, if fail quit the program */
if(!RegisterClassEx(&win)) return 0;
/* The class is registered, lets create the program*/
hwnd = CreateWindowEx(
0, /* Extended possibilites for variation */
Nombre, /* Classname */
"x Windows Example", /* Title Text */
WS_OVERLAPPEDWINDOW, /* defaultwindow */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window end up on the screen */
404, /* The programs width */
225, /* and height in pixels */
HWND_DESKTOP, /* The window is a childwindow to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
ShowWindow(hwnd, nFunsterStil); // Make the window visible on the screen
Mu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
SetMenu(hwnd, Mu);
while(GetMessage(&ok, NULL, 0, 0)) // Run the nessageloop. It will run until GetMessage( ) returns 0
{
DispatchMessage(&ok); // Send message to WindowProcedure
}
return ok.wParam; // The program returvalue is 0 - The value that PostQuitMessage( ) gave
}
// This function is called by the Windowsfunction DispatchMessage( )
LRESULT CALLBACK WindowProcedure(HWND a1, UINT a2, WPARAM a3, LPARAM a4)
{
switch (a2)
{
case WM_COMMAND:
switch( a3 )
{
case IDM_FILENEW:
case IDM_FILEOPEN:
case IDM_FILESAVE:
case IDM_FILESAVEAS:
case IDM_FILEPRINT:
case IDM_FILEPAGESETUP:
case IDM_FILEPRINTSETUP:
case IDM_EDITUNDO:
case IDM_EDITCUT:
case IDM_EDITCOPY:
case IDM_EDITPASTE:
case IDM_EDITDELETE:
MessageBox( a1, (LPSTR) "Function Not Yet Implemented.",
(LPSTR) Nombre,
MB_ICONINFORMATION | MB_OK );
return 0;
case IDM_HELPCONTENTS:
WinHelp( a1, (LPSTR) "HELPFILE*HLP",
HELP_CONTENTS, 0L );
return 0;
case IDM_HELPSEARCH:
WinHelp( a1, (LPSTR) "HELPFILE*HLP",
HELP_PARTIALKEY, 0L );
return 0;
case IDM_HELPHELP:
WinHelp( a1, (LPSTR) "HELPFILE*HLP",
HELP_HELPONHELP, 0L );
return 0;
case IDM_FILEEXIT:
SendMessage( a1, WM_CLOSE, 0, 0L );
return 0;
case IDM_HELPABOUT:
MessageBox (NULL, "About..." , "Windows example version 0.01", 1);
return 0;
}
break;
case WM_CLOSE:
DestroyWindow( a1 );
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
break;
default: //for messages that we don't deal with
return DefWindowProc(a1, a2, a3, a4);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -