码迷,mamicode.com
首页 > Windows程序 > 详细

Win32程序框架

时间:2018-01-04 16:21:28      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:lap   chm   ips   har   rbac   hit   tips   edr   icons   

#include<Windows.h>

LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);

int WINAPI WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int iCmdShow
    )
{
    TCHAR szAppName[] = TEXT("KeyView1");
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wndClass;

    wndClass.cbSize = sizeof(WNDCLASSEX);
    wndClass.cbClsExtra = 0;
    wndClass.cbWndExtra = 0;
    wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
    wndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
    wndClass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
    wndClass.hInstance = hInstance;
    wndClass.lpfnWndProc = WindowProc;
    wndClass.lpszClassName = szAppName;
    wndClass.lpszMenuName = NULL;
    wndClass.style = CS_VREDRAW|CS_HREDRAW;

    if(!RegisterClassEx(&wndClass))
    {
        MessageBox(NULL,TEXT("it requires Windows NT!"),TEXT("TIPS"),0);
        return -1;
    }

    hwnd = CreateWindow(
        szAppName,TEXT("KeyView1 Window"),
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
        NULL,NULL,hInstance,NULL
        );

    ShowWindow(hwnd,iCmdShow);
    UpdateWindow(hwnd);

    while(GetMessage(&msg,0,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;

    switch(message)
    {
    case WM_CREATE:
        break;
    case WM_PAINT:
        hdc = BeginPaint(hwnd,&ps);
        EndPaint(hwnd,&ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    }
    return DefWindowProc(hwnd,message,wParam,lParam);
}

 

Win32程序框架

标签:lap   chm   ips   har   rbac   hit   tips   edr   icons   

原文地址:https://www.cnblogs.com/FWFC/p/8193470.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!