SetROP2 (hdc, R2_NOT) 函数功能测试
来源:互联网 发布:手机淘宝客服怎么设置 编辑:程序博客网 时间:2024/06/14 16:59
在Windows程序设计(第五版)第七章的BLOKOUT程序中用到了
函数SetROP2 (hdc, R2_NOT)
现对其进行功能测试,
测试代码 在鼠标左键按下和弹起时分别使用一次 SetROP2 (hdc, R2_NOT)并画出一个小正方形,观察绘图结果。
#include <windows.h>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) ;int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){static TCHARszAppName[] = TEXT ("SetPRO2") ;HWNDhwnd ;MSGmsg ;WNDCLASSwndclass ;wndclass.cbClsExtra = 0 ;wndclass.cbWndExtra = 0 ;wndclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH) ;wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;wndclass.hInstance = hInstance ;wndclass.lpfnWndProc = WndProc ;wndclass.lpszClassName = szAppName ;wndclass.lpszMenuName = NULL ;wndclass.style = CS_HREDRAW | CS_VREDRAW ;if (!RegisterClass (&wndclass)){MessageBox (NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR) ;return 0 ;}hwnd = CreateWindow (szAppName, TEXT("A Test of SetROP2"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL) ;ShowWindow (hwnd, iCmdShow);UpdateWindow (hwnd) ;while (GetMessage (&msg, NULL, 0, 0)){TranslateMessage (&msg) ;DispatchMessage (&msg) ;}return msg.wParam ;}LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){HDChdc ;static intcxClient, cyClient ;PAINTSTRUCTps ;intx, y ;switch (message){case WM_SIZE :cxClient = LOWORD (lParam) ;cyClient = HIWORD (lParam) ;return 0;case WM_LBUTTONDOWN :hdc = GetDC (hwnd) ;x = LOWORD (lParam) ;y = HIWORD (lParam) ;SetROP2 (hdc, R2_NOT) ;Rectangle (hdc, x, y, x+50, y+50) ;ReleaseDC (hwnd, hdc) ;return 0;case WM_LBUTTONUP :hdc = GetDC (hwnd) ;x = LOWORD (lParam) ;y = HIWORD (lParam) ;SetROP2 (hdc, R2_NOT) ;<span style="white-space:pre"></span>//屏蔽这一行试试Rectangle (hdc, x, y, x+50, y+50) ;ReleaseDC (hwnd, hdc) ;return 0;case WM_DESTROY :PostQuitMessage (0) ;return 0 ;}return DefWindowProc (hwnd, message, wParam, lParam) ;}
2.鼠标左键按下, 移动至正方形右下方的放开
3. 鼠标左键按下, 不移动, 放开
按下时出现
放开之后这个图形消失
0 0
- SetROP2 (hdc, R2_NOT) 函数功能测试
- 利用SetROP2函数的R2_NOT与R2_NOTXORPEN
- 当SetROP2(R2_NOT)不能擦除文字时
- c++ GDI绘图 利用SetROP2函数的R2_NOT与R2_NOTXORPEN属性,重新绘制时清除原先的图
- SetROP2函数
- SetROP2
- SETROP2
- SetROP2
- SetROP2
- SetROP2
- SetROP2
- SetROP2
- SetROP2
- SetROP2
- HDC
- SetROP2函数 ——设置前景色与背景色
- ostream_iterator用法,以及unique_copy函数功能测试
- jQuery之Callbacks函数功能测试
- 常用的APT命令参数
- 动态二维数组
- bzoj1207: [HNOI2004]打鼹鼠
- java的System.getProperty()方法可以获取的值
- Black Box——优先队列
- SetROP2 (hdc, R2_NOT) 函数功能测试
- 51单片机实现scanf和printf函数
- HDU 4913 Least common multiple 解题报告(线段树)
- 父类和子类的构造方法
- FunCoolShell
- EasyUI在MVC4中需要部分刷新页面时load()后页面变形问题!
- 深度探索C++对象模型--构造函数语义学
- 【JAVA】初始化数组并实例化Random类对象输出
- 中期检查报告