哈哈,我现在使用的是:
Map.Canvas.Brush.Color:=clWindow;
Map.Canvas.FillRect(Map.Canvas.ClipRect);
Map.Canvas.StretchDraw(Map.BoundsRect,MJpg);
//Map.Canvas.Brush.Color:=ClBlue;
//Map.Canvas.Pen.Color:=ClBlue;
DM.SeatTable.First;
While Not DM.SeatTable.Eof do begin
Map.Canvas.Brush.Color:=StringToColor(Trim(DM.SeatTable.FieldByName('Color').AsString));
Map.Canvas.Pen.Color:=Map.Canvas.Brush.Color;
Map.Canvas.RoundRect(DM.SeatTable.FieldByName('SeatX').AsInteger,
DM.SeatTable.FieldByName('SeatY').AsInteger,
DM.SeatTable.FieldByName('SeatX').AsInteger+DM.SeatTable.FieldByName('Width').AsInteger,
DM.SeatTable.FieldByName('Seaty').AsInteger+DM.SeatTable.FieldByName('Height').AsInteger,
1,1);
DM.SeatTable.Next;
end;
Map为一个IMAGE控件。
鼠标判断:
DM.TempQuery.Close;
DM.TempQuery.SQL.Clear;
DM.TempQuery.SQL.Add('Select * from Seat where (SeatX>='+IntToStr(x)+')and(SeatX<='+IntToStr(X)+'+2)and(SeatY<='+IntToStr
+')and(SeatY>='+IntToStr
+'-2)');
DM.TempQuery.Open;
if not DM.TempQuery.IsEmpty then begin
//Application.MessageBox('hello','',0);
{Map.Hint:=}
Memo.Lines.Add(DM.TempQuery.FieldByName('Area').AsString+'区'
+DM.TempQuery.FieldByName('Line').AsString+'排'
+DM.TempQuery.FieldByName('Seat').AsString+'座');
end;
只是想要找一种更方便快捷的方式,你也可以试一下我上面说的那种方法,我不是想不动脑子,而是想要找一种更快捷的方法。
原来做的代码程序:
{DM.TempQuery.Close;
DM.TempQuery.SQL.Clear;
DM.TempQuery.SQL.Add('Select Max(Area) from Seat');
DM.TempQuery.Open;
MaxI:=DM.TempQuery.Fields[0].AsInteger+1;
DM.TempQuery.Close;
DM.TempQuery.SQL.Clear;
DM.TempQuery.SQL.Add('Select Max(Line) from Seat');
DM.TempQuery.Open;
MaxJ:=DM.TempQuery.Fields[0].AsInteger+1;
DM.TempQuery.Close;
DM.TempQuery.SQL.Clear;
DM.TempQuery.SQL.Add('Select Max(Seat) from Seat');
DM.TempQuery.Open;
MaxK:=DM.TempQuery.Fields[0].AsInteger+1;
SetLength(ShapeArray,MaxI,MaxJ,MaxK);
SeatPanel.DisableAlign;
DM.SeatTable.First;
While not DM.SeatTable.Eof do begin
ShapeArray[DM.SeatTable.FieldByName('Area').AsInteger][DM.SeatTable.FieldByName('Line').AsInteger][DM.SeatTable.FieldByName('Seat').AsInteger]:=TShape.Create(Self);
With ShapeArray[DM.SeatTable.FieldByName('Area').AsInteger][DM.SeatTable.FieldByName('Line').AsInteger][DM.SeatTable.FieldByName('Seat').AsInteger] do begin
Name:='';
Left:=DM.SeatTable.FieldByName('SeatX').AsInteger;
Top:=DM.SeatTable.FieldByName('SeatY').AsInteger;
Width:=DM.SeatTable.FieldByName('Width').AsInteger;
Height:=DM.SeatTable.FieldByName('Height').AsInteger;
//Brush.Color:=IdentToColor(DM.SeatTable.FieldByName('Color').AsString);
Cursor := crHandPoint;
DragCursor := crDrag;
DragMode := dmAutomatic;
Hint:=DM.SeatTable.FieldByName('Area').AsString+'区'
+DM.SeatTable.FieldByName('Line').AsString+'排'
+DM.SeatTable.FieldByName('Seat').AsString+'座';
OnMouseMove:=ShapeMouseMove;
OnEndDrag:=ShapeEndDrag;
Tag:=DM.SeatTable.FieldByName('SeatID').AsInteger;
Parent:=SeatPanel;
//end;
end;
DM.SeatTable.Next;
Application.ProcessMessages;
end;}
可能大家误解了我的意思了,还有对于多选的,我现在也找到做的方法了,使用API函数
DrawFocusRect(),大家有兴趣可以试一下,还有没更好的办法?