zoukankan      html  css  js  c++  java
  • 2D游戏编程4—Windows事件

    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;
    image

    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;

  • 相关阅读:
    从零入门 Serverless | Knative 带来的极致 Serverless 体验
    SpringCloud 应用在 Kubernetes 上的最佳实践 — 高可用(熔断)
    阿里巴巴成立云原生技术委员会,云原生升级为阿里技术新战略
    解构云原生,从概念到落地:阿里云、声网、微博、好未来、CNCF 的专家们怎么看?
    人工智能训练云燧T10
    云计算应用场景分析
    昇腾全栈解决方案
    自动驾驶解决方案架构
    自动驾驶开发云平台业务分析
    ResNet-50模型图像分类示例
  • 原文地址:https://www.cnblogs.com/seebro/p/3322585.html
Copyright © 2011-2022 走看看