win32问题,初学,求指教
#include <windows.h>//*************************************************************************** // #define IDM_NEW 101 // 定
#define IDM_OPEN 102
#define IDM_SAVE 103
#define IDM_SAVEAS 104 // 义
#define IDM_PRINT 105
#define IDM_EXIT 106
#define IDM_CUT 201
#define IDM_COPY 202
#define IDM_PASTE 203
#define IDM_DELETE 204 //区
//**************************************************************************//
int WINAPI WinMain (HINSTANCE, HINSTANCE ,LPSTR , int );
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK NewWndProc(HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
//***************************************************************************************//
static TCHAR szAppName[] = TEXT ("菜单程序") ;
static TCHAR szXj[] = TEXT ("新建") ; // 可
static TCHAR szDk[] = TEXT ("打开") ;
static TCHAR szBc[] = TEXT ("保存") ;
static TCHAR szLc[] = TEXT ("另存") ;
static TCHAR szDy[] = TEXT ("打印") ;
static TCHAR szWj[] = TEXT ("文件") ;
static TCHAR szTc[] = TEXT ("退出") ; // 忽
static TCHAR szJc[] = TEXT ("剪切") ;
static TCHAR szFz[] = TEXT ("复制") ;
static TCHAR szNt[] = TEXT ("黏贴") ;
static TCHAR szBj[] = TEXT ("编辑") ;
static TCHAR szSc[] = TEXT ("删除") ; // 略
//*****************************************************************************************//
WNDCLASSEX wcex ;
wcex.cbSize=sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW |CS_DBLCLKS;
wcex.lpfnWndProc =(WNDPROC) WndProc ;
wcex.cbClsExtra = 0 ; 定义窗口类
wcex.cbWndExtra = 0 ;
wcex.hInstance = hInstance ;
wcex.hIcon = LoadIcon (NULL, (LPCTSTR)IDI_APPLICATION) ;
wcex.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wcex.hbrBackground = (HBRUSH) (COLOR_WINDOW+1) ;
wcex.lpszMenuName = NULL ;
wcex.lpszClassName = szAppName;
wcex.hIconSm = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION) ;
******************************************************************************************
if (!RegisterClassEx (&wcex)) return FALSE;
*****************************************************************************************
HMENU hMenu=CreateMenu();
HMENU hPopup=CreatePopupMenu();
AppendMenu(hPopup,MF_STRING,IDM_NEW,szXj);
AppendMenu(hPopup,MF_STRING,IDM_OPEN,szDk);
AppendMenu(hPopup,MF_STRING,IDM_SAVE,szBc);
AppendMenu(hPopup,MF_STRING,IDM_SAVEAS,szLc);
AppendMenu(hPopup,MF_STRING,IDM_PRINT,szDy);
AppendMenu(hPopup,MF_SEPARATOR,0,NULL);
AppendMenu(hPopup,MF_STRING,IDM_EXIT,szTc);
AppendMenu(hMenu,MF_POPUP,(int)hPopup,szWj); 显示菜单项
hPopup=CreatePopupMenu();
AppendMenu(hPopup,MF_STRING,IDM_CUT,szJc);
AppendMenu(hPopup,MF_STRING,IDM_COPY,szFz);
AppendMenu(hPopup,MF_STRING,IDM_PASTE,szNt);
AppendMenu(hPopup,MF_STRING,IDM_DELETE,szSc);
AppendMenu(hMenu,MF_POPUP,(int)hPopup,szBj);
**********************************************************************************************
HWND hWnd=CreateWindowEx(NULL,
szAppName,
szAppName,
WS_OVERLAPPEDWINDOW,
100,
100,
500,
350,
NULL,
hMenu,
hInstance,
NULL);
if(!hWnd)return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) //窗口消息处理程序
{
switch (message)//////////////////////////////////////////////////////////消息处理
{
case WM_COMMAND:
switch(wParam)
{
case IDM_EXIT:
PostQuitMessage(0);
break ;
case IDM_NEW:
************************************************************************
此处如何实现新建一个可编辑窗口 。。。。。。。。。。。。。。。。。。。
**************************************************************************
}
case WM_DESTROY:
PostQuitMessage (0) ;
break ;
default:
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
return 0;
}