That code does compile. Here it is in complete code:
#include <windows.h>
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
int nWidth=850, nHeight=700,zoom=1,oldzoom=1,xPos,yPos,down=0,color;
HINSTANCE hInst;
HDC hDC;
#define stackSize 16777216
int stackx[stackSize];
int stacky[stackSize];
int stackxPointer=-1;
int stackyPointer=-1;
int popx()
{
if(stackxPointer>0)
{
stackxPointer--;
return stackx[stackxPointer+1];
}
else
return -1;
}
int popy()
{
if(stackyPointer>0)
{
stackyPointer--;
return stacky[stackyPointer+1];
}
else
return -1;
}
boolean pushx(int x)
{
if (stackxPointer<stackSize-1)
{
stackxPointer++;
stackx[stackxPointer]=x;
return 1;
}
else
return 0;
}
boolean pushy(int y)
{
if (stackyPointer<stackSize-1)
{
stackyPointer++;
stacky[stackyPointer]=y;
return 1;
}
else
return 0;
}
void emptyxStack()
{
while(popx());
}
void emptyyStack()
{
while(popy());
}
void Surrounding(int x, int y, int r, int g, int b, int r2, int g2, int b2)
{
int new = RGB(r2,g2,b2);
int old = RGB(r,g,b);
if (new==old)
return;
emptyxStack();
emptyyStack();
if ((!pushx(x)) || (!pushy(y)))
return;
int newx,newy;
newx=popx();
newy=popy();
while (newx!=-1)
{
SetPixel(hDC,newx,newy, new);
if ((newx+1<nWidth)&&(GetPixel(hDC,newx+1,newy)==old))
{
if ((!pushx(newx+1))||(pushy(newy)))
return;
}
if ((newx-1<nWidth)&&(GetPixel(hDC,newx-1,newy)==old))
{
if ((!pushx(newx-1))||(pushy(newy)))
return;
}
if ((newy+1<nHeight)&&(GetPixel(hDC,newx,newy+1)==old))
{
if ((!pushx(newx))||(pushy(newy+1)))
return;
}
if ((newy-1<nHeight)&&(GetPixel(hDC,newx,newy-1)==old))
{
if ((!pushx(newx))||(pushy(newy-1)))
return;
}
newx=popx();
newy=popy();
}
}
INT PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndCls;
HWND hWnd;
static char szAppName[] = "BitmapIntro";
MSG Msg;
WndCls.cbSize = sizeof(WndCls);
WndCls.style = 0;
WndCls.lpfnWndProc = WindProcedure;
WndCls.cbClsExtra = 0;
WndCls.cbWndExtra = 0;
WndCls.hInstance = hInstance;
WndCls.hIcon = NULL;
WndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
WndCls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
WndCls.lpszMenuName = NULL;
WndCls.lpszClassName = szAppName;
WndCls.hIconSm = NULL;
RegisterClassEx(&WndCls);
hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
szAppName,
"Rooms",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
nWidth,
nHeight,
NULL,
NULL,
hInstance,
NULL);
hInst = hInstance;
int r, g, b;
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
hDC = GetDC(hWnd);
SelectObject(hDC, GetStockObject(GRAY_BRUSH));
Rectangle(hDC, 100, 100, 200, 200);
if (down){
color = GetPixel(hDC,xPos,yPos);
r = GetRValue(color);
g = GetGValue(color);
b = GetBValue(color);
Surrounding(xPos,yPos,r,g,b,r+40,g+80,b+20);
down=0;
}
ReleaseDC(hWnd, hDC);
}
return Msg.wParam;
}
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_SIZE:
nWidth = LOWORD(lParam);
nHeight = HIWORD(lParam);
break;
case WM_LBUTTONDOWN:
xPos = (short)LOWORD(lParam);
yPos = (short)HIWORD(lParam);
down=1;
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}