今天见到了兄弟“红烧猪头”的贴子,不知道从何说起。
散分吧.....
带上一点代码(手头正写的).....//版主会扔掉这个贴子吗?
------------------------------------------------------------------function TForm1.GetSGWidth: Integer;
Var
Col_Value : Integer;
Sum_Value : Integer;
begin
Sum_Value := 0;
For Col_Value := 0 to StringGrid1.ColCount - 1 do
Inc(Sum_Value,StringGrid1.ColWidths[Col_Value]);
Result := Sum_Value;
end;function TForm1.GetStringCol: Integer;
begin
Result := StringGrid1.ColCount;
end;function TForm1.GetStringRow: Integer;
begin
Result := StringGrid1.RowCount;
end;procedure TForm1.HeaderControl1SectionResize(HeaderControl: THeaderControl;
Section: THeaderSection);
var
I : Integer;
begin
StringGrid1.ColWidths[Section.Index] := Section.Width - 1;
StringGrid1.Width := GetSGWidth + 7;
StringGrid1.Height := GetSGHeight + 7;
end;procedure TForm1.InitStringGridHB(Cols_Value, Rows_Value: Integer);
var
I : Integer;
begin
with StringGrid1 , HeaderControl1 do
begin
For I := 0 to Cols_Value - 1 do
begin
with Sections.Add do
begin
Width := 51;
StringGrid1.ColWidths[I] := 50;
end;
end;
end;
end;procedure TForm1.SetArray_StringCol(Cols_Value: Integer);
begin
SetLength(FColsArray,Cols_Value);
end;procedure TForm1.SetGridInfo(Col_Value, Row_Value: Integer;
Text_Value: String);
begin
StringGrid1.Cells[Col_Value,Row_Value] := Text_Value;
end;procedure TForm1.SetGrid_ColsWidth(Cols_Array: array of Integer);
var
Index : Integer;
begin
For Index := Low(FColsArray) to High(FColsArray) do
begin
FColsArray[Index] := Cols_Array[Index];
end;
end;procedure TForm1.SetGrid_Title(Cols_Value, Rows_Value: Integer;
Title_Value: array of String);
begin
//..
FColCount := Cols_Value;
FRowCount := Rows_Value;
SetStringRow(Rows_Value);
SetStringCol(Cols_Value);
SetSGWidth(GetSGWidth);
SetArray_StringCol(Cols_Value);//设置数组宽度;(不专业的说:数组大小)
InitStringGridHB(Cols_Value,Rows_Value);
SetTitleInfo(Title_Value);//设置头信息(Text)
end;procedure TForm1.SetSGWidth(ASGWidth: Integer);
begin
FSGWidth := ASGWidth;
StringGrid1.Width := FSGWidth;
end;procedure TForm1.SetStringCol(AColCount: Integer);
begin
FColCount := AColCount;
StringGrid1.ColCount := AColCount;
end;procedure TForm1.SetStringRow(ARowCount: Integer);
begin
FRowCount := ARowCount;
StringGrid1.RowCount := ARowCount;
end;procedure TForm1.SetTitleInfo(Title_Value: array of String);
var
Index : Integer;
begin
For Index := Low(Title_Value) to High(Title_Value) do
begin
HeaderControl1.Sections[Index].Text := Title_Value[Index];
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
Col_Value , Row_Value :Integer;
begin
SetGrid_Title(6 , 6,['11111','22222','33333','44444','55555','66666']);
For Col_Value := 0 to GetSGWidth - 1 do
For Row_Value := 0 to GetSGHeight - 1 do
SetGridInfo(Col_Value,Row_Value,'一二三四' + IntToStr(Col_Value) );
StringGrid1.Width := GetSGWidth + 7;
StringGrid1.Height := GetSGHeight + 7;
end;Function TForm1.GetSGHeight:Integer;
Var
Row_Value : Integer;
Sum_Value : Integer;
begin
Sum_Value := 0;
For Row_Value := 0 to StringGrid1.RowCount - 1 do
Inc(Sum_Value,StringGrid1.RowHeights[Row_Value]);
FSGHeight := Sum_Value;
Result := FSGHeight;
end;{
if (ACol = 2) and (ARow = 3) then//是周日或周六 then
begin
Canvas.Brush.Color := clRed;
Canvas.FillRect(Rect);
Canvas.Font.Name := 'Courier New';
Canvas.Pen.Color := ClTeal;
Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end ;
给颜色 DT_LEFT = 0;
DT_CENTER = 1;
DT_RIGHT = 2;
DT_VCENTER = 4;
}procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
//..
DrawCell(Sender,ACol,ARow,Rect,State,StringGrid1);
//DrawCell(Sender,ACol,ARow,Rect,State,StringGrid1);
end;function TForm1.IsCellSelected(StringGrid: TStringGrid; X,
Y: Integer): BOOLEAN;
begin
Result := false;
try
if (X >= StringGrid.Selection.Left) and (X <= StringGrid.Selection.Right) and
(Y >= StringGrid.Selection.Top) and (Y <= StringGrid.Selection.Bottom) then
Result := true;
except
end;
end;procedure TForm1.WriteText(ACanvas: TCanvas; const ARect: TRect; DX,
DY: Integer; const Text: string; Format: Word);
var
S: array[0..255] of Char;
B, R: TRect;begin
with ACanvas, ARect do
begin
case Format of
DT_LEFT : ExtTextOut(Handle, Left + DX, Top + DY, ETO_OPAQUE or
ETO_CLIPPED, @ARect, StrPCopy(S, Text),
length(Text), nil);
DT_RIGHT : ExtTextOut(Handle, Right - TextWidth(Text) - 3, Top + DY,
ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text), Length(Text), nil);
DT_CENTER : ExtTextOut(Handle, Left + (Right - Left - TextWidth(Text)) div 2, Top + DY, ETO_OPAQUE or ETO_CLIPPED, @ARect,
StrPCopy(S, Text), Length(Text), nil);
end;
end;
end;procedure TForm1.DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState; StringGrid: TStringGrid);
var
R: TRect;
begin
with TStringGrid(StringGrid) do
begin
with TStringGrid(StringGrid),TStringGrid(StringGrid).Canvas do
begin
FillRect(Rect);
R := Rect;
InflateRect(R, -2, -2);
if (ACol = 1) and (ARow = 3) then DrawText(Handle, PChar(Cells[ACol, ARow]),
Length(Cells[ACol, ARow]), R, DT_CENTER)
else TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
end;
end;procedure TForm1.SetGridViewFormat(ColArray: array of Integer;
ViewFormat: Integer);
begin
//..
end;
----------------------------------------------------------------------
csdn的人气会如何呢?应该不错的:)
散分吧.....
带上一点代码(手头正写的).....//版主会扔掉这个贴子吗?
------------------------------------------------------------------function TForm1.GetSGWidth: Integer;
Var
Col_Value : Integer;
Sum_Value : Integer;
begin
Sum_Value := 0;
For Col_Value := 0 to StringGrid1.ColCount - 1 do
Inc(Sum_Value,StringGrid1.ColWidths[Col_Value]);
Result := Sum_Value;
end;function TForm1.GetStringCol: Integer;
begin
Result := StringGrid1.ColCount;
end;function TForm1.GetStringRow: Integer;
begin
Result := StringGrid1.RowCount;
end;procedure TForm1.HeaderControl1SectionResize(HeaderControl: THeaderControl;
Section: THeaderSection);
var
I : Integer;
begin
StringGrid1.ColWidths[Section.Index] := Section.Width - 1;
StringGrid1.Width := GetSGWidth + 7;
StringGrid1.Height := GetSGHeight + 7;
end;procedure TForm1.InitStringGridHB(Cols_Value, Rows_Value: Integer);
var
I : Integer;
begin
with StringGrid1 , HeaderControl1 do
begin
For I := 0 to Cols_Value - 1 do
begin
with Sections.Add do
begin
Width := 51;
StringGrid1.ColWidths[I] := 50;
end;
end;
end;
end;procedure TForm1.SetArray_StringCol(Cols_Value: Integer);
begin
SetLength(FColsArray,Cols_Value);
end;procedure TForm1.SetGridInfo(Col_Value, Row_Value: Integer;
Text_Value: String);
begin
StringGrid1.Cells[Col_Value,Row_Value] := Text_Value;
end;procedure TForm1.SetGrid_ColsWidth(Cols_Array: array of Integer);
var
Index : Integer;
begin
For Index := Low(FColsArray) to High(FColsArray) do
begin
FColsArray[Index] := Cols_Array[Index];
end;
end;procedure TForm1.SetGrid_Title(Cols_Value, Rows_Value: Integer;
Title_Value: array of String);
begin
//..
FColCount := Cols_Value;
FRowCount := Rows_Value;
SetStringRow(Rows_Value);
SetStringCol(Cols_Value);
SetSGWidth(GetSGWidth);
SetArray_StringCol(Cols_Value);//设置数组宽度;(不专业的说:数组大小)
InitStringGridHB(Cols_Value,Rows_Value);
SetTitleInfo(Title_Value);//设置头信息(Text)
end;procedure TForm1.SetSGWidth(ASGWidth: Integer);
begin
FSGWidth := ASGWidth;
StringGrid1.Width := FSGWidth;
end;procedure TForm1.SetStringCol(AColCount: Integer);
begin
FColCount := AColCount;
StringGrid1.ColCount := AColCount;
end;procedure TForm1.SetStringRow(ARowCount: Integer);
begin
FRowCount := ARowCount;
StringGrid1.RowCount := ARowCount;
end;procedure TForm1.SetTitleInfo(Title_Value: array of String);
var
Index : Integer;
begin
For Index := Low(Title_Value) to High(Title_Value) do
begin
HeaderControl1.Sections[Index].Text := Title_Value[Index];
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
Col_Value , Row_Value :Integer;
begin
SetGrid_Title(6 , 6,['11111','22222','33333','44444','55555','66666']);
For Col_Value := 0 to GetSGWidth - 1 do
For Row_Value := 0 to GetSGHeight - 1 do
SetGridInfo(Col_Value,Row_Value,'一二三四' + IntToStr(Col_Value) );
StringGrid1.Width := GetSGWidth + 7;
StringGrid1.Height := GetSGHeight + 7;
end;Function TForm1.GetSGHeight:Integer;
Var
Row_Value : Integer;
Sum_Value : Integer;
begin
Sum_Value := 0;
For Row_Value := 0 to StringGrid1.RowCount - 1 do
Inc(Sum_Value,StringGrid1.RowHeights[Row_Value]);
FSGHeight := Sum_Value;
Result := FSGHeight;
end;{
if (ACol = 2) and (ARow = 3) then//是周日或周六 then
begin
Canvas.Brush.Color := clRed;
Canvas.FillRect(Rect);
Canvas.Font.Name := 'Courier New';
Canvas.Pen.Color := ClTeal;
Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end ;
给颜色 DT_LEFT = 0;
DT_CENTER = 1;
DT_RIGHT = 2;
DT_VCENTER = 4;
}procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
//..
DrawCell(Sender,ACol,ARow,Rect,State,StringGrid1);
//DrawCell(Sender,ACol,ARow,Rect,State,StringGrid1);
end;function TForm1.IsCellSelected(StringGrid: TStringGrid; X,
Y: Integer): BOOLEAN;
begin
Result := false;
try
if (X >= StringGrid.Selection.Left) and (X <= StringGrid.Selection.Right) and
(Y >= StringGrid.Selection.Top) and (Y <= StringGrid.Selection.Bottom) then
Result := true;
except
end;
end;procedure TForm1.WriteText(ACanvas: TCanvas; const ARect: TRect; DX,
DY: Integer; const Text: string; Format: Word);
var
S: array[0..255] of Char;
B, R: TRect;begin
with ACanvas, ARect do
begin
case Format of
DT_LEFT : ExtTextOut(Handle, Left + DX, Top + DY, ETO_OPAQUE or
ETO_CLIPPED, @ARect, StrPCopy(S, Text),
length(Text), nil);
DT_RIGHT : ExtTextOut(Handle, Right - TextWidth(Text) - 3, Top + DY,
ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text), Length(Text), nil);
DT_CENTER : ExtTextOut(Handle, Left + (Right - Left - TextWidth(Text)) div 2, Top + DY, ETO_OPAQUE or ETO_CLIPPED, @ARect,
StrPCopy(S, Text), Length(Text), nil);
end;
end;
end;procedure TForm1.DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState; StringGrid: TStringGrid);
var
R: TRect;
begin
with TStringGrid(StringGrid) do
begin
with TStringGrid(StringGrid),TStringGrid(StringGrid).Canvas do
begin
FillRect(Rect);
R := Rect;
InflateRect(R, -2, -2);
if (ACol = 1) and (ARow = 3) then DrawText(Handle, PChar(Cells[ACol, ARow]),
Length(Cells[ACol, ARow]), R, DT_CENTER)
else TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
end;
end;procedure TForm1.SetGridViewFormat(ColArray: array of Integer;
ViewFormat: Integer);
begin
//..
end;
----------------------------------------------------------------------
csdn的人气会如何呢?应该不错的:)
两种方法:一种是通过Active Form解决,还有一种就是通过写COM组件;具体的B/S也要看是什么语言写的,如果用Delphi写的话,就不必讨论用什么好了,如果要是想通用一些而且速度快一些,用Active Form来的快;当然,COM是解决的最终办法;你认为呢?
我现在这个是Active Form//之前写的两个也是Active Form{发行、数字签名都没有问题,下一步想COM做,说一说你的看法}
我做的是For Jsp的,以后要用到C# 和 Java上
呵呵,在宁夏就这样,工资不定的,有时高有时低,没有定数。换了公司后,环境的确比以前好多了,不过,我以前的那个公司的一个半月的工资都没有拿,也不好意思去拿,是得是失,谁知道,哈.......
好好努力哦,你不错的。
是为了给其它语言留有接口而设的:)
To TOMWLD(笑天)
用COM ,当用到TypeLib的时候,接口之间的调用会使你的工作变的很得心应手;
我也正在尝试用COM作,呵呵,也是菜头一个。
是你?
又搞了一大段代码出来晕人
我还没有用过TStringGrid哈哈哈
因为这将是一个组件(For JSP的),所以要留接口给用户,而且接口都有说明,甚至某一接口的改变不会影响其它的接口,如下:
{ Private declarations }
Result_C : Array of Integer; //需要进行格试化的列(居中)
Result_R : Array of Integer; //需要进行格式化的列(右)
FFormat : Integer;//返回是行或列或是行和列进行格式化;
Function GetSGWidth :Integer;//获得StirngGrid的宽度
Procedure SetSGWidth(ASGWidth : Integer);//设置StirngGrid的宽度
Procedure InitStringGridHB(Cols_Value, Rows_Value: Integer);
//对StringGrid and HeaderControl进行设置(初始化)
Procedure SetStringCol(AColCount : Integer);//设置StringGrid的列数;
Function GetStringCol:Integer;//获得StringGrid的列数
Procedure SetStringRow(ARowCount : Integer);//设置StringGrid行数
Function GetStringRow : Integer;//获得StringGrid 行数
Procedure SetArray_StringCol(Cols_Value : Integer);//设置StringGrid ColCount数组
Procedure SetTitleInfo(Title_Value : Array of String); //设置头信息(Text)
Function GetSGHeight:Integer; //获得StirngGrid的高度
function IsCellSelected(StringGrid : TStringGrid; X, Y : LONGINT): BOOLEAN;
{判断单元格是否被选中 X 列,Y 行);}
Function ReturnV_CR(Array_Value : Array of Integer):Integer;
//Function Return
//得到其要操作的列或行
public
{ Public declarations }
FSGWidth : Integer;//StringGrid 宽
FSGHeight : Integer;//StringGird 高
FWidth : Integer;//StringGrid -> Cols宽(列数总宽)
FColCount : Integer;//StringGrid 列数;
FRowCount : Integer;//StringGrid 行数;
FColsArray : Array of Integer; //纪录StringGrid每一列的宽度;
Procedure SetGrid_Title(Cols_Value , Rows_Value : Integer ;
Title_Value : Array of String); //初始化StringGrid Title(即 HeaderControl)
Procedure SetGrid_ColsWidth(Cols_Array :Array of Integer); //设置数组的每列宽度;
Procedure SetGridInfo(Col_Value , Row_Value : Integer ; Text_Value : String);
procedure WriteText(ACanvas: TCanvas; const ARect: TRect; DX, DY: Integer;
const Text: string; Format: Word);//字符串网格文字输出的对齐
{设置StringGrid的文本信息}
Procedure DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState ;StringGrid : TStringGrid );
//StringGrid Draw Cell;
Procedure SetGridViewFormat(ColArray_R : Array of Integer ;
ColArray_C : Array of Integer);//设置列的显示信息;在者,每一个函数或过程一般不会太长,都在三十行之下。
Result_R : Array of Integer; //定义一动态数组,共用变量
Function R_ResultV(ColArray_RV : Array of Integer;
ColArray_CV : Array of Integer):Integer;
begin
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV));
.....
end;
如果程序中调用:R_ResultV([1,3],[2,4]) ...
看一看下边的值是什么?为什么呢?
ShowMessage(IntToStr(High(Result_R)));
ShowMessage(IntToStr(Low(Result_R)));
{------------------------程序片段截取--------------------------}
麻烦你看一看问题,就是那个动态数组的那个啊。
试一试:
新建一个工程:
....
public
{ Public declarations }
Result_R : Array of Integer; //定义一动态数组,共用变量
Procedure R_ResultV(ColArray_RV : Array of Integer;
ColArray_CV : Array of Integer);
end;
.....
procedure TForm1.R_ResultV(ColArray_RV, ColArray_CV: array of Integer);
var
Index : Integer;
begin
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV));
For Index := Low(ColArray_RV) to High(ColArray_RV) do
Result_R[Index] := ColArray_RV[Index];
end;procedure TForm1.Button1Click(Sender: TObject);
begin
R_ResultV([12,32],[22,43]);
ShowMessage(IntToStr(Result_R[1]));
ShowMessage(IntToStr(High(Result_R)));
ShowMessage(IntToStr(Low(Result_R)));
end;
麻烦,现在就试试,关键给个说法啊;
procedure TForm1.R_ResultV(ColArray_RV, ColArray_CV: array of Integer);
var
Index : Integer;
begin
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV));
For Index := Low(ColArray_RV) to High(ColArray_RV) do
Result_R[Index] := ColArray_RV[Index];
end;procedure TForm1.Button1Click(Sender: TObject);
begin
R_ResultV([12,32],[22,43]);
ShowMessage(IntToStr(Result_R[1]));
ShowMessage(IntToStr(High(Result_R)));
ShowMessage(IntToStr(Low(Result_R)));
end;会越界吧?
动态数组以0为起始下标,这样应该可以:
procedure TForm1.R_ResultV(ColArray_RV, ColArray_CV: array of Integer);
var
Index : Integer;
begin
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV));
For Index := 0 to High(ColArray_RV)-Low(ColArray_RV) do
Result_R[Index] := ColArray_RV[Index+Low(ColArray_RV)];
end;
你没有明白我的意思...
谢谢:)
我是很久没到csdn了
最近忙
^_^
以后还得多和你们学习
落后ing
不会吧,真的是你???狂喜,好久不见的朋友了............
过的可好啊?做什么着呢?哎,找个时间好好的聊一聊.......
亲一口,啵~~~~~~~~~~~~~~~
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV));
这句仅将Result_R长度设置为1,也就是只有Result_R[0]申请了空间,
所以第一个ShowMessage有越界的嫌疑,其它几个ShowMessage显示均为0
有友自远方来,不亦乐乎,哈..........
明年的明年看还有没有明年,如果那时要是没有明年的话,就去北京....
你乱改名子做什么啊?害的我想啊想.........To Borlandor(五角大民)
3Q;
procedure TForm1.R_ResultV(ColArray_RV, ColArray_CV: array of Integer);
var
Index : Integer;
begin
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV) + 1);
For Index := Low(ColArray_RV) to High(ColArray_RV) do
Result_R[Index] := ColArray_RV[Index+Low(ColArray_RV)];
end;而
procedure TForm1.R_ResultV(ColArray_RV, ColArray_CV: array of Integer);
var
Index : Integer;
begin
SetLength(Result_R , High(ColArray_RV) - Low(ColArray_RV));
For Index := 0 to High(ColArray_RV)-Low(ColArray_RV) do
Result_R[Index] := ColArray_RV[Index+Low(ColArray_RV)];
end;
还会犯越界操作:(
太菜,看不懂,我只给vb写过组件,给讲讲好吗?
你看一看VCL源代码,肯定也会说:“我不欣赏如此冗长的代码函数、事件的罗列,看起来太费劲了,尽管你的咚咚写得很好!”
我一般将过程和函数控制在30行以下。
咋办,兄弟们给点建议吧!—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂ ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃ ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛ ▲自动添加签名......让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip
你的朋友真多呀,得到你帮助的站的比例不小吧,学了好长时间了,还是不能登堂入室,感觉前进很困难,算了,郁闷的心情谁都有,问问题吧,
我一直在找关于Active Form的数字签名方面的书,可没找到,看前面的帖子中,你提到过,能否给详细讲一下,在Delphi中如何对Active Form进行数字签名,
还有,你说你在给JSP写控件,我在JAVA中也有同样的问题,就是如何给Applet进行数字签名,看过一些有关的知识,可是太复杂了,看了头晕,
以上问题,请您给讲讲,
只剩下40分了,这下又剩下了,还可以多问几个问题了,呵呵,先谢了
我给你发一份。
[email protected]
请您多加点儿说明,我很笨的
是我,^_^,我现在正在准备接一个项目,主要是警力布控的,这回倒好,就我一个人干,公司倒是很信任,我可忙了!!还得和我们公司的产品结合起来,工作量不小!!^_^
如果实在不行,你可以用QQ发给我,我的QQ--10014618
收信....
今天俺们这里下大雪,来的突然,天气骤冷,呵呵,来这里烤烤火!ihihonline,您老的代码俺实在看不明白,给个完整的程序看看可以吗!Q---->175322659