![]() |
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 |
weiss es wirklich keiner?
...sorry das ich so schnell nochmal nachfrage, aber mein prog sollte bis 18 uhr fertig sein :\ danke |
Re: Listbox Scrollbar wegmachen?
Zitat:
Zitat:
|
Eigene Kompo ableiten:
Delphi-Quellcode:
Quelle:
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; ![]() |
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 :\ |
danke APP, mal ausprobieren
|
bei mir funzt der code nicht, bei dir?
|
Ja.
1. Form1 2. Button1 draufkleben 3. Code...
Delphi-Quellcode:
20 x Button 1 drücken, dann siehst Du es (oder eben nicht :mrgreen:).
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. |
thx^^
|
Zitat:
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 |
AW: Listbox Scrollbar wegmachen?
Hi,
ich habe das gleiche Problem gehabt aber ich weiß leider nicht wie ich das für eine sichtbare Komponente anwenden kann. D.h. wie kann ich es an einer listbox anwenden die schon auf der form ist und nicht zur laufzeit erzeugt wird? Gruß |
AW: Listbox Scrollbar wegmachen?
Durch nen kleinen Hack kannst du das Verhalten deiner TListBox noch verändern:
Delphi-Quellcode:
Außerdem ist die Methode CreateParams besser als die oben vorgeschlagene.
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TListBox = class(StdCtrls.TListBox) protected procedure CreateParams(var Params: TCreateParams); override; end; type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ListBox1.Items.add('asfkljhasuilfhfuih fuihawiuh waeuifhw'); end; { TListBox } procedure TListBox.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); if (Params.Style and WS_VSCROLL) <> 0 then Params.Style := Params.Style and not WS_VSCROLL; end; end. |
AW: Listbox Scrollbar wegmachen?
Die If-Abfrage kann man sich aber sparen, oder nicht?
|
AW: Listbox Scrollbar wegmachen?
Glaub schon, ich komm bei dem "verunden/-odern" von Flags immer durcheinander. :oops:
|
AW: Listbox Scrollbar wegmachen?
Herzlichen dank für den Tip. Funktioniert super.
Gruß Achi |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz