zoukankan      html  css  js  c++  java
  • MFC(一)windows

    Windows编程概念

    1.     我们编写的windows程序都是与windows系统进行交互的,与外部所有的通讯都必须通过windows系统进行。

    使用windows程序,主要是与windows交互,系统与应用程序进行交互。

    2.     windows程序是事件驱动的,因此程序要等待某个事件的发生。

    3.     Windows将事件记录在每个消息中,并将该消息放在目标程序的消息队列。消息是与某个事件有关的数据记录。

    Windows必须包含专门处理这些消息的函数,通常是WndProc()WindowProc()windows通过我们指定的函数指针访问该函数,因此其名称可以不固定为以上。

    4.     任何程序与windows的交互都通过windows API

    5.     Windows程序的结构

    最简单的,仅使用windows api的程序。包含两个函数

    WinMain():程序的开始,一些初始化的操作放在里面;

    WindowProc():用来处理程序的消息。

    这两个函数没有直接联系,都由windows系统调用。

    (1)WinMain函数

    int WINAPI WinMain( , , , )

    {

      //先创建windowclass实例;

    WNDCLASSEX windowclass;

      Windowclass.XX=…;

    Windowclass.XX=…;

     //注册相应程序实例

      RegisterClassEX(&windowclass);

     //创建程序窗口

       CreateWindow(,,,);

    // 显示程序窗口

     ShowWindow(,,,);

    //更新程序

    UpdateWindow(,,);

    //消息循环

    While(GetMessage(&msg,0,0,0)==TRUE)

    {

     TranslateMessage(&msg);//把操作行为转换为相关消息,如按键。

     DisPatchMessage(&msg);//处理转换后的消息,遇到WM_QUIT退出。

    }

    (2)WindowProc函数(非排队消息)

    LRESULT WINAPI  WindowProc(,,)

    {

       Switch(message)

    {

      case WM_PAINT:

    Return 0;

    case WM_...:

    Return 0;

                default:

     …..

    }

    }

  • 相关阅读:
    UVA-1623 Enter The Dragon (贪心)
    UVA-1619 Feel Good (单调队列)
    UVA-11536 Smallest Sub-Array
    UVA-1617 Laptop (贪心)
    UVA-10570 Meeting with Aliens (枚举+贪心)
    UVA-1153 Keep the Customer Satisfied (贪心)
    UVA-1614 Hell on the Markets(贪心+推理) (有待补充)
    UVA-1613 K-Graph Oddity (着色问题)
    UVA-1612 Guess (贪心)
    todo:open和fopen的区别
  • 原文地址:https://www.cnblogs.com/hometown/p/3204242.html
Copyright © 2011-2022 走看看