zoukankan      html  css  js  c++  java
  • windows编程:第一个windows程序

     1 #define WIN32_LEAN_AND_MEAN
     2 #include <windows.h>
     3 #include <windowsx.h>
     4 #include <math.h>
     5 #define WINDOW_CLASS_NAME L"WINCLASS1"
     6 //窗口处理函数
     7 LRESULT CALLBACK WindowProc(HWND hwnd,
     8     UINT msg,
     9     WPARAM wParam,
    10     LPARAM lPram)
    11 {
    12     PAINTSTRUCT ps;
    13     HDC hdc;
    14     switch (msg)
    15     {
    16     case WM_CREATE:
    17     {
    18                       return 0;
    19     }break;
    20     case WM_PAINT:
    21     {
    22                      hdc = BeginPaint(hwnd, &ps);
    23                      EndPaint(hwnd, &ps);
    24                      return 0;
    25     }break;
    26     default:break;
    27     }
    28     return DefWindowProc(hwnd, msg, wParam, lPram);
    29 }
    30 void GameMain()
    31 {
    32     return;
    33 }
    34 int WINAPI WinMain(HINSTANCE hInstance,
    35     HINSTANCE hPrevInstance,
    36     LPSTR lpCmdLine,
    37     int nCmdShow)
    38 {
    39     //定义窗口类
    40     WNDCLASSEX winClass;
    41     HWND hWnd;
    42     MSG msg;
    43     //填充窗口类的个成员
    44     winClass.cbSize = sizeof(WNDCLASSEX);
    45     winClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    46     winClass.lpfnWndProc = WindowProc;    //窗口消息处理函数
    47     winClass.cbClsExtra = 0;
    48     winClass.cbWndExtra = 0;
    49     winClass.hInstance = hInstance;
    50     winClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    51     winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    52     winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    53     winClass.lpszMenuName = NULL;
    54     winClass.lpszClassName = WINDOW_CLASS_NAME;        //窗口类名
    55     winClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    56 
    57     //注册窗口类
    58     if (!RegisterClassEx(&winClass))
    59     {
    60         return 0;
    61     }
    62 
    63     //创建窗口类的一个成员
    64     if (!(hWnd = CreateWindowEx(NULL,
    65         WINDOW_CLASS_NAME,
    66         L"hello world",
    67         WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    68         0, 0,
    69         640, 480,
    70         NULL,
    71         NULL,
    72         hInstance,
    73         NULL)))
    74     {
    75         return 0;
    76     }
    77 
    78     //消息循环
    79     while (true)
    80     {
    81         if (PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE))
    82         {
    83             if (msg.message == WM_QUIT)
    84             {
    85                 break;
    86             }
    87             TranslateMessage(&msg);
    88             DispatchMessage(&msg);
    89         }
    90         GameMain();
    91     }
    92     return msg.wParam;
    93 }
  • 相关阅读:
    HIDS逐渐的成为主流 java程序员
    怎样做反向域名解析(反向DNS解析)? java程序员
    入侵检测系统的性能的辨别(2) java程序员
    Codeforces Round #146 (Div. 2)
    usaco1.34Prime Cryptarithm
    poj3667 hotel(线段树区间合并)
    poj1330Nearest Common Ancestors(水LCA)
    hdu4135Coprime(容斥原理)
    hdu1541Stars(树状数组)
    usaco 1.43Arithmetic Progressions
  • 原文地址:https://www.cnblogs.com/chenjiahong/p/4197429.html
Copyright © 2011-2022 走看看