当前位置:网站首页>使用C语言代码实现工厂端LCD RGB的测试程序
使用C语言代码实现工厂端LCD RGB的测试程序
2022-06-12 09:20:00 【Tody Guo】
如下代码使用CreateWindow实现窗口的最大无边框及最前代码,可以编译成32位或64位的程序均可。不用担心无法编译版本的问题。
#include <windows.h>
int i = 0;
/* This is where all the input to the window goes to */
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
HDC hdc; // handle to a device context
switch (Message) {
/* Upon destruction, tell the main thread to stop */
case WM_DESTROY: {
PostQuitMessage(0);
break;
}
case WM_LBUTTONDOWN:
case WM_KEYDOWN:
{
i++;
RECT rect;
hdc = GetDC(hwnd);
GetClientRect(hwnd, &rect);
switch (i) {
case 1:
FillRect(hdc, &rect, CreateSolidBrush(RGB(255, 0, 0)));
break;
case 2:
FillRect(hdc, &rect, CreateSolidBrush(RGB(0, 255, 0)));
break;
case 3:
FillRect(hdc, &rect, CreateSolidBrush(RGB(0, 0, 255)));
break;
case 4:
FillRect(hdc, &rect, CreateSolidBrush(RGB(255, 255, 255)));
break;
case 5:
ReleaseDC(hwnd, hdc);
PostQuitMessage(0);
break;
}
// release the dc back
ReleaseDC(hwnd, hdc);
}
/* All other messages (a lot of them) are processed using default procedures */
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
/* The 'main' function of Win32 GUI programs: this is where execution starts */
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wc; /* A properties struct of our window */
HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */
MSG msg; /* A temporary location for all messages */
/* zero out the struct and set the stuff we want to modify */
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc; /* This is where we will send messages to */
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
/* White, COLOR_WINDOW is just a #define for a system color, try Ctrl+Clicking it */
//wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
wc.lpszClassName = L"WindowClass";
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* Load a standard icon */
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* use the name "A" to use the project icon */
if (!RegisterClassEx(&wc)) {
MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
L"WindowClass",
L"LCD RGB Test",
WS_VISIBLE | WS_POPUP | WS_MAXIMIZE | WS_THICKFRAME | WS_EX_TOPMOST,
0, /* x */
0, /* y */
1920, /* width */
1080, /* height */
NULL, NULL, hInstance, NULL);
if (hwnd == NULL) {
MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
LONG Style = GetWindowLongA(hwnd, GWL_STYLE);
Style = Style & ~WS_CAPTION & ~WS_SYSMENU & ~WS_SIZEBOX;
SetWindowLongA(hwnd, GWL_STYLE, Style);
/*
This is the heart of our program where all input is processed and
sent to WndProc. Note that GetMessage blocks code flow until it receives something, so
this loop will not produce unreasonably high CPU usage
*/
while (GetMessage(&msg, NULL, 0, 0) > 0) { /* If no error is received... */
TranslateMessage(&msg); /* Translate key codes to chars if present */
DispatchMessage(&msg); /* Send it to WndProc */
}
return msg.wParam;
}
边栏推荐
- (js)三位用逗号隔开,保留两位小数(or 四舍五入取整)
- 2022 极术通讯-安谋科技迎来发展新机遇
- How should the test plan be written? A thought teaches you
- ADB命令集锦,一起来学吧
- Codecraft-22 and codeforces round 795 (Div. 2)
- After going to the bathroom, I figured out the ES search server
- Full alphabetic arrangement (pure alphabetic password dictionary)
- 90%以上软件公司都会问的软件测试面试题赶紧来背吧
- Meeting time (topology sorting +dp)
- What are the software testing requirements analysis methods? Let's have a look
猜你喜欢
ADB command collection, let's learn together

I Regular expression to finite state automata: regular expression to NFA

电阻的作用有哪些?(超全)

ThreadLocal

Countdownlatch example
Summary of APP test interview questions, which must be taken in the interview
![Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays](/img/6b/6dcc86bfe0f48103ef8420b9996c1e.jpg)
Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays
软件测试基础知识分享,写点你不知道的

Distributed transactions - Theoretical Overview

After going to the bathroom, I figured out the ES search server
随机推荐
Automated test learning path, come and learn
CodeCraft-22 and Codeforces Round #795 (Div. 2) 题解
Diff prime pairs
JVM virtual machine
測試用例和bug描述規範參考
Description of string
ADB command collection, let's learn together
Hotspot Metaspace
Counting haybales (difference + discretization)
I Regular expression to finite state automata: regular expression to NFA
【云原生】具体指什么呢---此文和大伙儿分享答案
More than 90% of the software companies will ask the software test interview questions. Hurry to recite them
TAP 系列文章3 | Tanzu Application Platform 部署参考架构介绍
APP测试面试题汇总,面试必考一定要看
NiO principle
解压缩zip文件的工具类
Do you know how to improve software testing ability?
Auto.js学习笔记8:常用且重要的一些API
Selenium interview question sharing
Filters and listeners