IntraWebによるWebアプリケーション作成(3)

 

画像を設定する
条件指定項目を作成する
[検索]ボタンで商品一覧画面を呼び出す
商品一覧画面を作成する
商品分類から一覧画面呼び出す
おすすめ商品をファイルから設定する
お知らせをファイルから設定する
HTMLタグを埋め込む
実行形式を変更する
おすすめ商品をファイルから設定する 4/5
4/5

フォームのOnCreatイベントで、ファイルを読み込みおすすめ商品の内容を設定するコードを記述します。

商品名(IWLblNm)と価格(IWLblPrc1)のCaptionプロパティでHTMLタグの<div align=center>を使用すると、中央寄せができます。


procedure TformMain.IWAppFormCreate(Sender: TObject);
var
  i   :  integer;
  fnm :  string;
begin
  //おすすめ商品(ファイルより表示)
  with  Query1 do
  begin
    i := 0;
    Active := True;
    First;
    if not eof then
    begin
      fnm := FieldByName('CODE').AsString + '.JPG';
      IWImgTp1.Picture.LoadFromFile('c://img/' + fnm);
      IWLblNm1.Caption := '<div align=center>'
	   + FieldByName('NAME').AsString + '</div>';
      IWLblPrc1.Caption:= '<div align=center>'
	   + FormatFloat('#,0円',FieldByName('SPRICE').AsCurrency) + '</div>';
      Next;
    end;
    if not eof then
    begin
      fnm := FieldByName('CODE').AsString + '.JPG';
      IWImgTp2.Picture.LoadFromFile('c://img/' + fnm);
      IWLblNm2.Caption := '<div align=center>'
	   + FieldByName('NAME').AsString + '</div'>';
      IWLblPrc2.Caption:= '<div align=center>'
	   + FormatFloat('#,0円',FieldByName('SPRICE').AsCurrency) + '</div>';
      Next;
    end;
    if not eof then
    begin
      fnm := FieldByName('CODE').AsString + '.JPG';
      IWImgTp3.Picture.LoadFromFile('c://img/' + fnm);
      IWLblNm3.Caption := '<div align=center>'
	   + FieldByName('NAME').AsString + '</div>';
      IWLblPrc3.Caption:= '<div align=center>'
	   + FormatFloat('#,0円',FieldByName('SPRICE').AsCurrency) + '</div>';
      Next;
    end;
    Active := False;
  end;
end;

   
4/5