注册 登录
编程论坛 C++教室

刚学习C++的菜鸟,请各位大侠帮帮我看一下源程序哪儿出错了

冒水 发布于 2016-07-15 19:01, 2814 次点击
#include<windows.h>
LRESULT CALLBACK WindowProc(HWND hwnd,
    UINT Umsgld,
    WPARAM wParam,
    LPARAM lParam);
int WINAPI WinMain(HINSTANCE hinstance,
    HINSTANCE hPrevInstance,
    LPSTR pszCmdlind,
    int nCmdShow)
{
    static char szAppName[] = "无标题3";
    HWND hwnd; MSG msg;
    WNDCLASS wndclass;
    wndclass.style = 0;
    wndclass.lpfnWndProc = WindowProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hinstance;
    wndclass.hCursor=LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName =(LPCSTR) LoadMenu(hinstance, "MainMenu");
    wndclass.lpszClassName = szAppName;
    if (RegisterClass( &wndclass ) == 0)
    {
        return 0;
    }
    hwnd = CreateWindow(
        szAppName,
        szAppName,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        NULL,
        NULL,
        hinstance,
        NULL);
    if (hwnd == 0)
    {
        return 0;
    }
    ShowWindow(hwnd, nCmdShow);
        UpdateWindow(hwnd);
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hwnd,
    UINT uMsgld,
    WPARAM wParam,
    LPARAM lParam)
{static char*pszHello = "HELLO,HOW APE YOU?";

    switch (uMsgld)
    {
    case WM_PAINT:
            HDC hDC;
            PAINTSTRUCT paintStruct;
            hDC = BeginPaint(hwnd, &paintStruct);
            TextOut(hDC, 0, 0, pszHello, lstrlen(pszHello));
            EndPaint(hwnd, &paintStruct);
            return 0;
    case WM_DESTROY:
                PostQuitMessage(0);
                return 0;
               default:
                return DefWindowProc(hwnd, uMsgld, wParam, lParam);
    }

}
1 回复
#2
我是XXX2016-07-18 15:49
可以运行啊!你这个软件的目的是什么?
1