【VB开源代码栏目提醒】:网学会员在VB开源代码频道为大家收集整理了“【精品】Windows程序设计(第五版)源代码A(chap11) - 文化“提供大家参考,希望对大家有所帮助!
chap11-About1/------------------------------------------ ABOUT1.C -- About Box Demo Program No. 1 c Charles Petzold 1998 ------------------------------------------/include ltwindows.hgtinclude quotresource.hquotLRESULT CALLBACK WndProc HWND UINT WPARAM LPARAM BOOL CALLBACK AboutDlgProc HWND UINT WPARAM LPARAM int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow static TCHAR szAppName TEXT quotAbout1quot MSG msg HWND hwnd WNDCLASS wndclass wndclass.style CS_HREDRAW CS_VREDRAW wndclass.lpfnWndProc WndProc wndclass.cbClsExtra 0 wndclass.cbWndExtra 0 wndclass.hInstance hInstance wndclass.hIcon LoadIcon hInstance szAppName wndclass.hCursor LoadCursor NULL IDC_ARROW wndclass.hbrBackground HBRUSH GetStockObject WHITE_BRUSH wndclass.lpszMenuName szAppName wndclass.lpszClassName szAppName if RegisterClass ampwndclass MessageBox NULL TEXT quotThis program requires Windows NTquot szAppName MB_ICONERROR return 0 hwnd CreateWindow szAppName TEXT quotAbout Box Demo Programquot WS_OVERLAPPEDWINDOW CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT NULL NULL hInstance NULL ShowWindow hwnd iCmdShow UpdateWindow hwnd while GetMessage ampmsg NULL 0 0 TranslateMessage ampmsg DispatchMessage ampmsg return msg.wParam LRESULT CALLBACK WndProc HWND hwnd UINT message WPARAM wParamLPARAM lParam static HINSTANCE hInstance switch message case WM_CREATE : hInstance LPCREATESTRUCT lParam-gthInstance return 0 case WM_COMMAND : switch LOWORD wParam case IDM_APP_ABOUT : DialogBox hInstance TEXT quotAboutBoxquot hwndAboutDlgProc break return 0 case WM_DESTROY : PostQuitMessage 0 return 0 return DefWindowProc hwnd message wParam lParam BOOL CALLBACK AboutDlgProc HWND hDlg UINT message WPARAM wParam LPARAM lParam switch message case WM_INITDIALOG : return TRUE case WM_COMMAND : switch LOWORD wParam case IDOK : case IDCANCEL : EndDialog hDlg 0 return TRUE break return FALSE chap11-About1//NO_DEPENDENCIES// Microsoft Developer Studio generated include file.// Used by About1.rc//define IDM_APP_ABOUT 40001// Next default values for new objects//ifdef APSTUDIO_INVOKEDifndef APSTUDIO_READONLY_SYMBOLSdefine _APS_NEXT_RESOURCE_VALUE 104define _APS_NEXT_COMMAND_VALUE 40004define _APS_NEXT_CONTROL_VALUE 1003define _APS_NEXT_SYMED_VALUE 101endifendifchap11-About2/------------------------------------------ ABOUT2.C -- About Box Demo Program No. 2 c Charles Petzold 1998 ------------------------------------------/include ltwindows.hgtinclude quotresource.hquotLRESULT CALLBACK WndProc HWND UINT WPARAM LPARAM BOOL CALLBACK AboutDlgProc HWND UINT WPARAM LPARAM int iCurrentColor IDC_BLACK iCurrentFigure IDC_RECT int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow static TCHAR szAppName TEXT quotAbout2quot MSG msg HWND hwnd WNDCLASS wndclass wndclass.style CS_HREDRAW CS_VREDRAW wndclass.lpfnWndProc WndProc wndclass.cbClsExtra 0 wndclass.cbWndExtra 0 wndclass.hInstance hInstance wndclass.hIcon LoadIcon hInstance szAppName wndclass.hCursor LoadCursor NULL IDC_ARROW wndclass.hbrBackground HBRUSH GetStockObject WHITE_BRUSH wndclass.lpszMenuName szAppName wndclass.lpszClassName szAppName if RegisterClass ampwndclass MessageBox NULL TEXT quotThis program requires Windows NTquot szAppName MB_ICONERROR return 0 hwnd CreateWindow szAppName TEXT quotAbout Box Demo Programquot WS_OVERLAPPEDWINDOW CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT NULL NULL hInstance NULL ShowWindow hwnd iCmdShow UpdateWindow hwnd while GetMessage ampmsg NULL 0 0 TranslateMessage ampmsg DispatchMessage ampmsg return msg.wParam void PaintWindow HWND hwnd int