Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Listbox Scrollbar wegmachen? (https://www.delphipraxis.net/4980-listbox-scrollbar-wegmachen.html)

Pseudemys Nelsoni 19. Mai 2003 13:42


Listbox Scrollbar wegmachen?
 
hi

ich habe eine Listbox auf meiner form und möchte, dass wenn die items über dem sichtbaren hinausgehen die dadurch kommende Scrollbar weghaben...gibts dafür keine option wie bei memo etc?

gruss silent

Pseudemys Nelsoni 19. Mai 2003 16:23

weiss es wirklich keiner?

...sorry das ich so schnell nochmal nachfrage, aber mein prog sollte bis 18 uhr fertig sein :\

danke

Luckie 19. Mai 2003 16:25

Re: Listbox Scrollbar wegmachen?
 
Zitat:

Zitat von silent
hi
ich habe eine Listbox auf meiner form und möchte, dass wenn die items über dem sichtbaren hinausgehen die dadurch kommende Scrollbar weghaben

warum?
Zitat:

...gibts dafür keine option wie bei memo etc?
Nicht das ich wüßte.

APP 19. Mai 2003 16:34

Eigene Kompo ableiten:
Delphi-Quellcode:
type
  TNoVScrolllistbox = Class( TListBox )
  private
    procedure WMNCCalcSize( var msg: TMessage ); message WM_NCCALCSIZE;
  end;


procedure TNoVScrolllistbox.WMNCCalcSize(var msg: TMessage);
var
  style: Integer;
begin
  style := GetWindowLong( handle, GWL_STYLE );
  if (style and WS_VSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_VSCROLL );
  inherited;
end;
Quelle:How to remove the scrollbar of a TListBox

Pseudemys Nelsoni 19. Mai 2003 16:36

Liste der Anhänge anzeigen (Anzahl: 1)
siehe bild im anhang, ich hab schon eine scrollbar d.h die alte soll weg

jemand der sich in delphi auskennt sagte mir das ich in der SDK hilfe nach "ShowScrollBar" gucken soll, k hab ich:

Delphi-Quellcode:
The ShowScrollBar function shows or hides the specified scroll bar.

BOOL ShowScrollBar(

    HWND hWnd,   // handle of window with scroll bar
    int wBar,   // scroll bar flag
    BOOL bShow    // scroll bar visibility flag
   );   
 

Parameters

hWnd

Identifies a scroll bar control or a window with a standard scroll bar, depending on the value of the wBar parameter.

wBar

Specifies the scroll bar(s) to be shown or hidden. This parameter can be one of the following values:

Value   Meaning
SB_BOTH   Shows or hides a window's standard horizontal and vertical scroll bars.
SB_CTL   Shows or hides a scroll bar control. The hWnd parameter must be the handle of the scroll bar control.
SB_HORZ   Shows or hides a window's standard horizontal scroll bars.
SB_VERT   Shows or hides a window's standard vertical scroll bar.
 

bShow

Specifies whether the scroll bar is shown or hidden. If this parameter is TRUE, the scroll bar is shown; otherwise, it is hidden.

 

Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

While processing a scroll bar message, an application should not call this function to hide a scroll bar.

See Also

GetScrollPos, GetScrollRange, ScrollDC, ScrollWindow, SetScrollPos, SetScrollRange

aber damit kann ich wirklich nichts anfangen

:\

Pseudemys Nelsoni 19. Mai 2003 16:38

danke APP, mal ausprobieren

Pseudemys Nelsoni 19. Mai 2003 16:50

bei mir funzt der code nicht, bei dir?

APP 19. Mai 2003 16:55

Ja.


1. Form1
2. Button1 draufkleben
3. Code...
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

  type
  TNoVScrolllistbox = Class( TListBox )
  private
    procedure WMNCCalcSize( var msg: TMessage ); message WM_NCCALCSIZE;
  end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  ListBox2: TNoVScrolllistbox;

implementation

{$R *.DFM}
procedure TNoVScrolllistbox.WMNCCalcSize(var msg: TMessage);
var
  style: Integer;
begin
  style := GetWindowLong( handle, GWL_STYLE );
  if (style and WS_VSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_VSCROLL );
  inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  listbox2.Items.add('asfkljhasuilfhfuih fuihawiuh waeuifhw');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox2 := TNoVScrolllistbox.create(self);
  Listbox2.SetParent(Form1);
end;

end.
20 x Button 1 drücken, dann siehst Du es (oder eben nicht :mrgreen:).

Pseudemys Nelsoni 19. Mai 2003 19:18

thx^^

Oliver1983 30. Mär 2008 16:54

Zitat:

Zitat von APP
Ja.


1. Form1
2. Button1 draufkleben
3. Code...
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

  type
  TNoVScrolllistbox = Class( TListBox )
  private
    procedure WMNCCalcSize( var msg: TMessage ); message WM_NCCALCSIZE;
  end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  ListBox2: TNoVScrolllistbox;

implementation

{$R *.DFM}
procedure TNoVScrolllistbox.WMNCCalcSize(var msg: TMessage);
var
  style: Integer;
begin
  style := GetWindowLong( handle, GWL_STYLE );
  if (style and WS_VSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_VSCROLL );
  inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  listbox2.Items.add('asfkljhasuilfhfuih fuihawiuh waeuifhw');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox2 := TNoVScrolllistbox.create(self);
  Listbox2.SetParent(Form1);
end;

end.
20 x Button 1 drücken, dann siehst Du es (oder eben nicht :mrgreen:).


funktioniert super aber wie kann ich es an einer listbox anwenden die schon auf der form ist und nicht zur laufzeit erzeugt wird?

Hat sich erledigt :)

mfg olli


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:24 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz