怎样让edit中的内容右对齐或居中?

解决方案 »

  1.   

    SetWindowLong(Edit1.handle, GWL_STYLE,GetWindowlong(edit1.Handle, GWL_STYLE) +ES_CENTER);
    SetWindowLong(Edit1.handle, GWL_STYLE,GetWindowlong(edit1.Handle, GWL_STYLE) +ES_RIGHT);看以前的帖子
    http://expert.csdn.net/Expert/topic/2067/2067579.xml?temp=8.785647E-02
      

  2.   

    firetoucher(风焱)的方法好!我用了!
      

  3.   

    继承TEdit,重载CreateParams,修改Param即可。 
    procedure TEdit_Ex.CreateParams(var Params: TCreateParams); 
    begin 
      inherited; 
      if self.FTextOnRight then Params.Style:=Params.Style or ES_RIGHT; 
    end;
      

  4.   

    firetoucher(风焱)的方法在我这里没有效果。环境:win2k+d6
      

  5.   

    我看帮助上面明明写着有的,为什么delphi6里没有  
    ---------------------------------------------------------------  
     
    其实可以自己做一个,我给你个吧,接着…………:)  
     
    //----------------------------------------------------  
    unit  WCAlignEdit;  
     
    interface  
     
    uses  
       Windows,  Messages,  SysUtils,  Classes,  Graphics,  Controls,  Forms,  Dialogs,  
       StdCtrls;  
     
    type  
       TWCAlignEdit  =  class(TEdit)  
       private  
           {  Private  declarations  }  
           FAlignment  :  TAlignment;  
       protected  
           {  Protected  declarations  }  
           procedure  SetAlignment(Value:  TAlignment);  
       public  
           {  Public  declarations  }  
           procedure  CreateParams(var  Params  :  TCreateParams);  override;  
       published  
           {  Published  declarations  }  
           property  Alignment:  TAlignment  read  FAlignment  write  SetAlignment  
               default  taLeftJustify;  
       end;  
     
    procedure  Register;  
     
    implementation  
     
    procedure  Register;  
    begin  
       RegisterComponents('Samples',  [TWCAlignEdit]);  
    end;  
     
    procedure  TWCAlignEdit.CreateParams(var  Params  :  TCreateParams);  
    begin  
       inherited  CreateParams(Params);  
       case  FAlignment  of  
           taRightjustify:  params.style  :=  params.style  or  es_right;  
           taLeftjustify  :  params.style  :=  params.style  or  es_left;  
           taCenter            :  params.style  :=  params.style  or  es_center;  
       end;  
    end;  
     
    procedure  TWCAlignEdit.SetAlignment;  
    begin  
       if  FAlignment  <>  Value  then  
       begin  
           FAlignment  :=  Value;  
           RecreateWnd;  
       end;  
    end;  
     
     
    end.
      

  6.   

    我的win2000+dephi6用firetoucher(风焱)的方法也不行,是不是我的系统或是dephi有问题呢?
      

  7.   

    SetWindowLong(Edit1.handle, GWL_STYLE,GetWindowlong(edit1.Handle, GWL_STYLE) +ES_CENTER);
    Edit1.Refresh;
    SetWindowLong(Edit1.handle, GWL_STYLE,GetWindowlong(edit1.Handle, GWL_STYLE) +ES_RIGHT);
    Edit1.Refresh;————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  8.   

    lxpbuaa(桂枝香在故国晚秋) 
    方法好像不可行
      

  9.   

    我有控件楼主要不要,
    if You want then
     Send me!