#include <windows.h>
#include "stdafx.h"
#include "resource.h"

HWND hdlg;
HINSTANCE hInst;

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM) ;
BOOL CALLBACK DlgProc(HWND,UINT,WPARAM,LPARAM);

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
    HWND hwnd ;
    MSG Msg ;
    HACCEL hAccel;
    WNDCLASS wndclass ;
    char lpszMenuName[] = "Menu";
    char lpszClassName[] = "window" ;
    char lpaszTitle[] = "My-Windows" ;


    wndclass.style = 0 ;
    wndclass.lpfnWndProc = WndProc ;
    wndclass.cbClsExtra = 0 ;
    wndclass.cbWndExtra = 0 ;
    wndclass.hInstance = hInstance ;
    wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION) ;
    wndclass.hCursor = LoadCursor(NULL,IDC_ARROW) ;
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH) ;
    wndclass.lpszMenuName = lpszMenuName ;
    wndclass.lpszClassName = lpszClassName ;
    
    if (!RegisterClass(&wndclass))
    {
        MessageBeep(0) ;
        return FALSE ;
    }
    
    hwnd = CreateWindow(
                        lpszClassName,
                        lpaszTitle,
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        NULL,
                        NULL,
                        hInstance,
                        NULL);
    
    ShowWindow(hwnd,nCmdShow) ;
    UpdateWindow(hwnd) ;
    hInst=hInstance;
    hAccel=LoadAccelerators(hInst,lpszMenuName);


    while (GetMessage(&Msg,NULL,0,0))
    {
        if(! IsDialogMessage(hdlg,&Msg))
        {
            if(!TranslateAccelerator(hwnd,hAccel,&Msg))
            {
                TranslateMessage(&Msg);
                DispatchMessage(&Msg) ;
            }
        }
    }
        
    return Msg.wParam ;
}


LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    switch(message)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDM_NEW:
                    MessageBox(hwnd,"eee!","eee",MB_OK);
                    break;
                case IDM_OPEN:
                    MessageBox(hwnd,"aaa!","aaa",MB_OK);
                    break;
                case IDM_SAVE:
                    MessageBox(hwnd,"bbb!","bbb",MB_OK);
                    break;
                case IDM_EXIT:
                    SendMessage(hwnd,WM_DESTROY,0,0);
                    break;
                case IDM_ABOUT:
                    hdlg=CreateDialog(hInst,"About",hwnd,(DLGPROC)Dlgproc);
                    break;
            }
            break;
        case WM_DESTROY :
            PostQuitMessage(0) ;
        default :
            return DefWindowProc(hwnd,message,wParam,lParam) ;
    }
    return(0) ;
}

BOOL CALLBACK Dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM,lParam)
{
    switch(message)
    {
        case WM_INITDIALOG:
            return 1;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDOK:
                DestroyWindow(hdlg);
                return 1;
            }
            break;
        case WM_CLOSE:
            DestroyWindow(hdlg);
            return 1;
    }
    return 0;
}

        
--------------------Configuration: 菜单 - Win32 Debug--------------------
Compiling...
菜单.cpp
C:\Documents and Settings\ayeeda.AYEEDA-HHO401YQ\桌面\菜单\菜单.cpp(94) : error C2065: 'Dlgproc' : undeclared identifier
C:\Documents and Settings\ayeeda.AYEEDA-HHO401YQ\桌面\菜单\菜单.cpp(106) : error C2061: syntax error : identifier 'lParam'
C:\Documents and Settings\ayeeda.AYEEDA-HHO401YQ\桌面\菜单\菜单.cpp(107) : error C2373: 'Dlgproc' : redefinition; different type modifiers
Error executing cl.exe.