打印本文 打印本文 关闭窗口 关闭窗口
组件制作之四(定制外观)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2424  更新时间:2009/4/23 18:34:08  文章录入:mintao  责任编辑:mintao

  FMargin:=0;

  BorderStyle:=bsNone;

  height:=150;

  width:=200;

end;

 

procedure TCoolMemo.setMargin(Value:byte);

var

  Rect: TRect;

begin

//该消息取得客户区的尺寸

  SendMessage(Handle, EM_GETRECT, 0, Longint(@Rect));

  //以下是重新确定尺寸

  Rect.Top := Value;

  Rect.Left := Value;

  Rect.Right := Width -Value;

  Rect.Bottom := Height -Value;

//该消息设定客户区的大小

  SendMessage(Handle, EM_SETRECT, 0, Longint(@Rect));

  Fmargin:=value;

end;

 

function TCoolMemo.getPosition:TPosition;

var

  row,Col:longint;

  CBLines:longint;

  str:WideString;

begin

//该消息取得光标所在的行,

  row:= SendMessage(Handle,EM_LINEFROMCHAR,SelStart,0);

  //该消息取得光标所在行开始的位置,位置从第一行的0开始计数,

  //每过一个字符增加1,

  CBLines:=SendMessage(Handle,EM_LINEINDEX,row,0);

  //得到光标的所在行的所在列

  Col:=SelStart-CBLines;

  //为了解决中文的问题,需要用宽字符型来取得光标所在行

  //,行中光标所在列之前的字符串,这样可以解决中文列数的确定问题.

  str:=Copy(Lines[row],1,col);

  col:=Length(Str)+1;

  result.row:=row+1;

  result.col:=col;

end;

 

procedure TCoolMemo.setEdgeColor(Value:TCOlor);

begin

 if FEdgeColor<>value then

 begin

  FEdgeColor:=value;

  drawBorder;

 end;

end;

 

procedure TCoolMemo.setEnterColor(Value:TColor);

begin

 if FEnterColor<>value then

 begin

   FEnterColor:=value;

   drawBorder;

 end;

end;

 

procedure TCoolMemo.CMMouseEnter(var Message: TMessage);

begin

  inherited;

    MouseIn:= True;

    drawBorder;

end;

 

procedure TCoolMemo.CMMouseLeave(var Message:TMessage);

begin

  inherited;

  MouseIn:=False;

  drawBorder;

end;

 

procedure TCoolMemo.WMPaint (var Message: TMessage);

begin

  inherited;

  drawBorder;

end;

 

procedure TCoolMemo.WMNCCalcSize (var Message: TWMNCCalcSize);

begin

  inherited;

  InflateRect(Message.CalcSize_Params^.rgrc[0], -3, -3);

end;

 

procedure TCoolMemo.drawBorder;

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口