我自己把抄的程序段整合了一下,可就是菜单功能用不了,请各位指教。
#include <windows.h>
#include "hello.h"LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
       LPSTR lpCmdLine, int nCmdShow)
{
static TCHAR szAppName[]= TEXT("HelloWin");
        static TCHAR szClassName[]= TEXT("HelloWinClass");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
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 = "MENUTEST";
wndclass.lpszClassName = szClassName;

if ( !RegisterClass( &wndclass ) )
{
MessageBox( NULL, TEXT("This program requires Windows NT!"),
szAppName, MB_ICONERROR );
return 0;
} hwnd = CreateWindow( szClassName,
TEXT("The HelloWin Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL ); ShowWindow( hwnd, nCmdShow );
UpdateWindow( hwnd ); while ( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
}LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
HWND hwndBtn1;
        HINSTANCE hInstance; static int cxClient, cyClient;
        static int      cxChar,cyChar;
TEXTMETRIC tm ;
switch( message )
{
        case WM_CREATE:
    cxClient = LOWORD(lParam);
        cyClient = HIWORD(lParam);
                
hdc = GetDC(hwnd);
GetTextMetrics(hdc,&tm);
cxChar = tm.tmAveCharWidth;
        cyChar = tm.tmHeight;
                ReleaseDC( hwnd, hdc );

              

hInstance = (HINSTANCE) GetWindowLong( hwnd, GWL_HINSTANCE );
hwndBtn1 = CreateWindow( TEXT("button"), TEXT("删除"),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
300, 100, 10*cxChar, 2*cyChar,
hwnd, (HMENU) ID_OK, hInstance, NULL );

             break;
case WM_PAINT:
hdc = BeginPaint( hwnd, &ps ); GetClientRect( hwnd, &rect ); EndPaint( hwnd, &ps ); return 0; case WM_DESTROY:
DestroyMenu("MENUTEST");
PostQuitMessage( 0 );
return 0;
case WM_COMMAND:
            
switch (LOWORD(wParam))
{     case ID_MENUITEM_NEW:
MessageBox(NULL,"caption","你按了按纽",MB_OK);
   break;
                 case ID_MENUITEM_OPEN:
    
   break;
                 case ID_MENUITEM_SAVE:
   
   break;
                 case ID_MENUITEM_CLOSE: 
            DestroyWindow(hwnd);
   break;
        case ID_OK:
                     MessageBox(NULL,"你按了按钮","提示!",MB_OK
                     break;




}
return 0;
}
return DefWindowProc( hwnd, message, wParam, lParam );
}