zoukankan      html  css  js  c++  java
  • 2D游戏编程2--windows高级编程

     

    windows应用程序布局

    image

    编译流程

    image

    响应菜单事件消息

    image

    菜单消息处理实例:

    LRESULT CALLBACK WindowProc(HWND hwnd,
                                UINT msg,
                                WPARAM wparam,
                                LPARAM lparam)
    {
    // this is the main message handler of the system
    PAINTSTRUCT        ps;    // used in WM_PAINT
    HDC                        hdc;    // handle to a device context
    
    // what is the message
    switch(msg)
        {
        case WM_CREATE:
            {
        // do initialization stuff here
    
           // return success
           return(0);
        } break;
    
           case WM_COMMAND:
           {
           switch(LOWORD(wparam))
                 {
                 // handle the FILE menu
                 case MENU_FILE_ID_OPEN:
                 {
                 // do work here
                 } break;
                 case MENU_FILE_ID_CLOSE:
                 {
                  // do work here
                 } break;
                 case MENU_FILE_ID_SAVE:
                 {
                 // do work here
                 } break;
                 case MENU_FILE_ID_EXIT:
                 {
                 // do work here
                 } break;
    
                 // handle the HELP menu
                 case MENU_HELP_ABOUT:
                 {
                 // do work here
                 } break;
                 default: break;
    
                 } // end switch wparam
    
            } break; // end WM_COMMAND
    
        case WM_PAINT:
        {
        // simply validate the window
        hdc = BeginPaint(hwnd,&ps);
        // you would do all your painting here
           EndPaint(hwnd,&ps);
           // return success
        return(0);
        } break;
    
        case WM_DESTROY:
        {
        // kill the application, this sends a WM_QUIT message
        PostQuitMessage(0);
    
            // return success
        return(0);
        } break;
    
           default:break;
    
        } // end switch
    
    // process any messages that we didn't take care of
    return (DefWindowProc(hwnd, msg, wparam, lparam));
    
    } // end WinProc
  • 相关阅读:
    foj 2111 Problem 2111 Min Number
    hdoj 1175 连连看
    poj 2377 Bad Cowtractors
    poj 3666 Making the Grade
    2018华南理工大学程序设计竞赛 H-对称与反对称
    hdoj 4293 Groups
    FOJ Problem 2273 Triangles
    poj 3411 Paid Roads
    Codeforces 235A. LCM Challenge
    离散对数二连 poj 2417 Discrete Logging & HDU 2815 Mod Tree
  • 原文地址:https://www.cnblogs.com/seebro/p/3315537.html
Copyright © 2011-2022 走看看