HOla, no tengo delphi a la mano, pero ésta es una idea de cómo podría ser:
Guarda la información en un arreglo de dos dimensiones:
Código Delphi
[-]
type
TCalendarioMes = Array[1..7,1..5] of Integer;
var
enero : TCalendarioMes;
procedure inicializaCalendario;
var
i,j : Integer;
begin
for i:= 1 to 7 do
for j := 1 to 5 do
enero[i,j] := 0; end;
procedure marcaAsignado(fila, columna: Integer);
begin
enero[fila,columna] := 1;
end;
procedure desmarcaAsignado(fila, columna: Integer);
begin
enero[fila,columna] := 0;
end;
Cuando selecciones la celda en el grid cambias el estado en el arreglo
Código Delphi
[-]
procedure seleccionar_dia(X, Y: Integer;StrMes:TStringGrid);
var
aCol, aRow :integer;
p:TPoint;
begin
with FrmCalendarioOficial do
begin
StrMes.MouseToCell(X, Y, aCol, aRow);
StrMes.Row := aRow;
StrMes.Col := aCol;
marcaAsignado(aCol,aRow);
p := StrMes.ClientToScreen(Point(x,y));
PopupMenu1.popup(p.x, p.y);
end;
end;
procedure TFrmCalendarioOficial.StrEneroMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
aCol, aRow :integer;
p:TPoint;
begin
if button = mbright then
seleccionar_dia( X, Y,StrEnero);
end;
Cuando verifiques si se tiene que resaltar consultas el arreglo
Código Delphi
[-]
procedure TFrmCalendarioOficial.StrEneroDrawCell(Sender: TObject; aCol,
aRow: Integer; aRect: TRect; aState: TGridDrawState);
begin
with TStringGrid(Sender) do
begin
if not (gdFixed in aState) then
begin if ((gdSelected in aState) and (Cells[Acol,Arow]<>'')) then
Canvas.Brush.Color := clHighlight
else
Canvas.Brush.Color := clWindow;
Canvas.FillRect(aRect);
end;
Canvas.TextRect(aRect, ACol, ARow, Cells[ACol, ARow]);
end;
end;