IDC_BLACK IDC_WHITE LOWORDwParam PaintTheBlock hCtrlBlock iColor iFigure return TRUE case IDC_RECT: case IDC_ELLIPSE: iFigure LOWORD wParam CheckRadioButton hDlg IDC_RECT IDC_ELLIPSE LOWORDwParam PaintTheBlock hCtrlBlock iColor iFigure return TRUE break case WM_PAINT: PaintTheBlock hCtrlBlock iColor iFigure break return FALSE chap11-About2//NO_DEPENDENCIES// Microsoft Developer Studio generated include file.// Used by About2.rc//define IDC_BLACK 1000define IDC_BLUE 1001define IDC_GREEN 1002define IDC_CYAN 1003define IDC_RED 1004define IDC_MAGENTA 1005define IDC_YELLOW 1006define IDC_WHITE 1007define IDC_RECT 1008define IDC_ELLIPSE 1009define IDC_PAINT 1010define IDM_APP_ABOUT 40001// Next default values for new objects//ifdef APSTUDIO_INVOKEDifndef APSTUDIO_READONLY_SYMBOLSdefine _APS_NEXT_RESOURCE_VALUE 105define _APS_NEXT_COMMAND_VALUE 40002define _APS_NEXT_CONTROL_VALUE 1011define _APS_NEXT_SYMED_VALUE 101endifendifchap11-About3/------------------------------------------ ABOUT3.C -- About Box Demo Program No. 3 c Charles Petzold 1998 ------------------------------------------/include ltwindows.hgtinclude quotresource.hquotLRESULT CALLBACK WndProc HWND UINT WPARAM LPARAM BOOL CALLBACK AboutDlgProc HWND UINT WPARAM LPARAM LRESULT CALLBACK EllipPushWndProc HWND UINT WPARAM LPARAM int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow static TCHAR szAppName TEXT quotAbout3quot 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 wndclass.style CS_HREDRAW CS_VREDRAW wndclass.lpfnWndProc EllipPushWndProc wndclass.cbClsExtra 0 wndclass.cbWndExtra 0 wndclass.hInstance hInstance wndclass.hIcon NULL wndclass.hCursor LoadCursor NULL IDC_ARROW wndclass.hbrBackground HBRUSH COLOR_BTNFACE 1 wndclass.lpszMenuName NULL wndclass.lpszClassName TEXT quotEllipPushquot RegisterClass ampwndclass 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 return 0 break 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 : EndDialog hDlg 0 return TRUE break return FALSE LRESULT CALLBACK EllipPushWndProc HWND hwnd UINT message WPARAM wParam LPARAM lParam TCHAR szText40 HBRUSH hBrush HDC hdc PAINTSTRUCT ps RECT rect switch message case WM_PAINT : GetClientRect hwnd amprect GetWindowText hwnd szText sizeof szText hdc BeginPaint hwnd ampps hBrush CreateSolidBrush GetSysColor COLOR_WINDOW hBrush HBRUSH SelectObject hdc hBrush SetBkColor hdc GetSysColor COLOR_WINDOW SetTextColor hdc GetSysColor COLOR_WINDOWTEXT Ellipse hdc rect.left rect.top rect.right rect.bottom DrawText hdc szText -1 amprect DT_SINGLELINE DT_CENTER DT_VCENTER DeleteObject SelectObject hdc hBrush EndPaint hwnd ampps return 0 case WM_KEYUP : if wParam VK_SPACE break // fall through case WM_LBUTTONUP : SendMessage GetParent hwnd WM_COMMAND GetWindowLong hwnd GWL_ID LPARAM hwnd return 0 return DefWindowProc hwnd message wParam lParam chap11-About3//NO_DEPENDENCIES// Microsoft Developer Studio generated include file.// Used by About3.rc//define IDM_APP_ABOUT 40001define IDC_STATIC -1// Next default values for new objects//ifdef APSTUDIO_INVOKEDifndef APSTUDIO_READONLY_SYMBOLSdefine _APS_NEXT_RESOURCE_VALUE 105define _APS_NEXT_COMMAND_VALUE 40002define _APS_NEXT_CONTROL_VALUE 1001define _APS_NEXT_SYMED_VALUE 101endifendifchap11-Colors2/------------------------------------------------ COLORS2.C -- Version using Modeless Dialog Box c Charles Petzold 1998 ------------------------------------------------/include ltwindows.hgtLRESULT CALLBACK WndProc HWND UINT WPARAM LPARAM BOOL CALLBACK ColorScrDlg HWND UINT WPARAM LPARAM HWND hDlgModeless int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow static TCHAR szAppName TEXT quotColors2quot 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 CreateSolidBrush 0L wndclass.lpszMenuName NULL wndclass.lpszClassName szAppName if RegisterClass ampwndclass MessageBox NULL TEXT quotThis program requires Windows NTquot szAppName MB_ICONERROR return 0 hwnd CreateWindow szAppName TEXT quotColor Scrollquot WS_OVERLAPPEDWINDOW WS_CLIPCHILDREN CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT NULL NULL hInstance NULL ShowWindow hwnd iCmdS.
上一篇:
VB程序设计中的控制语句 doc
下一篇:
关于大学英语教学