C,
pasted
on Mar 22:
|
#include <windows.h>
#include "debugout.h"
unsigned int x;
HDC hdcMemoryDC_ScreenS, hdcMemoryDC_DIBS;
HBITMAP bmpDDBShotGDIobjS, bmpDIBFileGDIObjS;
int widthS, heightS;
BITMAPFILEHEADER BitmapFileHeader;
BITMAPINFO BitmapInfoHeader;
BYTE *PixelData;
void capture(void) {
HDC hdcScreen;
int i;
hdcScreen = GetDC(0);
widthS = GetDeviceCaps(hdcScreen, HORZRES);
heightS = GetDeviceCaps(hdcScreen, VERTRES);
bmpDDBShotGDIobjS = CreateCompatibleBitmap(hdcScreen, widthS, heightS);
hdcMemoryDC_ScreenS = CreateCompatibleDC(hdcScreen);
SelectObject(hdcMemoryDC_ScreenS, bmpDDBShotGDIobjS);
i = BitBlt(hdcMemoryDC_ScreenS, 0, 0, widthS, heightS,
hdcScreen, 0, 0, SRCCOPY);
ReleaseDC(NULL, hdcScreen);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
HDC hdc;
static
PAINTSTRUCT ps;
RECT rect;
switch (msg) {
case WM_DESTROY:
SelectObject(hdcMemoryDC_ScreenS, GetStockObject(WHITE_BRUSH));
DeleteObject(bmpDDBShotGDIobjS);
DeleteDC(hdcMemoryDC_ScreenS);
PostQuitMessage(0);
return 0;
case WM_CREATE:
hdc = GetDC(hwnd);
hdcMemoryDC_DIBS = CreateCompatibleDC(hdc);
SelectObject(hdcMemoryDC_DIBS, bmpDIBFileGDIObjS);
BitBlt(hdcMemoryDC_DIBS, 0, 0, widthS, heightS,
hdcMemoryDC_ScreenS, 0, 0, SRCCOPY);
ReleaseDC(hwnd, hdc);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
StretchBlt(hdc, 0, 0, rect.right, rect.bottom,
hdcMemoryDC_DIBS, 0, 0, widthS, heightS,
SRCCOPY);
EndPaint(hwnd, &ps);
return 0;
}
return DefWindowProc(hwnd, msg, wp, lp);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR pCmdLine, int nCmdShow) {
HWND hwnd;
WNDCLASS winc;
MSG msg;
DWORD n;
capture();
n = widthS * 3;
if (n % 4 > 0)
n += 4 - (n % 4);
BitmapInfoHeader.bmiHeader.biSizeImage = n * heightS;
BitmapInfoHeader.bmiHeader.biSize = 40;
BitmapInfoHeader.bmiHeader.biWidth = widthS;
BitmapInfoHeader.bmiHeader.biHeight = heightS;
BitmapInfoHeader.bmiHeader.biPlanes = 1;
BitmapInfoHeader.bmiHeader.biBitCount = 24;
BitmapInfoHeader.bmiHeader.biCompression = BI_RGB;
BitmapInfoHeader.bmiHeader.biXPelsPerMeter = 0;
BitmapInfoHeader.bmiHeader.biYPelsPerMeter = 0;
BitmapInfoHeader.bmiHeader.biClrUsed = 0;
BitmapInfoHeader.bmiHeader.biClrImportant = 0;
bmpDIBFileGDIObjS = CreateDIBSection(NULL,
&BitmapInfoHeader,
DIB_RGB_COLORS,
(void *)&PixelData,
NULL,
0);
winc.style = CS_HREDRAW | CS_VREDRAW;
winc.lpfnWndProc = WndProc;
winc.cbClsExtra = winc.cbWndExtra = 0;
winc.hInstance = hInstance;
winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winc.hCursor = LoadCursor(NULL, IDC_ARROW);
winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
winc.lpszMenuName = NULL;
winc.lpszClassName = TEXT("KITTY");
if (!RegisterClass(&winc))
return 0;
hwnd = CreateWindow(TEXT("KITTY"), TEXT("Kitty on your lap"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
if (hwnd == NULL)
return 0;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
SelectObject(hdcMemoryDC_DIBS, GetStockObject(WHITE_BRUSH));
DeleteObject(bmpDIBFileGDIObjS);
DeleteDC(hdcMemoryDC_DIBS);
return msg.wParam;
}
/* end */
|
Output:
|
Line 20: error: windows.h: No such file or directory
Line 21: error: debugout.h: No such file or directory
Line 6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'hdcMemoryDC_ScreenS'
Line 7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bmpDDBShotGDIobjS'
Line 10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'BitmapFileHeader'
Line 11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'BitmapInfoHeader'
Line 12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
In function 'capture':
Line 15: error: 'HDC' undeclared (first use in this function)
Line 15: error: (Each undeclared identifier is reported only once
Line 15: error: for each function it appears in.)
Line 15: error: expected ';' before 'hdcScreen'
Line 17: error: 'hdcScreen' undeclared (first use in this function)
Line 18: error: 'HORZRES' undeclared (first use in this function)
Line 19: error: 'VERTRES' undeclared (first use in this function)
Line 20: error: 'bmpDDBShotGDIobjS' undeclared (first use in this function)
Line 21: error: 'hdcMemoryDC_ScreenS' undeclared (first use in this function)
Line 24: error: 'SRCCOPY' undeclared (first use in this function)
t.c: At top level:
Line 28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CALLBACK'
Line 61: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'WinMain'
|
|