当前位置:网站首页>"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
边栏推荐
- MySQL installation pit
- xutils3修改了我提报的一个bug,开心
- Improvement of ref and struct in C 11
- Blazor University (12) - component lifecycle
- [MySQL] left function | right function
- Top 9 task management system in 2022
- 2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
- 可以接收多種數據類型參數——可變參數
- Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
- When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
猜你喜欢

C WPF UI framework mahapps switching theme
![[MySQL] left function | right function](/img/26/82e0f2280de011636c26931a74e749.png)
[MySQL] left function | right function

《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案

Optimization of especially slow startup in idea debugging mode

Ide-idea-problem

Seminar playback video: how to improve Jenkins' ability to become a real Devops platform

Comprehensive calculation of employee information

New ORM framework -- Introduction to beetlsql

MySql关键字GROUP_CONCAT,组合连接查询

Log4net is in Net core usage
随机推荐
WinForm allows the form form to switch between the front and active states
Mysql database design specification
《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案
Flink real-time data warehouse project - Design and implementation of DWS layer
IOTOS物联中台对接海康安防平台(iSecure Center)门禁系统
socket编程 send()与 recv()函数详解
Yes Redis using distributed cache in NE6 webapi
MySql分组查询规则
Optimization of especially slow startup in idea debugging mode
超好用的Excel异步导出功能
Eight elder brothers chronicle [4]
Experiment 5 components and event handling
Explanation keyword of MySQL
File upload vulnerability summary and upload labs shooting range documentary
Using jsonserialize to realize data type conversion gracefully
ASP. Net 6 middleware series - conditional Middleware
be based on. NETCORE development blog project starblog - (2) environment preparation and creation project
Supersocket is Use in net5 - startup
手机连接电脑后,QT的QDIR怎么读取手机文件路径
Idempotency practice operation, explaining idempotency based on business