一个很多人都会碰到的问题(50分)

  • 主题发起人 主题发起人 wdbcpw
  • 开始时间 开始时间
W

wdbcpw

Unregistered / Unconfirmed
GUEST, unregistred user!
有一个急于知道的问题想请教高手,就是如何将SQL数据库中表里的图片依次显示在panel上,具体效果附图 http://www.sd163.com.cn/turnpage.jpg
 
我通过存储过程实现过,但是由于水平有限,没有达到这种效果,附上部分代码<br>procedure TForm1.FormCreate(Sender: TObject);<br>var ii,iii:integer;<br>&nbsp;d,j:integer;<br>&nbsp; &nbsp;jpg:TJPEGImage;<br>&nbsp; &nbsp;stream:TMemorystream;<br>begin<br>pcount:=0;<br>combobox1.ItemIndex:=1;<br>scrolldel;<br>&nbsp; &nbsp; i := i;<br>&nbsp; sp.ProcedureName := 'Pr_PageShowOne;1';<br>&nbsp; sp.Close;<br>&nbsp; sp.Parameters.ParamByName('@PageSize').Value :=8;<br>&nbsp; sp.Parameters.ParamByName('@PageCurrent').Value := i;<br>&nbsp; sp.Parameters.ParamByName('@FdName').Value := 'pictureid';<br>&nbsp; sp.Parameters.ParamByName('@SelectStr').Value := 'pictureid,title,picsmall,categoryname,picturedate,uploaddate,remark';<br>&nbsp; sp.Parameters.ParamByName('@FromStr').Value := 'pictures';<br>&nbsp; sp.Parameters.ParamByName('@WhereStr').Value := '';<br>&nbsp; sp.Parameters.ParamByName('@OrderByStr').Value := 'pictureid';<br>&nbsp; sp.Open;<br>&nbsp; &nbsp; Label1.Caption := '记录总数:'+IntToStr(sp.Parameters.ParamValues['@CountRows']);<br>&nbsp; Label2.Caption := '总页数:'+IntToStr(sp.Parameters.ParamValues['@CountPage']);<br>&nbsp; RsCount := sp.Parameters.ParamValues['@CountPage'];<br>&nbsp; Label3.Caption := '第 '+IntToStr(i)+ ' 页';<br><br>&nbsp; d:=sp.RecordCount;<br>&nbsp; &nbsp; &nbsp; j:=d;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //调用拷贝图片显示<br>&nbsp; &nbsp; &nbsp; while d&gt;0 do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; image[j-d]:=Timage.Create(application.Owner);<br>&nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d]:=Tlabel.Create(self);<br>&nbsp; &nbsp; &nbsp; &nbsp; pan[j-d]:=Tpanel.Create(self);<br>&nbsp; &nbsp; &nbsp; &nbsp; pan[j-d].Parent:=scrollbox1;<br>&nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Parent:=pan[j-d];<br>&nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].Parent:=pan[j-d];<br>&nbsp; &nbsp; &nbsp; &nbsp; pan[j-d].Top:=150*((j-d)div 8)+10;<br>&nbsp; &nbsp; &nbsp; &nbsp; pan[j-d].Left:=120*((j-d)mod 8)+10;<br>&nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Top:=2;<br>&nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Left:=2;<br>&nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Height:=115;<br>&nbsp; &nbsp; &nbsp; &nbsp; pan[j-d].Height:=130;<br>&nbsp; &nbsp; &nbsp; &nbsp; pan[j-d].Width:=110;<br>&nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].Top:=image[j-d].Height+2;<br>&nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Width:=105;<br>&nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].Left:=2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stream:=Tmemorystream.Create;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TBlobField(sp.FieldByName('picsmall')).SaveToStream(stream);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stream.Position:=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jpg:=TJPEGImage.Create;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jpg.LoadFromStream(stream);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imageh[j-d]:=jpg.height;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imagew[j-d]:=jpg.width;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Stretch:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //image1.Left:=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //image1.Top:=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Picture.Assign(jpg);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].Caption:=sp.fieldbyname('title').AsString;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].Font.Color:=clblue;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image[j-d].BringToFront;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].BringToFront;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image[j-d].Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labelx[j-d].Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pcount:=pcount+1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jpg.Free;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sp.next;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d:=d-1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iii:=sp.Parameters.ParamValues['@CountPage'];<br>&nbsp; &nbsp; for ii := 1 to iii &nbsp;do<br>combobox1.Items.Add(IntToStr(ii));<br>next;<br><br>end;<br>用这种方法能显示图片,但是不知道将表里的字段全部用标签显示出来,谁有好的代码将发到我的邮箱,万分感谢,我的邮箱是wdbcpw@163.com
 
delphi demo中就有类似的,为什么不去找找?
 

Similar threads

D
回复
0
查看
728
DelphiTeacher的专栏
D
D
回复
0
查看
754
DelphiTeacher的专栏
D
D
回复
0
查看
683
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部