&是一个位运算符,就是将两个二进制的数逐位相与,就是都是1才是1,只要有一个为0则为0,结果是相与之后的结果。
&&是一个逻辑运算符,就是判断两个表达式的真假性,只有两个表达式同时为真才为真,有一个为假则为假,具有短路性质。
 /*-------------------------------------------------
CHECKER4.C -- Mouse Hit-Test Demo Program No. 4
(c) Charles Petzold, 1998
-------------------------------------------------*/ #include <windows.h> #define DIVISIONS 5 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK ChildWndProc (HWND, UINT, WPARAM, LPARAM) ; int idFocus = ;
TCHAR szChildClass[] = TEXT ("Checker4_Child") ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Checker4") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = ;
wndclass.cbWndExtra = ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return ;
} wndclass.lpfnWndProc = ChildWndProc ;
wndclass.cbWndExtra = sizeof (long) ;
wndclass.hIcon = NULL ;
wndclass.lpszClassName = szChildClass ; RegisterClass (&wndclass) ; hwnd = CreateWindow (szAppName, TEXT ("Checker4 Mouse Hit-Test Demo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ; ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, , ))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hwndChild[DIVISIONS][DIVISIONS] ;
int cxBlock, cyBlock, x, y ; switch (message)
{
case WM_CREATE :
for (x = ; x < DIVISIONS ; x++)
for (y = ; y < DIVISIONS ; y++)
hwndChild[x][y] = CreateWindow (szChildClass, NULL,
WS_CHILDWINDOW | WS_VISIBLE,
, , , ,
hwnd, (HMENU) (y << | x),
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE),
NULL) ;
return ; case WM_SIZE :
cxBlock = LOWORD (lParam) / DIVISIONS ;
cyBlock = HIWORD (lParam) / DIVISIONS ; for (x = ; x < DIVISIONS ; x++)
for (y = ; y < DIVISIONS ; y++)
MoveWindow (hwndChild[x][y],
x * cxBlock, y * cyBlock,
cxBlock, cyBlock, TRUE) ;
return ; case WM_LBUTTONDOWN :
MessageBeep () ;
return ; // On set-focus message, set focus to child window case WM_SETFOCUS:
SetFocus (GetDlgItem (hwnd, idFocus)) ;
return ; // On key-down message, possibly change the focus window case WM_KEYDOWN:
x = idFocus & 0xFF ;
y = idFocus >> ; switch (wParam)
{
case VK_UP: y-- ; break ;
case VK_DOWN: y++ ; break ;
case VK_LEFT: x-- ; break ;
case VK_RIGHT: x++ ; break ;
case VK_HOME: x = y = ; break ;
case VK_END: x = y = DIVISIONS - ; break ;
default: return ;
} x = (x + DIVISIONS) % DIVISIONS ;
y = (y + DIVISIONS) % DIVISIONS ; idFocus = y << | x ; SetFocus (GetDlgItem (hwnd, idFocus)) ;
return ; case WM_DESTROY :
PostQuitMessage () ;
return ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
} LRESULT CALLBACK ChildWndProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ; switch (message)
{
case WM_CREATE :
SetWindowLong (hwnd, , ) ; // on/off flag
return ; case WM_KEYDOWN:
// Send most key presses to the parent window if (wParam != VK_RETURN && wParam != VK_SPACE)
{
SendMessage (GetParent (hwnd), message, wParam, lParam) ;
return ;
}
// For Return and Space, fall through to toggle the square case WM_LBUTTONDOWN :
SetWindowLong (hwnd, , ^ GetWindowLong (hwnd, )) ;
SetFocus (hwnd) ;
InvalidateRect (hwnd, NULL, FALSE) ;
return ; // For focus messages, invalidate the window for repaint case WM_SETFOCUS:
idFocus = GetWindowLong (hwnd, GWL_ID) ; // Fall through case WM_KILLFOCUS:
InvalidateRect (hwnd, NULL, TRUE) ;
return ; case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ;
Rectangle (hdc, , , rect.right, rect.bottom) ; // Draw the "x" mark if (GetWindowLong (hwnd, ))
{
MoveToEx (hdc, , , NULL) ;
LineTo (hdc, rect.right, rect.bottom) ;
MoveToEx (hdc, , rect.bottom, NULL) ;
LineTo (hdc, rect.right, ) ;
} // Draw the "focus" rectangle if (hwnd == GetFocus ())
{
rect.left += rect.right / ;
rect.right -= rect.left ;
rect.top += rect.bottom / ;
rect.bottom -= rect.top ; SelectObject (hdc, GetStockObject (NULL_BRUSH)) ;
SelectObject (hdc, CreatePen (PS_DASH, , )) ;
Rectangle (hdc, rect.left, rect.top, rect.right, rect.bottom) ;
DeleteObject (SelectObject (hdc, GetStockObject (BLACK_PEN))) ;
} EndPaint (hwnd, &ps) ;
return ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}

 /*-------------------------------------------------
CHECKER4.C -- Mouse Hit-Test Demo Program No. 4
(c) Charles Petzold, 1998
-------------------------------------------------*/ #include <windows.h> #define DIVISIONS 5 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK ChildWndProc (HWND, UINT, WPARAM, LPARAM) ; int idFocus = ;
TCHAR szChildClass[] = TEXT ("Checker4_Child") ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Checker4") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = ;
wndclass.cbWndExtra = ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return ;
} wndclass.lpfnWndProc = ChildWndProc ;
wndclass.cbWndExtra = sizeof (long) ;
wndclass.hIcon = NULL ;
wndclass.lpszClassName = szChildClass ; RegisterClass (&wndclass) ; hwnd = CreateWindow (szAppName, TEXT ("Checker4 Mouse Hit-Test Demo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ; ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, , ))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hwndChild[DIVISIONS][DIVISIONS] ;
int cxBlock, cyBlock, x, y ; switch (message)
{
case WM_CREATE :
for (x = ; x < DIVISIONS ; x++)
for (y = ; y < DIVISIONS ; y++)
hwndChild[x][y] = CreateWindow (szChildClass, NULL,
WS_CHILDWINDOW | WS_VISIBLE,
, , , ,
hwnd, (HMENU) (y << | x),
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE),
NULL) ;
return ; case WM_SIZE :
cxBlock = LOWORD (lParam) / DIVISIONS ;
cyBlock = HIWORD (lParam) / DIVISIONS ; for (x = ; x < DIVISIONS ; x++)
for (y = ; y < DIVISIONS ; y++)
MoveWindow (hwndChild[x][y],
x * cxBlock, y * cyBlock,
cxBlock, cyBlock, TRUE) ;
return ; case WM_LBUTTONDOWN :
MessageBeep () ;
return ; // On set-focus message, set focus to child window case WM_SETFOCUS:
SetFocus (GetDlgItem (hwnd, idFocus)) ;
return ; // On key-down message, possibly change the focus window case WM_KEYDOWN:
x = idFocus & 0xFF ;
y = idFocus >> ; switch (wParam)
{
case VK_UP: y-- ; break ;
case VK_DOWN: y++ ; break ;
case VK_LEFT: x-- ; break ;
case VK_RIGHT: x++ ; break ;
case VK_HOME: x = y = ; break ;
case VK_END: x = y = DIVISIONS - ; break ;
default: return ;
} x = (x + DIVISIONS) % DIVISIONS ;
y = (y + DIVISIONS) % DIVISIONS ; idFocus = y << | x ; SetFocus (GetDlgItem (hwnd, idFocus)) ;
return ; case WM_DESTROY :
PostQuitMessage () ;
return ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
} LRESULT CALLBACK ChildWndProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ; switch (message)
{
case WM_CREATE :
SetWindowLong (hwnd, , ) ; // on/off flag
return ; case WM_KEYDOWN:
// Send most key presses to the parent window if (wParam != VK_RETURN && wParam != VK_SPACE)
{
SendMessage (GetParent (hwnd), message, wParam, lParam) ;
return ;
}
// For Return and Space, fall through to toggle the square case WM_LBUTTONDOWN :
SetWindowLong (hwnd, , ^ GetWindowLong (hwnd, )) ;
SetFocus (hwnd) ;
InvalidateRect (hwnd, NULL, FALSE) ;
return ; // For focus messages, invalidate the window for repaint case WM_SETFOCUS:
idFocus = GetWindowLong (hwnd, GWL_ID) ; // Fall through case WM_KILLFOCUS:
InvalidateRect (hwnd, NULL, TRUE) ;
return ; case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ;
Rectangle (hdc, , , rect.right, rect.bottom) ; // Draw the "x" mark if (GetWindowLong (hwnd, ))
{
MoveToEx (hdc, , , NULL) ;
LineTo (hdc, rect.right, rect.bottom) ;
MoveToEx (hdc, , rect.bottom, NULL) ;
LineTo (hdc, rect.right, ) ;
} // Draw the "focus" rectangle if (hwnd == GetFocus ())
{
rect.left += rect.right / ;
rect.right -= rect.left ;
rect.top += rect.bottom / ;
rect.bottom -= rect.top ; SelectObject (hdc, GetStockObject (NULL_BRUSH)) ;
SelectObject (hdc, CreatePen (PS_DASH, , )) ;
Rectangle (hdc, rect.left, rect.top, rect.right, rect.bottom) ;
DeleteObject(SelectObject (hdc, GetStockObject (BLACK_PEN))) ;
} EndPaint (hwnd, &ps) ;
return ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
 

&与&& C语言的更多相关文章

  1. C语言 · 高精度加法

    问题描述 输入两个整数a和b,输出这两个整数的和.a和b都不超过100位. 算法描述 由于a和b都比较大,所以不能直接使用语言中的标准数据类型来存储.对于这种问题,一般使用数组来处理. 定义一个数组A ...

  2. Windows server 2012 添加中文语言包(英文转为中文)(离线)

    Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...

  3. iOS开发系列--Swift语言

    概述 Swift是苹果2014年推出的全新的编程语言,它继承了C语言.ObjC的特性,且克服了C语言的兼容性问题.Swift发展过程中不仅保留了ObjC很多语法特性,它也借鉴了多种现代化语言的特点,在 ...

  4. C语言 · Anagrams问题

    问题描述 Anagrams指的是具有如下特性的两个单词:在这两个单词当中,每一个英文字母(不区分大小写)所出现的次数都是相同的.例如,"Unclear"和"Nuclear ...

  5. C语言 · 字符转对比

    问题描述 给定两个仅由大写字母或小写字母组成的字符串(长度介于1到10之间),它们之间的关系是以下4中情况之一: 1:两个字符串长度不等.比如 Beijing 和 Hebei 2:两个字符串不仅长度相 ...

  6. JAVA语言中的修饰符

    JAVA语言中的修饰符 -----------------------------------------------01--------------------------------------- ...

  7. Atitit 项目语言的选择 java c#.net  php??

    Atitit 项目语言的选择 java c#.net  php?? 1.1. 编程语言与技术,应该使用开放式的目前流行的语言趋势1 1.2. 从个人职业生涯考虑,java优先1 1.3. 从项目实际来 ...

  8. 【开源】简单4步搞定QQ登录,无需什么代码功底【无语言界限】

    说17号发超简单的教程就17号,qq核审通过后就封装了这个,现在放出来~~ 这个是我封装的一个开源项目:https://github.com/dunitian/LoTQQLogin ————————— ...

  9. InstallShield 脚本语言学习笔记

    InstallShield脚本语言是类似C语言,利用InstallShield的向导或模板都可以生成基本的脚本程序框架,可以在此基础上按自己的意愿进行修改和添加.     一.基本语法规则      ...

  10. 用C语言封装OC对象(耐心阅读,非常重要)

    用C语言封装OC对象(耐心阅读,非常重要) 本文的主要内容来自这里 前言 做iOS开发的朋友,对OC肯定非常了解,那么大家有没有想过OC中NSInteger,NSObject,NSString这些对象 ...

随机推荐

  1. usb开发

    usb开发 USB HID报告及报告描述符简介 LibUSB通过SetReport()请求与USBHID设备通信 libusb开发者指南 USB枚举和HID枚举实例 USB命令 BusHound数据分 ...

  2. 程序员需要有多懒 ?- cocos2d-x 数学函数、常用宏粗整理 - by Glede

    最近我们的cocos2d-x游戏项目已经进入了正式开发的阶段了,几个dev都辛苦码代码.cocos2d-x还是一套比较方便的api的,什么action啊.director啊.ccpoint啊都蛮便捷的 ...

  3. ARM处理器简介

    参考: http://www.arm.com/zh/products/processors/instruction-set-architectures/index.php 1.ARM核演变图 2.AR ...

  4. eclipse中集成svn maven开发手册---导入项目

    一,导入项目 二,创建提分支 三,maven编译打包 四,合并主干 一,导入项目 右键,import,选择从svn检出项目 点击next,如图 如果是第一次导入,选择创建新的资源库,点击next,输入 ...

  5. vmwvare 网卡设置讲解

  6. js架构设计模式——从angularJS看MVVM

    javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到 angularJS[ng] 这么重量 ...

  7. PKU-1704-Georgia and Bob

    题目链接 http://poj.org/problem?id=1704 这个题目是个好题,没有两下子是做不出的,其中考到,要你排序,如何把题目化成我们熟知的东西, 在这个题中我开始用选择法排序,他给我 ...

  8. 其实想要完全理解MVC框架并不是太容易

    完全理解MVC并不是很容易.使用MVC需要精心的计划,由于它的内部原理比较复杂,所以需要花费一些时间去思考.同时由于模型和视图要严格的分离,这样也给调试应用程序带来了一定的困难.每个构件在使用之前都需 ...

  9. globalToLocal的坐标变换

    globalToLocal $(function() { init(); }); // globalToLocal var stage, holder1, holder2,shape; functio ...

  10. 使用Flex4容器若干技巧

    本文适用于正在寻找使用Flex 4容器和布局的快速参考指南的开发人员. 尽管这不一定是一个复杂问题,但这似乎是许多开发人员的挫折的来源,特别是对于那些Flex刚刚入门的开发人员. 当开发人员不知道如何 ...