program keymouse;
{$APPTYPE GUI}
uses windows;
var classw1:WndClassEx;
Regwin:Integer;
Hndw:HWnd;
dc:HDC;
WT,WCN:PChar;
x,y,wid,hth:Integer;
ps:TPaintStruct;
bp:HDC;
color0,color1,color2,color3,color4:hbrush;
rect0,rect1,rect2,rect3,rect4:trect;
msg:tagmsg;
Function Wndproc(HWnd1:qword;m:longword;w:int64;l:int64):LResult;stdcall;
Begin
wndproc:=DefWindowProc(HWnd1,m,w,l);
End;
Begin
x:=100;y:=200;wid:=300;hth:=200;
classw1.cbSize:=sizeof(classw1);
classw1.style:=CS_HREDRAW Or CS_VREDRAW;
classw1.lpfnWndProc:=Addr(wndproc);
classw1.cbclsExtra:=0;
classw1.cbWndExtra:=0;
classw1.hInstance:=GetModuleHandle(nil);;
classw1.hIcon:=LoadIcon(0, IDI_APPLICATION);
classw1.hCursor:=0;
classw1.hbrBackground:=(14 + 1);
classw1.lpszMenuName:=NiL;
classw1.lpszClassName:='class Window'#0;
classw1.hIconSm:=LoadIcon(classw1.hInstance, IDI_APPLICATION);
Regwin:=RegisterClassEx(classw1);
WT:='My Program'#0;
WCN:='My window class'#0;
hndw:=CreateWindowEx(
0,
classw1.lpszClassName,
WT,
WS_POPUP,
X,Y,wid,hth,
0,0,GetModuleHandle(NiL),NiL);
ShowWindow(hndw,sw_show);
UpdateWindow(hndw);
DC:=GetDC(hndw);
PS.hdc:=DC;
PS.ferase:=false;
PS.rcpaint.left:=0;
PS.rcpaint.top:=0;
PS.rcpaint.right:=wid;
PS.rcpaint.bottom:=hth;
BP:=BeginPaint(hndw,PS);
rect0.Left:=0;
rect0.right:=wid;
Rect0.top:=0;
Rect0.bottom:=hth;
color0:=CreateSolidBrush(((30*256)+30)*256+30);
fillrect(DC,rect0,color0);
rect1.Left:=0;
rect1.right:=40;
rect1.top:=0;
rect1.bottom:=40;
color1:=CreateSolidBrush(((240*256)+0)*256+0);
rect2.left:=41;
rect2.right:=80;
rect2.top:=0;
rect2.bottom:=40;
color2:=CreateSolidBrush(((0*256)+0)*256+240);
rect3.Left:=81;
rect3.right:=120;
rect3.top:=0;
rect3.bottom:=40;
color3:=CreateSolidBrush(((0*256)+240)*256+0);
rect4.Left:=121;
rect4.right:=160;
rect4.top:=0;
rect4.bottom:=40;
color4:=CreateSolidBrush(((0*256)+240)*256+240);
msg.hwnd:=hndw;
repeat
{keyboard 1 or 2:}
if getasynckeystate($31)<>0 then begin fillrect(DC,rect0,color0);fillrect(DC,rect1,color1);end;
if getasynckeystate($32)<>0 then begin fillrect(DC,rect0,color0);fillrect(DC,rect2,color2);end;
{mouse left or right:}
If PeekMessage(msg,hndw,$201,$201,PM_REMOVE) Then Begin fillrect(DC,rect0,color0);fillrect(DC,rect3,color3);end;
If PeekMessage(msg,hndw,$204,$204,PM_REMOVE) Then Begin fillrect(DC,rect0,color0);fillrect(DC,rect4,color4);end;
until getasynckeystate(65)<>0; {exit with keyboard A}
DeleteObject(color1);DeleteObject(color2);DeleteObject(color3);DeleteObject(color4);
DeleteObject(bp);
closewindow(hndw);
unregisterclass(wcn,0);
end.