PDA

View Full Version : مبتدی: حرکت اسکرول بار در دلفی 7



sajioo
جمعه 26 اردیبهشت 1393, 20:15 عصر
دوستان چطور میشه با کلیک بر روی یک باتن مثلا اسکرول بار یک tstringlist رو به پایین ترین و یا بالاترین مکان ممکنش برد؟
البته در دلفی 7:قلب:

SayeyeZohor
جمعه 26 اردیبهشت 1393, 20:30 عصر
SendMessage(Memo1.Handle, EM_SETSEL, 0, 0);
SendMessage(Memo1.Handle, EM_SCROLLCARET, 10, 0);

sajioo
جمعه 26 اردیبهشت 1393, 20:39 عصر
راستش تست کردم جواب نداد برای tlistbox
:ناراحت:

SayeyeZohor
جمعه 26 اردیبهشت 1393, 20:43 عصر
برای memo جواب می ده اونو تست نکردم
حالا تست میکنم

SayeyeZohor
جمعه 26 اردیبهشت 1393, 20:49 عصر
ListBox1.Perform(LB_SETTOPINDEX, ListBox1.Items.Count -1,0);

LB_SETCURSEL or LB_SETCARETINDEX

SayeyeZohor
جمعه 26 اردیبهشت 1393, 20:53 عصر
با این Listbox.perform حتی می شه search نوشت



procedure TListBoxSearchForm.Edit1Change(Sender: TObject) ;
const
indexStart = -1;
var
search : array[0..128] of Char;
begin
//make sure Length(Edit1.Text) <= 128
StrPCopy(search, Edit1.Text) ;
ListBox1.ItemIndex := ListBox1.Perform(LB_SELECTSTRING, indexStart, LongInt(@search)) ;
end;

SayeyeZohor
جمعه 26 اردیبهشت 1393, 20:54 عصر
جالبه
نیست ؟

unit uinclist;

interface

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

type
TForm1 = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
{This is a test string to load into the list box at runtime}
CONST ListStrings = 'United States'#13'Guatemala'#13'Mexico'#13+
'El Salvador'#13'Costa Rica'#13'Yucatan'#13+
'China'#13'Japan'#13'Thailand'#13'Switzerland'#13+
'Germany'#13'Lichtenstein'#13'Jamaica'#13'Greece'+
'Turkey'#13'Ireland'#13'United Kingdom'#13'Scotland'+
'Canada'#13'Uruguay'#13'Paraguay'#13'Cuba'#13+
'Spain'#13'Italy'#13'France'#13'Portugal'#13'New Zealand'#13+
'Austria'#13'Australia'#13'Philippines'#13'Korea'# 13+
'Malaysia'#13'Tibet'#13'Nepal'#13'India'#13'Sri Lanka'#13+
'Pakistan'#13+'Saudi Arabia'#13'United Arab Emerates'#13'Iran'#13+
'Ukraine'#13'Belarus'#13+
'Chechen'#13'Yugoslavia'#13'Czechoslovakia'#13'Slo vina'#13'Kazakhstan'#13+
'Egypt'#13'Morocco'#13'Macedonia'#13'Cyprus'#13'Fi nland'#13+
'Norway'#13'Sweden'#13'Denmark'#13'Netherlands'#13 'Lithuania'#13;
begin
ListBox1.Items.SetText(ListStrings);
end;

procedure TForm1.Edit1Change(Sender: TObject);
var
S : Array[0..255] of Char;
begin
StrPCopy(S, Edit1.Text);
with ListBox1 do
ItemIndex := Perform(LB_SELECTSTRING, 0, LongInt(@S));
end;

end.