home *** CD-ROM | disk | FTP | other *** search
- {
- Msg #: 604 PASCAL Subboard
- From: RON PRITCHETT Sent: 04-30-91 21:10
- Re: MOUSE CODE PROBLEM
-
- Ok, Here's some code I'm having a problem with. The "pluses" I draw
- upon a left mouse button click are erased when the mouse is moved.
- Anyone got an answer?
-
- * Origin: Ronnue's Realm - Columbia, SC (803)781-2440
-
- begin code:
- }
- program blah;
-
- uses dos,crt,graph,mouse,drivers;
-
- type ButtonRec=record
- Name: string[25];
- xcoord,
- ycoord: integer;
- end;
-
- ButtonType=array[1..50] of ButtonRec;
-
- MouseObj=object
- num_buttons: word; { # of buttons on the mouse }
- error, { error on init or not }
- pressed1, { if button #1 pressed }
- pressed2, { if button #2 pressed }
- pressed3: boolean; { if button #3 pressed }
- xcoord,
- ycoord: word;
-
- procedure MouseOn;
- procedure GetPressed;
- procedure MouseOff;
- procedure GetCoords;
- end; { object MouseObj }
-
- var Buttons: ButtonType;
- gmode,gdriver: integer;
- Rodent: MouseObj;
-
-
- procedure MouseObj.MouseOn;
-
- begin
- InitMouse(num_buttons,error);
- ShowPointer;
- pressed1:=false;
- pressed2:=false;
- pressed3:=false;
- end;
-
-
- procedure MouseObj.GetPressed;
-
- var stat,c,h,v: word;
-
- begin
- getpressinfo(leftbutton,stat,c,h,v);
- Pressed1:=(stat and $01)=LeftButton;
- Pressed2:=(stat and $04)=CenterButton;
- Pressed3:=(stat and $02)=RightButton;
- end;
-
- procedure MouseObj.MouseOff;
-
- begin
- HidePointer;
- end;
-
- procedure MouseObj.GetCoords;
-
- begin
- GetMousePosition(num_buttons,xcoord,ycoord);
- end;
-
-
-
- begin
- SetupDrivers;
- gmode:=0;
- gdriver:=0;
- initgraph(gdriver,gmode,'');
- Rodent.MouseOn;
- repeat
- Rodent.GetPressed;
- if Rodent.pressed1 then
- begin
- Rodent.GetCoords;
- setcolor(13);
-
- line(Rodent.xcoord-5,Rodent.ycoord,Rodent.xcoord+5,Rodent.ycoord);
-
- line(Rodent.xcoord,Rodent.ycoord-5,Rodent.xcoord,Rodent.ycoord+5);
- end;
- delay(100);
- until Rodent.pressed3;
- Rodent.MouseOff;
- closegraph;
- end.
-
-
- {
- so... what's wrong?
-
- }