program bspforum01;
uses
wintypes,
Winprocs;
Var
Cls:WNDCLASSEX;
dk,
db,dm:ShortInt;
Function wndproc(hwnd:HWND;m,w:word;l:longint):LongInt;
Begin
case m
of
$100:dk:=-1*dk;
$201:
db:=-1*
db;
$200:dm:=-1*dm;
$204:
db:=2;
end;
End;
Function regwin:Integer;
Begin
cls.cbSize:=sizeof(
cls);
cls.style:=CS_HREDRAW
Or CS_VREDRAW;
cls.lpfnWndProc:=Addr(wndproc);
cls.cbClsExtra:=0;
cls.cbWndExtra:=0;
cls.hInstance:=GetModuleHandle(
nil);;
{IH}
cls.hIcon:=winprocs.LoadIcon(0, IDI_APPLICATION);
cls.hCursor:=0;
cls.hCursor:=0;
cls.hbrBackground:=(14 + 1);
cls.lpszMenuName:=NiL;
cls.lpszClassName:='
Win here'#0;
cls.hIconSm:=LoadIcon(
cls.hInstance, IDI_APPLICATION);
regwin:=winprocs.RegisterClassEx(
cls);
End;
Function creWin:word;
Var
s2,s1:pchar;
wndparent:hwnd;
menu:hmenu;
instance:thandle;
param:pointer;
Begin
S2:='
STATIC'#0;
S1:='
Win here'#0;
wndparent:=0;
menu:=0;
instance:=0;
param:=NiL;
creWin:=winprocs.createwindow(s2,s1,ws_popup,20,40,300,200,
wndparent,menu,instance,param);
End;
Var hwnd:Word;
procedure draw4(hwnd,x,y,wid,hei:word;r,g,b:byte);
Var
DC,bp:HDC;
xx,yy,Pos:LongInt;
PaintStrc:wintypes.TPAINTSTRUCT;
Begin
DC:=winprocs.getdc(hwnd);
{device context of window}
PaintStrc.hdc:=
DC;
PaintStrc.ferase:=false;
PaintStrc.rcpaint.left:=0;
PaintStrc.rcpaint.top:=0;
PaintStrc.rcpaint.right:=X+wid;
PaintStrc.rcpaint.bottom:=Y+hei;
bp:=winprocs.BeginPaint(hwnd,PaintStrc);
for yy:=1
To hei
Do
For xx:=1
To wid
Do
Begin
winprocs.SetPixel(
dc,x+xx,y+yy,(((r*256)+g)*256)+b);
End;
winprocs.EndPaint(hwnd,PaintStrc);
releasedc(hwnd,
dc);
end;
Begin
dk:=-1;
db:=-1;dm:=-1;
regwin;
hwnd:=crewin;
showwindow(hwnd,sw_show);
updatewindow(hwnd);
Repeat
if dk=-1
Then draw4(hwnd,02,02,20,20,$C0,$00,$00)
else draw4(hwnd,02,02,20,20,$40,$40,$00);
if db=-1
Then draw4(hwnd,24,02,20,20,$00,$C0,$00)
else draw4(hwnd,24,02,20,20,$00,$40,$40);
if dm=-1
Then draw4(hwnd,46,02,20,20,$00,$00,$C0)
else draw4(hwnd,46,02,20,20,$40,$00,$40);
showwindow(hwnd,sw_show);
updatewindow(hwnd);
Until db=2;
end.