Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #21  
Antiguo 21-04-2008
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Ciertamente, el componente expuesto sólo funcionará para aquellos casos en los que RecordCount arroje un valor significativo. Con algunos componentes es así, con otros no, depende, me parece, de qué tanta meta información manda la base. No obstante, a mi entender, el punto aquí, sería, en todo caso, determinar cuando es necesaria la barra y cuando no, y ese conocimiento no depende de si ocultamos la barra con la API correspondiente o poniéndole un panel encima.

// Saludos
Responder Con Cita
  #22  
Antiguo 21-04-2008
Avatar de enecumene
[enecumene] enecumene is offline
Miembro de Oro
 
Registrado: may 2006
Ubicación: Santo Domingo, Rep. Dom.
Posts: 3.040
Poder: 21
enecumene Va por buen camino
Saludos Compañeros, La cosa va así, he implementado un nuevo procedimiento y se trata de mover registros con la rueda del Ratón, o sea, lo que haces cuando las teclas ARRIBA/ABAJO para moverse entre registros y que ahora se puede hacer con el mouse, he aquí el código:

Código Delphi [-]
{ DBGrilla v1.0                                                   }
{ Grilla basado en los códigos de Neftalí y Román ClubDelphi.com  }
{ Tiene las siguientes Características:                           }
{ Scroll Automatico : Los Scroll Vertical y horizontal aparecerán }
{ cuando sea necesario.                                           }
{ VerticalScroll : Puedes activar o desactivar el scroll Vertical.}
{ HorizontalScroll : ¿no hay que explicarlo verdad?.              }
{ Componente realizado por Enecumene para ClubDelphi.com.         }

unit DBGrilla1;

interface

uses
  SysUtils, Classes, Controls, Grids, DBGrids, Messages, windows, DBTables, Dialogs,
  DB;

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

    procedure WMNCCalcSize(var msg: TMessage); message WM_NCCALCSIZE;
    procedure MouseScroll(var msg: TMessage); message WM_MOUSEWHEEL;
  protected
      procedure setAutomaticScroll(Value: Boolean);
      procedure setVerticalScrollBar(Value: Boolean);
      procedure setHorizontalScrollBar(Value: Boolean);
  public
    constructor Create(AOwner: TComponent); override;
  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

constructor TDBGrilla.Create(AOwner: TComponent);
begin
  WindowProc := MouseScroll;
    inherited;
end;

procedure TDBGrilla.MouseScroll(var msg: TMessage);
Var Cuanto: short;
begin
  if (Msg.Msg = WM_MOUSEWHEEL) then begin
     Cuanto:=HIWORD(Msg.WParam);
     Cuanto:=Cuanto div 120;
     if Assigned(DataSource) and Assigned(DataSource.DataSet) then
     begin
     DataSource.DataSet.MoveBy(-Cuanto);
     end;
   end else TMouse(TDBGrilla).WndProc(Msg);
end;

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.
Responder Con Cita
  #23  
Antiguo 07-06-2008
sanxpue sanxpue is offline
Miembro
 
Registrado: jul 2003
Posts: 196
Poder: 21
sanxpue Va por buen camino
Buenas Buenas

Usando el componente de compañero "Enecumene"
todo iba bien perooooooooooo resulta que tuve que volver a instalar
el delphi y adivinen que?

Ya no corrio

Error : incompatible Type : 'Boolean' and 'TValor'

Solo le hice esta pequeña modificacion y listo

type
TValor = Boolean;

y Listo

saludos (sigo vivo.. ehhh)
__________________
saludos desde Puebla Mexico..
asanxt@hotmail.com
"como siempre a sus ordenes y siempre con buena cara"
'lolita me excitas, perversa piel de melocotón'
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Scrollbar Vertical desaparece del DBGRID jmlifi OOP 4 27-04-2007 20:54:43
¿Como Eliminar de la Bd el item seleccionado en un DbGrid? day_eli Conexión con bases de datos 1 09-02-2007 16:36:33
eliminar scrollbar en DBGRID cocke C++ Builder 2 25-11-2006 05:01:51
Scrollbar vertical en Tframe Sayuri Varios 3 07-12-2005 16:48:38
ScrollBar Vertical del DBGRID desaparece le4br OOP 3 21-03-2005 10:09:09


La franja horaria es GMT +2. Ahora son las 18:07:10.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi