【ACCESS精品源码栏目提醒】:以下是网学会员为您推荐的ACCESS精品源码-【精品】Windows程序设计(第五版)源代码B(chap15) - 文化,希望本篇文章对您学习有所帮助。
chap15-Apollo11/---------------------------------------------- APOLLO11.C -- Program for screen captures c Charles Petzold 1998 ----------------------------------------------/include ltwindows.hgtinclude quotdibfile.hquotLRESULT CALLBACK WndProc HWND UINT WPARAM LPARAM TCHAR szAppName TEXT quotApollo11quot int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow 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 NULL wndclass.lpszClassName szAppName if RegisterClass ampwndclass MessageBox NULL TEXT quotThis program requires Windows NTquot szAppName MB_ICONERROR return 0 hwnd CreateWindow szAppName TEXT quotApollo 11quot 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 BITMAPFILEHEADER pbmfh 2 static BITMAPINFO pbmi 2 static BYTE pBits 2 static int cxClient cyClient cxDib 2 cyDib 2 HDC hdc PAINTSTRUCT ps switch message case WM_CREATE: pbmfh0 DibLoadImage TEXT quotApollo11.bmpquot pbmfh1 DibLoadImage TEXT quotApolloTD.bmpquot if pbmfh0 NULL pbmfh1 NULL MessageBox hwnd TEXT quotCannot load DIB filequot szAppName 0 return 0 // Get pointers to the info structure amp the bits pbmi 0 BITMAPINFO pbmfh0 1 pbmi 1 BITMAPINFO pbmfh1 1 pBits 0 BYTE pbmfh0 pbmfh0-gtbfOffBits pBits 1 BYTE pbmfh1 pbmfh1-gtbfOffBits // Get the DIB width and height assume BITMAPINFOHEADER // Note that cyDib is the absolute value of the headervalue cxDib 0 pbmi0-gtbmiHeader.biWidth cxDib 1 pbmi1-gtbmiHeader.biWidth cyDib 0 abs pbmi0-gtbmiHeader.biHeight cyDib 1 abs pbmi1-gtbmiHeader.biHeight return 0 case WM_SIZE: cxClient LOWORD lParam cyClient HIWORD lParam return 0 case WM_PAINT: hdc BeginPaint hwnd ampps // Bottom-up DIB full size SetDIBitsToDevice hdc 0 // xDst cyClient / 4 // yDst cxDib0 // cxSrc cyDib0 // cySrc 0 // xSrc 0 // ySrc 0 // first scan line cyDib0 // number of scan lines pBits0 pbmi0 DIB_RGB_COLORS // Bottom-up DIB partial SetDIBitsToDevice hdc 240 // xDst cyClient / 4 // yDst 80 // cxSrc 166 // cySrc 80 // xSrc 60 // ySrc 0 // first scan line cyDib0 // number of scan lines pBits0 pbmi0 DIB_RGB_COLORS // Top-down DIB full size SetDIBitsToDevice hdc 340 // xDst cyClient / 4 // yDst cxDib0 // cxSrc cyDib0 // cySrc 0 // xSrc 0 // ySrc 0 // first scan line cyDib0 // number of scan lines pBits0 pbmi0 DIB_RGB_COLORS // Top-down DIB partial SetDIBitsToDevice hdc 580 // xDst cyClient / 4 // yDst 80 // cxSrc 166 // cySrc 80 // xSrc 60 // ySrc 0 // first scan line cyDib1 // number of scan lines pBits1 pbmi1 DIB_RGB_COLORS