DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: luismasgoret
今日帖子: 40
在线用户: 8
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 dada2000 (dada2000) ★☆☆☆☆ -
盒子活跃会员
2004/4/24 21:50:56
标题:
难到真的没人知道吗?高手,高手,在那里啊,急救SOS。SOS。。。。 浏览:1440
加入我的收藏
楼主: 图片上的按钮用的是什么控件啊?
 
给定一行显示n个按钮,一列显示m个,怎样使它自动调整宽和高,且排列均匀?
此帖子包含附件:
JPEG 图像
大小:52.3K
----------------------------------------------
-
作者:
男 flyers (flyers) ★☆☆☆☆ -
普通会员
2004/4/25 0:08:28
1楼: 难,太难……
----------------------------------------------
大家好,我是Flyers。

是Delphi.Net版主,小弟会尽力解决大家的问题!谢谢支持!
作者:
男 ynzbf (过河卒子) ★☆☆☆☆ -
盒子活跃会员
2004/4/25 1:02:54
2楼: 不知道,如果找到了也给我一个,谢谢
----------------------------------------------
┏━━┓我      ●╭○╮   我┏━━┓
┃天长┃想°☆ /█∨█\ ☆ 爱┃海枯┃
┃地久┃你      ∏  ∏     你┃石烂┃
┗━━┛   ·☆爱你一生☆·  ┗━━┛
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/4/25 8:03:59
3楼: unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure OnAddControl(const AControl: TControl; const ACol, ARow: Integer);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// 按钮之间的间距
const
  RowSpace = 8;
  ColSpace = 8;

type
  TAddControlEvent = procedure(const AControl: TControl; const ACol, ARow: Integer) of object;

procedure CreateControls(AOwner: TWinControl; const R: TRect; const ACol, ARow: Integer;
  AClass: TControlClass; OnAdd: TAddControlEvent = nil);
var
  H, W: Integer;
  I, J: Integer;
  X, Y: Integer;
  Ctrl: TControl;
begin
  if not Assigned(AOwner) then Exit;
  if not Assigned(AClass) then Exit;
  if (ARow < 1 ) or (ACol < 1) then Exit;

  H := (R.Bottom - R.Top - (ARow + 1) * RowSpace) div ARow;
  W := (R.Right - R.Left - (ACol + 1) * ColSpace) div ACol;
  if (H < 1) or (W < 1) then Exit;

  for I := 0 to ARow - 1 do
    for J := 0 to ACol - 1 do
    begin
      Ctrl := AClass.Create(AOwner);
      with Ctrl do
      begin
        Parent := AOwner;
        X := (J + 1) * ColSpace + J * W;
        Y := (I + 1) * RowSpace + I * H;
        BoundsRect := Rect(X, Y, X + W, Y + H);

        if Assigned(OnAdd) then OnAdd(Ctrl, J, I);
        Show;
      end;
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  CreateControls(Self, ClientRect, 5, 5, TListBox, OnAddControl);
end;

procedure TForm1.OnAddControl(const AControl: TControl; const ACol, ARow: Integer);
begin
  TListBox(AControl).Items.Add('Col' + IntToStr(ACol) + ' : ' + 'Row' + IntToStr(ARow));
end;

end.

end.

----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/4/25 8:13:33
4楼: 如果要创建按钮,改一下就好了

procedure TForm1.FormCreate(Sender: TObject);
begin
  CreateControls(Self, ClientRect, 5, 5, TButton, OnAddControl);
end;

procedure TForm1.OnAddControl(const AControl: TControl; const ACol, ARow: Integer);
begin
  TButton(AControl).Caption ;= 'Col' + IntToStr(ACol) + ' : ' + 'Row' + IntToStr(ARow);
end;
此帖子包含附件:
JPEG 图像
大小:44.5K
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 hotyei (青出于蓝) ★☆☆☆☆ -
盒子活跃会员
2004/4/25 10:08:17
5楼: sephil 的可以啊。这种代码是应该自己写的,不会有现成的控件,因为太不通用了。不过这种情况我更喜欢用TStringGrid。
此帖子包含附件:
JPEG 图像
大小:53.9K
----------------------------------------------
米软科技有限公司http://www.szmesoft.com
作者:
男 regspy (幻影之芯) ★☆☆☆☆ -
盒子活跃会员
2004/4/25 11:47:50
6楼: sephil 的窗体用的是什么控件?
----------------------------------------------
---------------------
世间万物空如幻
来去此间只留影
---------------------
幻影之芯(rEgSpy/CGG) 

CGG WEB http://Www.CGG.Name
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/4/25 12:30:45
7楼: 不是控件
我的系统是XP
这是XP的Theme
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 dada2000 (dada2000) ★☆☆☆☆ -
盒子活跃会员
2004/4/25 18:52:07
8楼:  如果按钮间的距离都不给定,而是创建时自动调整,可不可以通过什么方法实现啊?
----------------------------------------------
-
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/4/25 18:58:55
9楼: 不行的
因为上面的动态生成的控件大小和位置是动态的,是根据间距来计算的
不给定间距那么动态生成的控件的大小和位置就不能确定的

当然如果动态生成的控件的大小是固定的那么也可以
上面的代码改改就行了
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 dada2000 (dada2000) ★☆☆☆☆ -
盒子活跃会员
2004/4/25 19:12:14
10楼: 是可以实现的,这个软件我有,它上面就有这个功能,我就是想不出来他是怎么实现的
----------------------------------------------
-
作者:
男 restboy (枫☆白水煮大虾) ★☆☆☆☆ -
盒子活跃会员
2004/4/25 20:47:03
11楼: x+y=100
你能解这个方程式么?
总要有一个因素是确定的对不对?
----------------------------------------------
夫君子之行,静以修身,俭以养德.非澹泊无以明志, 
非宁静无以致远.夫学须静也,才须学也,非学无以广才,
非志无以成学,淫漫则不能励精,险躁则不能治性,年与时驰, 
意与日去,遂成枯落,多不接世,悲守穷庐,将复何及!
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行1406.25毫秒 RSS