chap01/*--------------------------------------------------------------HelloMsg.c--DisplaysHello,Windows98!inamessagebox(c)CharlesPetzold,1998--------------------------------------------------------------*/#includewindows.hintWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,PSTRszCmdLine,intiCmdShow){MessageBox(NULL,TEXT(Hello,Windows98!),TEXT(HelloMsg),0);return0;}chap02/*-----------------------------------------------------SCRNSIZE.C--Displaysscreensizeinamessagebox(c)CharlesPetzold,1998-----------------------------------------------------*/#includewindows.h#includetchar.h#includestdio.hintCDECLMessageBoxPrintf(TCHAR*szCaption,TCHAR*szFormat,...){TCHARszBuffer[1024];va_listpArgList;//Theva_startmacro(definedinSTDARG.H)isusuallyequivalentto://pArgList=(char*)&szFormat+sizeof(szFormat);va_start(pArgList,szFormat);//Thelastargumenttowvsprintfpointstothearguments_vsntprintf(szBuffer,sizeof(szBuffer)/sizeof(TCHAR),szFormat,pArgList);//Theva_endmacrojustzeroesoutpArgListfornogoodreasonva_end(pArgList);returnMessageBox(NULL,szBuffer,szCaption,0);}intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,PSTRszCmdLine,intiCmdShow){intcxScreen,cyScreen;cxScreen=GetSystemMetrics(SM_CXSCREEN);cyScreen=GetSystemMetrics(SM_CYSCREEN);MessageBoxPrintf(TEXT(ScrnSize),TEXT(Thescreenis%ipixelswideby%ipixelshigh.),cxScreen,cyScreen);return0;}chap03/*------------------------------------------------------------HELLOWIN.C--DisplaysHello,Windows98!inclientarea(c)CharlesPetzold,1998------------------------------------------------------------*/#includewindows.hLRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,PSTRszCmdLine,intiCmdShow){staticTCHARszAppName[]=TEXT(HelloWin);HWNDhwnd;MSGmsg;WNDCLASSwndclass;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=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)){MessageBox(NULL,TEXT(ThisprogramrequiresWindowsNT!),szAppName,MB_ICONERROR);return0;}hwnd=CreateWindow(szAppName,//windowclassnameTEXT(TheHelloProgram),//windowcaptionWS_OVERLAPPEDWINDOW,//windowstyleCW_USEDEFAULT,//initialxpositionCW_USEDEFAULT,//initialypositionCW_USEDEFAULT,//initialxsizeCW_USEDEFAULT,//initialysizeNULL,//parentwindowhandleNULL,//windowmenuhandlehInstance,//programinstancehandleNULL);//creationparametersShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);}returnmsg.wParam;}LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMwParam,LPARAMlParam){HDChdc;PAINTSTRUCTps;RECTrect;switch(message){caseWM_CREATE:PlaySound(TEXT(hellowin.wav),NULL,SND_FILENAME|SND_ASYNC);return0;caseWM_PAINT:hdc=BeginPaint(hwnd,&ps);GetClientRect(hwnd,&rect);DrawText(hdc,TEXT(Hello,Windows98!),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);EndPaint(hwnd,&ps);return0;caseWM_DESTROY:PostQuitMessage(0);return0;}returnDefWindowProc(hwnd,message,wParam,lParam);}chap04-1/*------------------------------------------------------------HELLOWIN.C--DisplaysHello,Windows98!inclientarea(c)CharlesPetzold,1998------------------------------------------------------------*/#includewindows.hLRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,PSTRszCmdLine,intiCmdShow){staticTCHARszAppName[]=TEXT(HelloWin);HWNDhwnd;MSGmsg;WNDCLASSwndclass;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=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)){MessageBox(NULL,TEXT(ThisprogramrequiresWindowsNT!),szAppName,MB_ICONERROR);return0;}hwnd=CreateWindow(szAppName,//windowclassnameTEXT(TheHelloProgram),//windowcaptionWS_OVERLAPPEDWINDOW,//windowstyleCW_USEDEFAULT,//initialxpositionCW_USEDEFAULT,//initialypositionCW_USEDEFAULT,//initialxsizeCW_USEDEFAULT,//initialysizeNULL,//parentwindowhandleNULL,//windowmenuhandlehInstance,//programinstancehandleNULL);//creationparametersShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);}returnmsg.wParam;}LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMwParam,LPARAMlParam){HDChdc;PAINTSTRUCTps;RECTrect;switch(message){caseWM_CREATE:PlaySound(TEXT(hellowin.wav),NULL,SND_FILENAME|SND_ASYNC);return0;caseWM_PAINT:hdc=BeginPaint(hwnd,&ps);GetClientRect(hwnd,&rect);DrawText(hdc,TEXT(Hello,Windows98!),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);EndPaint(hwnd,&ps);return0;caseWM_DESTROY:PostQuitMessage(0);return0;}returnDefWindowProc(h