当前位置:网站首页>"Visual programming" test paper
"Visual programming" test paper
2022-04-23 03:22:00 【Tang Encheng_ hhhc】
Please use API Function programming , Requirements are as follows :
1. The name of the project document is ” Student number _ full name _ In class examination ”, All file names in the project file are “ Student number _ full name _ In class examination ”( Include .cpp,.rc,.h Wait for the documents ), Otherwise, in accordance with the “ Unfinished task ” Handle (10 branch )
2. Display a WINDOWS window , The title of the window is “ Student number _ full name _ In class examination ”, for example “2018620101_ Zhang San _ In class examination ”, The window shall not be blocked when the demo is recorded VC6.0 The file list on the upper left side of the window , Otherwise, it will be treated as unfinished task .(20 branch )
3. Set the cursor to the first word of the last name in your first name , Blue font is required , Red background .(10 branch ).
4. Set your name to the last word in the icon , Green font and white background are required (10 branch )
5. Display a set of graphics on the left side of the window and fill the grid , Here's the picture (10 branch )
6. A red square is displayed on the right half of the window, as shown in the figure below (10 branch )
7. Create a menu , There is a menu item “ file ”,“ file ” The menu item contains “ establish ”、 “ Delete ”、“ sign out ” Equivalency . choice “ establish ” Option, a menu is created dynamically “ edit ”, The “ edit ” The menu item contains “ mapping ” Options , meanwhile “ establish ” Option becomes unavailable . choice “ Delete ” Option , Then delete the menu item “ edit ”, meanwhile “ Delete ” Option becomes unavailable . choice “ sign out ” Option , Exit procedure (20 branch )
choice “ mapping ” Option , Then the lower figure... Is displayed in the middle of the window ( On the next page ), Requirement No 5, The first 6 The display of the question cannot disappear , Otherwise, the question will not be scored .(10 branch )
The following is the source code of the main file
#include <windows.h>
#include "2000000000_XXX_ In class examination .h"
// Global variables 、 Function declaration
HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
static int Paint = 0;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HACCEL hAccel;
WNDCLASSEX wcex;
HWND hWnd;
MSG msg;
TCHAR lpszMenuName[] = L"Menu";
TCHAR lpszClassName[] = L" Modal dialog ";
TCHAR lpszTitle[] = L"20203099_XXX_ In class examination ";
//------------------------------ The following initialization window classes ------------------------------
wcex.cbSize = sizeof(WNDCLASSEX); // The size of the window class
wcex.style = 0; // The default window type is
wcex.lpfnWndProc = WndProc; // The window processing function is WndProc
wcex.cbClsExtra = 0; // Window class has no extension
wcex.cbWndExtra = 0; // The window instance has no extension
wcex.hInstance = hInstance; // Current instance handle
// wcex.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDR_MAINFRAME)); // The icon of the window is the default icon
wcex.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursorFromFile(L"20000099_XXX_ In class examination .cur"); // The window uses the arrow cursor
// wcex.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
wcex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // The window background is white
wcex.lpszMenuName = lpszMenuName; // There is no menu in the window
wcex.lpszClassName = lpszClassName; // The window class name is “ Window example ”
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDR_MAINFRAME)); // The small icon of the window is the default icon
//wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
//------------------------------ The following window class registration ------------------------------
if (!RegisterClassEx(&wcex)) // Warn if registration fails
{
MessageBox(NULL, L" Window class registration failed !", L" Window registration ", NULL);
return 1;
}
//------------------------------ Create the following window ------------------------------
hWnd = CreateWindow(
lpszClassName, // Window class name
lpszTitle, // The title name of the window instance
WS_OVERLAPPEDWINDOW, // The style of the window
CW_USEDEFAULT, CW_USEDEFAULT, // The coordinates of the lower left corner of the window are the default values
CW_USEDEFAULT, CW_USEDEFAULT, // The height and width of the window are the default values
NULL, // This window has no parent window
NULL, // This window has no main menu
hInstance, // Create the current handle of this window application
NULL // Do not use this value
);
if (!hWnd) // Warn if window creation fails
{
MessageBox(NULL, L" Failed to create window !", L" create a window ", NULL);
return 1;
}
// Display window
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
hInst = hInstance;
hAccel = LoadAccelerators(hInst, lpszMenuName);
// Draw user area
while (GetMessage(&msg, NULL, 0, 0)) // Message loop
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(int)msg.wParam; // When the program terminates, the information is returned to the system
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HPEN hP;// paint brush
HBRUSH hB;// A brush
HDC hDC; // Define a handle to the device context
PAINTSTRUCT PtStr; // Defines a structure variable that points to the drawing information
HMENU Menu;// Main menu handle
static HMENU hadmenu;// New menu handle
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDM_EXIT://" sign out "
SendMessage(hwnd, WM_DESTROY, 0, 0); break;
case IDM_PAINT://“ mapping ”
Paint = 1;
InvalidateRect(hwnd, NULL, 1);
break;
case IDM_OPEN://“ establish ”
Menu = GetMenu(hwnd);
EnableMenuItem(Menu, IDM_OPEN, MF_BYCOMMAND | MF_GRAYED);//“ establish ” Selection not available
// New pop-up menu
hadmenu = CreateMenu();
AppendMenu(hadmenu, MF_POPUP, IDM_PAINT, L" mapping ");
InsertMenu(Menu, 3, MF_POPUP | MF_BYPOSITION, (UINT)hadmenu, L" edit ");
DrawMenuBar(hwnd);
break;
case IDM_DELETE://“ Delete ”
Menu = GetMenu(hwnd);
DeleteMenu(Menu, (UINT)hadmenu, MF_BYCOMMAND);// Delete “ edit ” Options
EnableMenuItem(Menu, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED);//“ Delete ” Unavailable
DrawMenuBar(hwnd);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_PAINT: // Handle redraw messages
hDC = BeginPaint(hwnd, &PtStr); // Start painting
SetMapMode(hDC, MM_TEXT);
if (Paint == 1)// Click on “ mapping ”
{
// Draw a rounded rectangle
hP = CreatePen(PS_DASHDOT, 2, RGB(0, 0, 0));
SelectObject(hDC, hP);
hB = CreateHatchBrush(HS_CROSS, RGB(255, 0, 0));
RoundRect(hDC, 400, 40, 500, 160, 10, 10);
// Black fill brush draws ellipses
hB = (HBRUSH)GetStockObject(BLACK_BRUSH);
SelectObject(hDC, hB);
Ellipse(hDC, 400, 50, 500, 150);
}
// Draw a red rectangle on the right half
hB = (HBRUSH)GetStockObject(DC_BRUSH);
SetDCBrushColor(hDC, RGB(225, 0, 0));
SelectObject(hDC, hB);
Rectangle(hDC, 700, 100, 780, 180);
// Draw the left half of the mesh fill
hB = CreateHatchBrush(HS_CROSS, RGB(255, 0, 0));
SelectObject(hDC, hB);
RoundRect(hDC, 120, 10, 200, 70, 10, 10);
Pie(hDC, 120, 70, 200, 160, 150, 70, 170, 70);
Rectangle(hDC, 120, 160, 200, 220);
// Blue stroke
hP = CreatePen(PS_DASHDOT, 2, RGB(0, 30, 250));
SelectObject(hDC, hP);
RoundRect(hDC, 120, 10, 200, 70, 10, 10);
Pie(hDC, 120, 70, 200, 160, 150, 70, 170, 70);
Rectangle(hDC, 120, 160, 200, 220);
// Delete brush brush
DeleteObject(hB);
DeleteObject(hP);
EndPaint(hwnd, &PtStr);
return 0;
default: return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
BOOL CALLBACK DlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
EndDialog(hdlg, 0);
break;
}
break;
case WM_CLOSE:
EndDialog(hdlg, 0);
break;
}
return 0;
}
The following is the code to add the resource file
#include <windows.h>
#include "200000000_XXX_ In class examination .h"
Menu MENU
{
POPUP " file "
{
MENUITEM " establish ", IDM_OPEN
MENUITEM SEPARATOR
MENUITEM " Delete ", IDM_DELETE
MENUITEM SEPARATOR
MENUITEM " sign out ", IDM_EXIT
}
}
Menu ACCELERATORS
{
"^O", IDM_OPEN
"^S", IDM_DELETE
}
IDR_MAINFRAME ICON "2020000009_XXX_ In class examination .ico"
Add code to header file
#define IDM_OPEN 10
#define IDM_PAINT 15
#define IDM_EXIT 17
#define IDR_MAINFRAME 128
#define IDM_DELETE 30
Because the screenshot cannot be taken, the mouse cursor , And menu options , Send pictures by mobile phone , It's a little fuzzy
Examination experience :
The class is finally over ! Learn all the way , I just found that my self-study ability is still good , The teacher didn't really help , Instead, there are many things ( Subjective evaluation doesn't care ). In the examination room, I didn't complete all the functions , There are still many problems . But I found that most of the problems are the fault of details ,
版权声明
本文为[Tang Encheng_ hhhc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621319812.html
边栏推荐
- Do you really understand hashcode and equals???
- Using swagger in. Net5
- Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
- Queue storage and circular queue
- socket编程 send()与 recv()函数详解
- ThreadLocal test multithreaded variable instance
- Improvement of ref and struct in C 11
- Optimization of especially slow startup in idea debugging mode
- Top ten project management software similar to JIRA
- QT learning summary
猜你喜欢
Comprehensive calculation of employee information
. net 5 Web custom middleware implementation returns the default picture
Aspnetcore configuration multi environment log4net configuration file
MySql关键字GROUP_CONCAT,组合连接查询
【无标题】
超好用的【通用Excel导入功能】
A set of combination boxing to create an idea eye protection scheme
《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
一套组合拳,打造一款 IDEA 护眼方案
随机推荐
Mysql database, inconsistent index character set, slow SQL query, interface timeout
Establishing and traversing binary tree
Generate QR code through zxing
数据库表中不建索引,在插入数据时,通过sql语句防止重复添加(转载)
Web Course Design - his system
Huawei mobile ADB devices connection device is empty
Queue storage and circular queue
Téléchargement en vrac de fichiers - téléchargement après compression
[MySQL] left function | right function
Mysql database design specification
The most understandable life cycle of dependency injection
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
二进制文件版本控制工具选择难?看完这篇你会找到答案
Preview of converting doc and PDF to SWF file
Docker拉取mysql并连接
Find the number of leaf nodes of binary tree
2022G2电站锅炉司炉考试题库及在线模拟考试
Five tips for cross-border e-commerce in 2022
[MySQL] left Function | Right Function