zoukankan      html  css  js  c++  java
  • 全用api写的程序

    全用api写的程序

    #include <windows.h>
    #include <stdio.h>
    #include <TCHAR.h>
    LRESULT CALLBACK winsProc(         
     HWND hwnd,
        UINT uMsg,
        WPARAM wParam,
        LPARAM lParam
    );


    int WinMain(         
       HINSTANCE hInstance,
        HINSTANCE hPrevInstance,
        LPSTR lpCmdLine,
        int nCmdShow
    )
    {
     WNDCLASS wclass;
     wclass.cbClsExtra=0;
     wclass.cbWndExtra=0;
     wclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
     wclass.hCursor=LoadCursor(NULL,IDC_ARROW);
     wclass.hIcon=LoadIcon(NULL,IDI_ERROR);
     wclass.hInstance=hInstance;
     wclass.lpfnWndProc=winsProc;
     wclass.lpszClassName=_T("Wins32");
     wclass.lpszMenuName=NULL;
     wclass.style=CS_HREDRAW|CS_VREDRAW;
     RegisterClass(&wclass);

     HWND hwnd;
     hwnd=CreateWindow(_T("Wins32"),_T("linkwork"),
      WS_OVERLAPPEDWINDOW,0,0,800,600,NULL,NULL,hInstance,NULL);

     ShowWindow(hwnd,SW_SHOWNORMAL);

     UpdateWindow(hwnd);
     MSG msg;
     BOOL bRet;

    while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
    {
        if (bRet == -1)
        {
            // handle the error and possibly exit
        }
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

     return 0;


    }
    LRESULT CALLBACK winsProc(
      HWND hwnd,
      UINT uMsg,
      WPARAM wParam,
      LPARAM lParam
      )
    {
     HDC dc;
     PAINTSTRUCT ps;
     switch(uMsg)
     {

     case WM_PAINT:
      dc=BeginPaint(hwnd,&ps);
      TextOut(dc,20,20,_T("Hello Word!"),10);
      EndPaint(hwnd,&ps);
      break;
     case WM_CLOSE:
      DestroyWindow(hwnd);
     case WM_DESTROY:
      PostQuitMessage(0);
     default:
      return DefWindowProc(hwnd,uMsg,wParam,lParam);
     
     }

     return 0;
    }

  • 相关阅读:
    Bzoj 3624: [Apio2008]免费道路 (贪心+生成树)
    [ZJOI2008]杀蚂蚁antbuster 题解
    赛前集训的第一个小总结(希望?)
    Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)
    Luogu2150 寿司晚宴
    「考试总结2020-08-03」可期
    Luogu4747 [CERC2017]Intrinsic Interval
    BZOJ2839 集合计数
    Luogu5369 [PKUSC2018]最大前缀和
    Luogu5772 [JSOI2016]位运算
  • 原文地址:https://www.cnblogs.com/ahuo/p/648024.html
Copyright © 2011-2022 走看看