显示器测试程序(黑、白、红、绿、蓝)–C++实现
功能实现:自定义不同的参数,屏幕输出黑、白、红、绿、蓝不同的颜色,测试显示器
//设置窗口全屏int nFullWidth = GetSystemMetrics(SM_CXSCREEN);int nFullHeight = GetSystemMetrics(SM_CYSCREEN);CRect m_FullScreenRect;CRect WindowRect;GetWindowRect(&WindowRect);CRect ClientRect;RepositionBars(0, 0xFFFF, AFX_IDW_PANE_FIRST, CWnd::reposQuery, &ClientRect);ClientToScreen(&ClientRect);m_FullScreenRect.left = WindowRect.left - ClientRect.left;m_FullScreenRect.top = WindowRect.top - ClientRect.top;m_FullScreenRect.right = WindowRect.right - ClientRect.right + nFullWidth;m_FullScreenRect.bottom = WindowRect.bottom - ClientRect.bottom + nFullHeight;WINDOWPLACEMENT wndpl;wndpl.length = sizeof(WINDOWPLACEMENT);wndpl.flags = 0;wndpl.showCmd = SW_SHOWNORMAL;wndpl.rcNormalPosition = m_FullScreenRect;SetWindowPlacement(&wndpl);//设置背景颜色//参数1为黑色if(lstrcmp(__argv[1],"1")==0){CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRect(rect,RGB(0,0,0));}//参数2为白色else if(lstrcmp(__argv[1],"2")==0){CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRect(rect,RGB(255,255,255));}//参数3为红色else if(lstrcmp(__argv[1],"3")==0){CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRect(rect,RGB(255,0,0));} //参数4为绿色else if(lstrcmp(__argv[1],"4")==0){CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRect(rect,RGB(0,255,0));}//参数5为蓝色else if(lstrcmp(__argv[1],"5")==0){CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRect(rect,RGB(0,0,255));}// TODO: Add extra initialization hereelse{CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRect(rect,RGB(0,0,0));}
效果:
CMD窗口运行test.exe 1屏幕输出黑色
CMD窗口运行test.exe 2屏幕输出白色
效果:
CMD窗口运行test.exe 3屏幕输出红色
效果:
CMD窗口运行test.exe 4屏幕输出绿色
效果:
CMD窗口运行test.exe 5屏幕输出蓝色
效果: