Edit如何居右排列?????
我在程序中加入:
SetWindowLong(Edit1-> Handle, GWL_STYLE, GetWindowLong(Edit1-> Handle, GWL_STYLE) | ES_RIGHT);
Edit1-> Invalidate();
为什么EDIT还是居左排列,这两行代码加不加没区别!!!!
请高手指教Edit如何居右排列?????
[解决办法]
这样你新建一个组件,就继承TEdit
class TYouEdit : public TEdit
{
....
virtual void __fastcall CreateParams(Controls::TCreateParams& Params);
virtual void __fastcall SetAlignment(Classes::TAlignment Value);
}
void __fastcall TYouEdit::CreateParams(TCreateParams& Params)
{
TEdit::CreateParams(Params);
long Alignments;
switch (FAlignment)
{
case taRightJustify:
Alignments = ES_RIGHT;
break;
case taLeftJustify:
Alignments = ES_LEFT;
break;
default:
Alignments = ES_CENTER;
break;
}
Params.Style = (Params.Style | ES_AUTOHSCROLL | Alignments) & (~ES_AUTOVSCROLL);
}
void __fastcall TYouEdit::SetAlignment(TAlignment Value)
{
if (FAlignment != Value)
{
FAlignment = Value;
RecreateWnd();
}
}
注册以后使用你的TYouEdit