windows消息传来的参数分解:

Message: WM_ACTIVATE

Parameterization:

fActive      = LOWORD(wParam);       // activation flag
fMinimized   = (BOOL)HIWORD(wParam); // minimized flag
hwndPrevious = (HWND)lParam;         // window handle

The Activation Flags for WM_ACTIVATE

Value
Description

WA_CLICKACTIVE
Activated by a mouse click.

WA_ACTIVE
The window has been activated by some means other than the mouse, such as the keyboard interface.

WA_INACTIVE
The window is being deactivated.

WinProc激活程序消息的处理:

case WM_ACTIVATE:
{
// test if window is being activated
if (LOWORD(wparam)!=WA_INACTIVE)
   {
   // application is being activated
   } // end if
else
   {
   // application is being deactivated
   } // end else

} break;

Message: WM_CLOSE

case WM_CLOSE:
{
// display message box
int result =  MessageBox(hwnd,
    "Are you sure you want to close this application?",
              "WM_CLOSE Message Processor",
               MB_YESNO | MB_ICONQUESTION);

// does the user want to close?
if (result == IDYES)
   {
   // call default handler
   return (DefWindowProc(hwnd, msg, wparam, lparam));
   } // end if
else // throw message away
   return(0);

} break;

Message: WM_SIZE

fwSizeType = wParam;         // resizing flag
nWidth     = LOWORD(lParam); // width of client area
nHeight    = HIWORD(lParam); // height of client area

The fwSizeType flag indicates what kind of resizing just occurred

Value
Description

SIZE_MAXHIDE
Message is sent to all pop-up windows when some other window is maximized.

SIZE_MAXIMIZED
Window has been maximized.

SIZE_MAXSHOW
Message is sent to all pop-up windows when some other window has been restored to its former size.

SIZE_MINIMIZED
Window has been minimized.

SIZE_RESTORED
Window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.

处理代码:

case WM_SIZE:
         {
         // extract size info
         int width  = LOWORD(lparam);
         int height = HIWORD(lparam);

         // get a graphics context
         hdc = GetDC(hwnd);

         // set the foreground color to green
         SetTextColor(hdc, RGB(0,255,0));

         // set the background color to black
         SetBkColor(hdc, RGB(0,0,0));

         // set the transparency mode to OPAQUE
         SetBkMode(hdc, OPAQUE);

         // draw the size of the window
         sprintf(buffer,
         "WM_SIZE Called -  New Size = (%d,%d)", width, height);
         TextOut(hdc, 0,0, buffer, strlen(buffer));

         // release the dc back
         ReleaseDC(hwnd, hdc);

         } break;

Message: WM_MOVE

case WM_MOVE:
         {
         // extract the position
         int xpos = LOWORD(lparam);
         int ypos = HIWORD(lparam);

         // get a graphics context
         hdc = GetDC(hwnd);

         // set the foreground color to green
         SetTextColor(hdc, RGB(0,255,0));

         // set the background color to black
         SetBkColor(hdc, RGB(0,0,0));

         // set the transparency mode to OPAQUE
         SetBkMode(hdc, OPAQUE);

         // draw the size of the window
         sprintf(buffer,
        "WM_MOVE Called -  New Position = (%d,%d)", xpos, ypos);
         TextOut(hdc, 0,0, buffer, strlen(buffer));
         // release the dc back
         ReleaseDC(hwnd, hdc);

         } break;

2D游戏编程4—Windows事件的更多相关文章

  1. 2D游戏编程6—windows程序模板

    // INCLUDES /////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN // just say ...

  2. windows游戏编程了解消息事件模型

    本系列文章由jadeshu编写,转载请注明出处.http://blog.csdn.net/jadeshu/article/details/22309265 作者:jadeshu   邮箱: jades ...

  3. 2D游戏编程2--windows高级编程

      windows应用程序布局 编译流程 响应菜单事件消息 菜单消息处理实例: LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wpar ...

  4. 2D游戏编程1--windows编程模型

    一.创建一个windows程序步骤 1.创建一个windows类 2.创建一个事件处理程序 3.注册windows类 4.用之前创建的windows类创建一个窗口 5.创建一个主事件循环   二.存储 ...

  5. 2D游戏编程7—星空案例

    // INCLUDES /////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN // just say ...

  6. 2D游戏编程5—锁定频率

    核心利用win心跳函数GetTickCount利用差量锁定fps,如下代码锁定30fps,缺点为如果计算机不能以30fps运行,程序将低于30fps #define WIN32_LEAN_AND_ME ...

  7. 2D游戏编程3—GDI

    WM_PAINT消息触发程序重新绘制界面,过程如下: PAINTSTRUCT    ps;    // used in WM_PAINT HDC        hdc;    // handle to ...

  8. 3D游戏编程大师技巧──2D引擎的编译问题

    接上一篇文章,这里将介绍2D引擎的编译,从现在开始才真正进入<3D游戏编程大师技巧>的学习.本书的第一.二章只是简介了游戏编程和windows编程,从第三章开始才是介绍<window ...

  9. Windows游戏编程之从零开始d

    Windows游戏编程之从零开始d I'm back~~恩,几个月不见,大家还好吗? 这段时间真的好多童鞋在博客里留言说或者发邮件说浅墨你回来继续更新博客吧. woxiangnifrr童鞋说每天都在来 ...

随机推荐

  1. bzoj1090:[SCOI2003]字符串折叠

    思路:区间dp,令f[l][r]表示l到r的答案,于是f[l][r]=min(f[l][mid],f[mid+1][r]),如果能折叠f[l][r]=min(f[l][r],f[l][l+len-1] ...

  2. layerX && layerY

    转载:https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/layerX UIEvent.layerX 非标准 这个属性是非标准的属性,并且 ...

  3. 【转】主从同步出现一下错误:Slave_IO_Running: Connecting

    主从同步出现一下错误: Slave_IO_Running: ConnectingSlave_SQL_Running: Yes 解决方法: 导致lave_IO_Running 为connecting 的 ...

  4. web前端工程师必须掌握的localStorage(二)

    最近工作太忙了,回来后就很晚了,因为红牛喝太多都不想睡觉了(公司免费给的,好多箱o(╯□╰)o),睡不着就想着逛逛博客园,本人最近忙着做一个仿原生app的singlePage应用,话说最近后台那帮兄弟 ...

  5. PHP异常处理

    一.异常处理——可以有效地控制多条出现错误或异常的代码 基本语法如下: try{ //可能出现异常的代码 } catch(Exception $e){ //对异常处理 //1.自己处理 //2.不作处 ...

  6. php5.3 不支持 session_register() 此函数已启用的解决方法

    php从5.2.x升级到5.3.2.出来问题了.有些原来能用的程序报错了,Deprecated: Function session_register() is deprecated php从5.2.x ...

  7. 全面理解.htaccess语法中RewriteCond和RewriteRule意义

    RewriteCond的语法 RewriteCond TestString CondPattern [Flags]其中的TestString是指一个文本格式的条件,例子中用的是环境变量名HTTP_HO ...

  8. C语言结构体中的函数指针

      这篇文章简单的叙述一下函数指针在结构体中的应用,为后面的一系列文章打下基础 本文地址:http://www.cnblogs.com/archimedes/p/function-pointer-in ...

  9. 基于类和redis的监控系统开发

    最近学习python运维开发,编写得一个简单的监控系统,现记录如下,仅供学习参考. 整个程序分为7个部分: 第一个部分根据监控架构设计文档架构如下: .├── m_client│   ├── conf ...

  10. iBatis系列之三

    iBatis和Hibernate最大差别就是在于iBatis没有严格的和具体的表做关联:而是将结果集和DAO做关联. iBatis的SqlConfig.xml配置一个properties文件,其实可以 ...