Ver Mensaje Individual
  #16  
Antiguo 18-04-2008
Avatar de enecumene
[enecumene] enecumene is offline
Miembro de Oro
 
Registrado: may 2006
Ubicación: Santo Domingo, Rep. Dom.
Posts: 3.040
Reputación: 22
enecumene Va por buen camino
¿y ahora cómo queda amigo Román siguiendo tus consejos?:

Código Delphi [-]
unit DBGrilla1;

interface

uses
  SysUtils, Classes, Controls, Grids, DBGrids, Messages, SHELLAPI, windows;

type
  TDBGrilla = class(TDBGrid)
  private
    FValorVertical: Boolean;
    FValorHorizontal: Boolean;
    FScrollAutomatico: Boolean;

    procedure WMNCCalcSize(var msg: TMessage); message WM_NCCALCSIZE;
  protected
      procedure setAutomaticScroll(Value: Boolean);
      procedure setVerticalScrollBar(Value: Boolean);
      procedure setHorizontalScrollBar(Value: Boolean);
  public
    { Public declarations }
  published
    property VerticalScrollBar: Boolean read FValorVertical write setVerticalScrollBar;
    property HorizontalScrollBar: Boolean read FValorHorizontal write setHorizontalScrollBar;
    property AutomaticScroll: Boolean read FScrollAutomatico write setAutomaticScroll;
  end;

procedure Register;

implementation

procedure TDBGrilla.setAutomaticScroll(Value: Boolean);
begin
  if Value <> FScrollAutomatico then
  begin
    FScrollAutomatico := Value;
  end;
end;

procedure TDBGrilla.setVerticalScrollBar(Value: Boolean);
begin
  if Value <> FValorVertical then
  begin
    FValorVertical := Value;
  end;
end;

procedure TDBGrilla.setHorizontalScrollBar(Value: Boolean);
begin
  if Value <> FValorHorizontal then
  begin
    FValorHorizontal := Value;
  end;
end;

procedure TDBGrilla.WMNCCalcSize(var msg: TMessage);
var
  style: Integer;
begin
if VerticalScrollBar then
  begin
  style := getWindowLong( handle, GWL_STYLE );

  if (style and WS_HSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_HSCROLL );
  if (style and WS_VSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_VSCROLL );
  end;
if HorizontalScrollBar then
  begin
  style := getWindowLong( handle, GWL_STYLE );

  if (style and WS_VSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_VSCROLL );
  if (style and WS_HSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_HSCROLL );
  end;
if AutomaticScroll then
  begin
    if Assigned(DataSource) and Assigned(DataSource.DataSet) then
    begin
      Style := GetWindowLong(Handle, GWL_STYLE);

      if DataSource.DataSet.RecordCount > VisibleRowCount then
       Style := Style or WS_VSCROLL
      else
       Style := Style and not WS_VSCROLL;

      SetWindowLong(Handle, GWL_STYLE, Style);
  end;
end;
  inherited;
end;

procedure Register;
begin
  RegisterComponents('Data Controls', [TDBGrilla]);
end;

end.

Saludos.
__________________

Mi BLOG - ¡Joder, leanse la guia de estilo!
Las Palabras son enanas, los ejemplos gigantes.

Última edición por enecumene fecha: 18-04-2008 a las 21:35:43.
Responder Con Cita