• 简单的Win 32 Application


     

    //WinMain

    #include <windows.h>

    #include <stdio.h>

     

    LRESULT CALLBACK WinProcOne(

        HWND hwnd,

        UINT uMessage,

        WPARAM wParam,

        LPARAM lParam

    );

     

    int WINAPI WinMain(

        HINSTANCE hInstance,

        HINSTANCE hPrevInstance,

        LPSTR lpCmdLine,

        int nShowCmd

    )

    {

        WNDCLASS wndcls;

        wndcls.cbClsExtra=0;

        wndcls.cbWndExtra=0;

        wndcls.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);

        wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);

        wndcls.hIcon=LoadIcon(NULL,IDI_QUESTION);

        wndcls.hInstance=hInstance;

        wndcls.lpfnWndProc=WinProcOne;

        wndcls.lpszClassName="WndClassName2011";

        wndcls.lpszMenuName=NULL;

        wndcls.style=CS_HREDRAW|CS_VREDRAW;

        RegisterClass(&wndcls);

     

        HWND hwnd;

        hwnd=CreateWindow("WndClassName2011","创建一个窗口应用程序",WS_OVERLAPPEDWINDOW,

            0,0,600,400,NULL,NULL,hInstance,NULL);

        ShowWindow(hwnd,SW_SHOWNORMAL);

        UpdateWindow(hwnd);

     

        MSG msg;

        while(GetMessage(&msg,NULL,0,0))

        {

            TranslateMessage(&msg);

            DispatchMessage(&msg);

        }

        return 0;

    }

     

    LRESULT CALLBACK WinProcOne(

        HWND hwnd,

        UINT uMessage,

        WPARAM wParam,

        LPARAM lParam

    )

    {

        switch(uMessage)

        {

        case WM_CHAR:

            char szChar[20];

            sprintf(szChar,"char is %d",wParam);

            MessageBox(hwnd,szChar,"Create Window Program",MB_OK);

            break;

        case WM_LBUTTONDOWN:

            MessageBox(hwnd,"left mouse clicked","Window Program",MB_OK);

            HDC hdc;

            hdc=GetDC(hwnd);

            TextOut(hdc,0,50,"创建一个窗口应用程序",strlen("创建一个窗口应用程序"));

            ReleaseDC(hwnd,hdc);

            break;

        case WM_PAINT:

            HDC hDC;

            PAINTSTRUCT ps;

            hDC=BeginPaint(hwnd,&ps);

            TextOut(hDC,0,0,"响应WM_PAINT消息",strlen("响应WM_PAINT消息"));

            EndPaint(hwnd,&ps);

            break;

        case WM_CLOSE:

            if(IDYES==MessageBox(hwnd,TEXT("是否真的结束?"),"window program",MB_YESNO))

            {

                DestroyWindow(hwnd);

            }

            break;

        case WM_DESTROY:

            PostQuitMessage(0);

            break;

        default:

            return(DefWindowProc(hwnd,uMessage,wParam,lParam));

        }

        return 0;

    }

     

    截图:

     

    源程序下载地址:http://down.qiannao.com/space/file/luowei505050/WinMain.rar/.page

  • 相关阅读:
    js实现年月日三级联动
    Java_Web之俱乐部会员信息管理系统
    JQuery特效之心形图片墙
    Java_Web之宠物管理系统
    JavaScript特效之图片特效放大,缩小,旋转
    使用Ajax验证用户名
    Java_Web之神奇的Ajax
    js动态操作订单表格
    tab切换
    树型菜单
  • 原文地址:https://www.cnblogs.com/luowei010101/p/2170107.html
Copyright © 2020-2023  润新知