Ver Mensaje Individual
  #7  
Antiguo 10-07-2015
El_Chava El_Chava is offline
Miembro
 
Registrado: jun 2005
Posts: 62
Reputación: 19
El_Chava Va por buen camino
Talking

Hola ecfisa, Neftali y tmsanchez primeramente muchas gracias por responder. Al fin logre lo que quería hacer y era que por el momento solo me marcaran los días en el stringGrid antes de guardarlos en la base de datos.Investigando por la red(y claro en el foro) encontre ejemplos y los adapte a los requerimientos que necesitaba Les dejo el código espero le sean de utilidad. Saludos.

procedimientos
Código:
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;
     p := StrMes.ClientToScreen(Point(x,y));
     PopupMenu1.popup(p.x, p.y);
    end;
 end;
 
procedure celda_seleccionada(Sender: TObject);
var
  aRect:TRect;
begin
    with TStringGrid(sender) do
    begin
     aRect:= CellRect(Col,Row);
       if Cells[Col,Row]<>'' then
      begin
        Objects[Col, Row] := TObject(clSilver);
        Canvas.Brush.Color := TColor(Objects[Col, Row]);
        Canvas.FillRect(aRect);
        Canvas.Font.Color := clBlack;
        Canvas.TextOut(aRect.Left+2, aRect.Top+2, Cells[Col, Row]);
      end;
    end;
end;
En el evento OnCreate del formulario
Código:
 
procedure TFrmCalendarioOficial.FormCreate(Sender: TObject);
var
  c, f: Integer;
begin
  with StrEnero do
  begin
    for c := FixedCols to ColCount-1 do
      for f := FixedRows to RowCount-1 do
      begin
        Objects[c, f]:= TObject(clWhite); // color por defecto
      end;
  end;
end;
En el evento OnDrawCell del StringGrid
Código:
 
procedure TFrmCalendarioOficial.StrEneroDrawCell(Sender: TObject; aCol,
  aRow: Integer; aRect: TRect; aState: TGridDrawState);
begin
  with TStringGrid(Sender) do
  begin
    if (ARow >= FixedRows) then
    begin
     if ((gdSelected in aState) and (Cells[Acol,Arow]<>'')) then
        Canvas.Brush.Color := clHighlight
     else
      Canvas.Brush.Color := TColor(Objects[ACol, ARow]);
      Canvas.FillRect(aRect);
      Canvas.Font.Color := clBlack;
      Canvas.TextOut(aRect.Left+2, aRect.Top+2, Cells[ACol, ARow]);
    end;
  end;
end;
En el evento MouseDown del StringGrid
Código:
 
procedure TFrmCalendarioOficial.StrEneroMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  var aCol, aRow :integer;
      p:TPoint;
begin
   with TStringGrid(Sender) do
    begin
      MouseToCell(X, Y, ACol, ARow);
     case Button of
       // mbLeft :seleccionar_dia( X, Y,StrEnero);
        mbRight:  seleccionar_dia( X, Y,StrEnero);
      end;
    end;
end;
en el popupmenu al seleccionar Día inhábil
Código:
 
procedure TFrmCalendarioOficial.MenudiainhabilClick(Sender: TObject);
begin
 if strEnero.Focused then
  celda_seleccionada(StrEnero);
end;
Resultado
Responder Con Cita