DELPHI中如何翻页 我在MEMO中动态产生了组件,但数目较多,想用BUTTON产生翻页的功能,类似PAGEUP,PAGEDOWN,请各位大佬赐教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 sendmessage(memo1.handle,wm_vscroll,SB_PAGEDOWN,0) SendMessage(Memo1.Handle,WM_VSCROLL,SB_PAGEUP,0); 大佬,没反应,MEMO是否有什么设置?unit Unit3;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,ExtCtrls, DB, DBTables,Dateutils;type TForm3 = class(TForm) GroupBox1: TGroupBox; GroupBox2: TGroupBox; GroupBox4: TGroupBox; Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Table1: TTable; Table2: TTable; Button1: TButton; Query1: TQuery; Memo1: TMemo; Button2: TButton; Button3: TButton; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private procedure OnClick( Sender: TObject ); { Private declarations } public { Public declarations } end;var Form3: TForm3;implementationuses Unit2;var f3_bt1:tpanel; f3_bt:tbutton; f3_i:integer; f3_ds1:string;{$R *.dfm} procedure tform3.OnClick( Sender: TObject ); var f3_di2,f3_di3,f3_di4,f3_di5,f3_di6:integer; begin f3_ds1:=tbutton(sender).Caption; query1.Close; query1.SQL.Clear; query1.SQL.Add('select * from dalei where lei_bi='''+f3_ds1+''''); query1.Open; //edit2.Text:=query1.fieldbyname('chdh').AsString f3_ds1:=query1.fieldbyname('bi_hao').AsString; f3_ds1:='sp'+trim(f3_ds1); //table2.Database:='chaoshi'; table2.TableName:=f3_ds1; table2.Open; table2.First ; f3_di2:=table2.RecordCount ; f3_di4:=0; f3_di3:=0; f3_di5:=1; for f3_di2:=1 to table2.RecordCount do begin f3_bt1:=tpanel.Create(self); f3_bt1.Parent:=memo1; f3_bt1.Top:=20+f3_di5; //f3_bt1.Top:=0+110*f3_di4; f3_bt1.Left:=15+f3_di3*110; //f3_bt1.Left:=15+f3_di6; if f3_bt1.Left>=440 then begin f3_di3:=-1; f3_di4:=f3_di4+1; f3_di5:=10*f3_di4+f3_di4*100; f3_di6:=10*f3_di3+f3_di4*100; end; f3_bt1.Height:=100; f3_bt1.Width:=100; f3_bt1.Caption:=table2.fieldbyname('sp_name').AsString ; f3_bt1.Show ; table2.Next; f3_di3:=f3_di3+1; end; table2.Close;end ;procedure TForm3.FormShow(Sender: TObject);varf3_i1 :integer;f3_s1:string;beginedit1.Text:=form2.edit1.Text;edit2.Text :=datetostr(date());table1.Active :=true; //存放商品大类 table1.Open; f3_i1:=table1.RecordCount ; table1.First; for f3_i1:=1 to f3_i1 do begin f3_bt:=tbutton.Create(self); f3_bt.Parent:=groupbox2; f3_bt.top:=10; f3_bt.left:=120+75*f3_i1;f3_bt.height:=75;f3_bt.width:=75;f3_s1:= form3.Table1.fieldbyname('lei_bi').asstring;f3_bt.caption:=f3_s1;f3_bt.show;table1.Next; f3_bt.onclick:=onclick;end;table1.active:=false; table1.Close; //大类按键放置完成 end;procedure TForm3.Button1Click(Sender: TObject);beginform3.Close;application.Terminate ;end;procedure TForm3.Button2Click(Sender: TObject);begin sendmessage(memo1.handle,wm_vscroll,SB_PAGEDOWN,0);end;procedure TForm3.Button3Click(Sender: TObject);begin sendmessage(memo1.handle,wm_vscroll,SB_PAGEup,0);end;end. //上页: sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1); sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1); //下页: sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1); sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1); 我这边测试OK啊~~你的memo1中可有数据啊~~~你放多一点数据测试~~ 我的意思是你的memo1中可有内容,是空的吗?以下是全部代码了~~我这边测试OK~~unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1); sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1);end;procedure TForm1.Button2Click(Sender: TObject);begin sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1); sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1);end;end. DE410,我在MEMO1中动态加入了30个PANEL,MEMO.SCOLLBARS:=SSBOTH,在BUTTON.CLICK事件中加入//上页: sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1); sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1); //下页: sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1); sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1); 可就没反应,是否还有别的设置. DE410,我在MEMO1中动态加入了30个PANEL,MEMO.SCOLLBARS:=SSBOTH,在BUTTON.CLICK事件中加入//上页: sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1); sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1); //下页: sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1); sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1); 可就没反应,是否还有别的设置. 你的意思是panel嵌入到meno中? DE410:在MEMO1中写入数据中可行的,但我是用动态生成组件在MEMO中,f3_bt1.Parent:=memo1;f3_bt1是TPANEL用你的方法没反应 那样Panel当然不会动别指望了,想别的办法吧。 DE410:可能是的,界面上体现的是30个PANEL在MEMO1上显示,但其实质还不正确清楚,就类似触摸屏POS机的点菜功能 晕,你用ScrollBox嘛!干嘛非要搞个Memo在那里搞 suijunonghen:可以用SCROLLBOX,用BUTTON翻页如何搞,望赐教 procedure TForm1.Button1Click(Sender: TObject); begin SendMessage(ScrollBox1.Handle, WM_VSCROLL, SB_PAGEDOWN, 0); if scrollbox1.VertScrollBar.Range - scrollbox1.VertScrollBar.Position + 20 = scrollbox1.Height then button1.Enabled:= false else button2.Enabled:= true; end; procedure TForm1.Button2Click(Sender: TObject); begin SendMessage(ScrollBox1.Handle, WM_VSCROLL, SB_PAGEUP, 0); if scrollbox1.VertScrollBar.Position = 0 then button2.Enabled:= false else begin button1.Enabled:= true; end; end; procedure TForm1.FormCreate(Sender: TObject);begin比如在这里动态创建30个panel,应该怎么写呀?end; procedure TForm1.Button2Click(Sender: TObject);var Panel: TPanel;i: integer;beginfor i:=0 to 30 dobegin Panel := TPanel.Create(self);Panel.Caption := IntToStr(i);Panel.Name := 'pnl_'+ IntToStr(i);Panel.SetBounds(0,20*i,50,20); //Panel.Align := alTop;Panel.Parent := memo1;Panel.Visible := True;end;end;楼主,这是我写的但是都在一排 ,不好看,我想分几行1 2 34 5 6 HJKTO这是程序中排列的一部分,仅供参考f3_di2:=table2.RecordCount ; f3_di4:=0; f3_di3:=0; f3_di5:=1; for f3_di2:=1 to table2.RecordCount do begin f3_bt1:=tpanel.Create(self); f3_bt1.Parent:=scrollbox1; f3_bt1.Top:=20+f3_di5; //f3_bt1.Top:=0+110*f3_di4; f3_bt1.Left:=15+f3_di3*110; //f3_bt1.Left:=15+f3_di6; if f3_bt1.Left>=440 then begin f3_di3:=-1; f3_di4:=f3_di4+1; f3_di5:=10*f3_di4+f3_di4*100; f3_di6:=10*f3_di3+f3_di4*100; end; f3_bt1.Height:=100; f3_bt1.Width:=100; f3_bt1.Caption:=table2.fieldbyname('sp_name').AsString ; f3_bt1.Show ; table2.Next; f3_di3:=f3_di3+1; cxgrid打印用dxComponentPrinter,怎样动态修改header? 还要等整整一星期才能玩R2 散一分 一个小问题放了20天解决不了说明了什么? 如何在一个工程中包括多个窗体? locate 问题 关于数据库 解决这个问题,给你100分。(一个关于打印方面的问题) 窗口释放问题,高手请进 本人初学Dephi,简单问题,请指教! 局域网文件COPY速度>1M/S 散分!!顺便发布一个业于时间写的小工具. delphi 如何构造多条SQL语句,然后一次保存
unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ExtCtrls, DB, DBTables,Dateutils;type
TForm3 = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox4: TGroupBox;
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Table1: TTable;
Table2: TTable;
Button1: TButton;
Query1: TQuery;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
procedure OnClick( Sender: TObject );
{ Private declarations }
public
{ Public declarations }
end;var
Form3: TForm3;implementationuses Unit2;
var
f3_bt1:tpanel;
f3_bt:tbutton;
f3_i:integer;
f3_ds1:string;
{$R *.dfm}
procedure tform3.OnClick( Sender: TObject );
var
f3_di2,f3_di3,f3_di4,f3_di5,f3_di6:integer; begin
f3_ds1:=tbutton(sender).Caption; query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from dalei where lei_bi='''+f3_ds1+'''');
query1.Open;
//edit2.Text:=query1.fieldbyname('chdh').AsString
f3_ds1:=query1.fieldbyname('bi_hao').AsString;
f3_ds1:='sp'+trim(f3_ds1); //table2.Database:='chaoshi';
table2.TableName:=f3_ds1;
table2.Open;
table2.First ;
f3_di2:=table2.RecordCount ;
f3_di4:=0;
f3_di3:=0;
f3_di5:=1;
for f3_di2:=1 to table2.RecordCount do
begin
f3_bt1:=tpanel.Create(self);
f3_bt1.Parent:=memo1;
f3_bt1.Top:=20+f3_di5;
//f3_bt1.Top:=0+110*f3_di4;
f3_bt1.Left:=15+f3_di3*110;
//f3_bt1.Left:=15+f3_di6;
if f3_bt1.Left>=440 then
begin
f3_di3:=-1;
f3_di4:=f3_di4+1;
f3_di5:=10*f3_di4+f3_di4*100;
f3_di6:=10*f3_di3+f3_di4*100;
end;
f3_bt1.Height:=100;
f3_bt1.Width:=100;
f3_bt1.Caption:=table2.fieldbyname('sp_name').AsString ;
f3_bt1.Show ;
table2.Next;
f3_di3:=f3_di3+1; end;
table2.Close;
end ;procedure TForm3.FormShow(Sender: TObject);
var
f3_i1 :integer;
f3_s1:string;
begin
edit1.Text:=form2.edit1.Text;
edit2.Text :=datetostr(date());
table1.Active :=true; //存放商品大类
table1.Open;
f3_i1:=table1.RecordCount ;
table1.First;
for f3_i1:=1 to f3_i1 do
begin f3_bt:=tbutton.Create(self);
f3_bt.Parent:=groupbox2;
f3_bt.top:=10;
f3_bt.left:=120+75*f3_i1;
f3_bt.height:=75;
f3_bt.width:=75;
f3_s1:= form3.Table1.fieldbyname('lei_bi').asstring;
f3_bt.caption:=f3_s1;
f3_bt.show;
table1.Next;
f3_bt.onclick:=onclick;
end;
table1.active:=false;
table1.Close; //大类按键放置完成
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
form3.Close;
application.Terminate ;
end;procedure TForm3.Button2Click(Sender: TObject);
begin
sendmessage(memo1.handle,wm_vscroll,SB_PAGEDOWN,0);
end;procedure TForm3.Button3Click(Sender: TObject);
begin
sendmessage(memo1.handle,wm_vscroll,SB_PAGEup,0);
end;end.
sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1);
sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1); //下页:
sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1);
sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1);
以下是全部代码了~~我这边测试OK~~
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1);
sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1);end;procedure TForm1.Button2Click(Sender: TObject);
begin
sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1);
sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1);
end;end.
//上页:
sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1);
sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1); //下页:
sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1);
sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1);
可就没反应,是否还有别的设置.
//上页:
sendmessage(memo1.handle, wm_keydown, VK_PRIOR, -1);
sendmessage(memo1.handle, wm_keyup, VK_PRIOR, -1); //下页:
sendmessage(memo1.handle, wm_keydown, VK_NEXT, -1);
sendmessage(memo1.handle, wm_keyup, VK_NEXT, -1);
可就没反应,是否还有别的设置.
在MEMO1中写入数据中可行的,但我是用动态生成组件在MEMO中,f3_bt1.Parent:=memo1;f3_bt1是TPANEL
用你的方法没反应
可能是的,界面上体现的是30个PANEL在MEMO1上显示,但其实质还不正确清楚,就类似触摸屏POS机的点菜功能
可以用SCROLLBOX,用BUTTON翻页如何搞,望赐教
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(ScrollBox1.Handle, WM_VSCROLL, SB_PAGEDOWN, 0);
if scrollbox1.VertScrollBar.Range - scrollbox1.VertScrollBar.Position + 20 = scrollbox1.Height then
button1.Enabled:= false
else
button2.Enabled:= true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SendMessage(ScrollBox1.Handle, WM_VSCROLL, SB_PAGEUP, 0);
if scrollbox1.VertScrollBar.Position = 0 then
button2.Enabled:= false
else
begin
button1.Enabled:= true;
end;
end;
begin
比如在这里动态创建30个panel,应该怎么写呀?
end;
var Panel: TPanel;
i: integer;
begin
for i:=0 to 30 do
begin Panel := TPanel.Create(self);
Panel.Caption := IntToStr(i);
Panel.Name := 'pnl_'+ IntToStr(i);
Panel.SetBounds(0,20*i,50,20);
//Panel.Align := alTop;
Panel.Parent := memo1;
Panel.Visible := True;
end;
end;
楼主,这是我写的
但是都在一排 ,不好看,我想分几行
1 2 3
4 5 6
这是程序中排列的一部分,仅供参考
f3_di2:=table2.RecordCount ;
f3_di4:=0;
f3_di3:=0;
f3_di5:=1;
for f3_di2:=1 to table2.RecordCount do
begin
f3_bt1:=tpanel.Create(self);
f3_bt1.Parent:=scrollbox1;
f3_bt1.Top:=20+f3_di5;
//f3_bt1.Top:=0+110*f3_di4;
f3_bt1.Left:=15+f3_di3*110;
//f3_bt1.Left:=15+f3_di6;
if f3_bt1.Left>=440 then
begin
f3_di3:=-1;
f3_di4:=f3_di4+1;
f3_di5:=10*f3_di4+f3_di4*100;
f3_di6:=10*f3_di3+f3_di4*100;
end;
f3_bt1.Height:=100;
f3_bt1.Width:=100;
f3_bt1.Caption:=table2.fieldbyname('sp_name').AsString ;
f3_bt1.Show ;
table2.Next;
f3_di3:=f3_di3+1;