Center Text horizontally in TEdit lazarus / 1-Linux ---------------------------------------------------------------------- Bruno45 · 2008-06-09 10:10 Hi How do I center text horizontally in a TEdit control? I would very appreciate a solution that works with Linux and Windows (perhaps with IFDEFs) Thanks Bruno ---------------------------------------------------------------------- Phil · 2008-06-09 14:51 Quote from: "Bruno45"Hi How do I center text horizontally in a TEdit control? I would very appreciate a solution that works with Linux and Windows (perhaps with IFDEFs) Thanks Bruno Hi Bruno, The TEdit control does not have the Alignment property like TLabel and others. However, the Orpheus TO32FlexEdit control does have Alignment and this works fine with Delphi when you set Alignment to taCenter. But I just tested it with Lazarus and it doesn't work. You might look at the code in O32FlxEd.pas. TO32FlexEdit is a descendent of TCustomEdit but maybe the LCL version of TCustomEdit doesn't support this. Look at CreateParams - it's setting ES_CENTER okay. http://wiki.lazarus.freepascal.org/OrphPort Thanks. -Phil ---------------------------------------------------------------------- felipemdc · 2008-06-09 15:59 I think they used a too Windows specific method to write their TO32FlexEdit. There is no guarantee that the different underlaying widgetsets support centralizing the text in their native edit controls. The better way would have been to create a TCustomControl descendent. ---------------------------------------------------------------------- Phil · 2008-06-09 16:16 Quote from: "sekel"I think they used a too Windows specific method to write their TO32FlexEdit. There is no guarantee that the different underlaying widgetsets support centralizing the text in their native edit controls. The better way would have been to create a TCustomControl descendent. Actually, Orpheus includes TOvcSimpleField, which is a TCustomControl descendant. But it doesn't work at all on any widgetset except win32, whereas TO32FlexEdit mostly works fine on all widgetsets. So I'm not so sure what you suggest is a better approach. Thanks. -Phil ---------------------------------------------------------------------- felipemdc · 2008-06-09 19:55 TCustomControl is by nature the most portable approach to build custom controls, and that's why SynEdit, for example, uses it. One would have to research why TOvcSimpleField doesn't work, but I'm sure this doesn't contradict my phrase. If this control would use only TCustomControl and Canvas routines, it would work. It's obviously using something else that causes the problems. ---------------------------------------------------------------------- Phil · 2008-06-10 01:13 Quote from: "sekel"TCustomControl is by nature the most portable approach to build custom controls, and that's why SynEdit, for example, uses it. One would have to research why TOvcSimpleField doesn't work, but I'm sure this doesn't contradict my phrase. If this control would use only TCustomControl and Canvas routines, it would work. It's obviously using something else that causes the problems. So what are you suggesting, that Bruno go back in time before Lazarus even existed and convince the TurboPower developers that they did it all wrong? Does TEdit use only TCustomControl and Canvas? No, it wraps the widgetset native edit controls. Meanwhile, back in the present, would you like to help Bruno and others by improving TO32FlexEdit? It has some nice features that don't work on Lazarus: (1) Alignment property for text and also right-to-left support. I imagine most native edit controls support this in some fashion. (2) Validation. Really sweet and clean, only it doesn't work on non- Windows, probably because other widgetsets don't implement Get/SetWindowLong or CallWindowProc correctly. I used your workaround for lack of MakeObjectInstance to get validation to work on Windows with Lazarus so this should work with other widgetsets too, only these other functions would need to work. (3) A button that appears inside the edit area that you can click to display a dialog box or whatever you want. But this isn't supported by the LCL. Thanks. -Phil ---------------------------------------------------------------------- felipemdc · 2008-06-10 01:26 Quote from: "Phil"So what are you suggesting, that Bruno go back in time before Lazarus even existed and convince the TurboPower developers that they did it all wrong? That isn't funny. Really, I wouldn't expect this kind of comment from you. I was sugesting that it would be much more sensible for someone interrested in having such a control to fix TOvcSimpleField instead, or create a new control based on TCustomControl. But you are free do disagree. Just do it politely. ---------------------------------------------------------------------- Phil · 2008-06-10 02:58 Quote from: "sekel"But you are free do disagree. Just do it politely. All right, the problem with TCustomControls is that you have to do everything yourself, painting, cursor, clipboard, internationalization, etc. TOvcSimpleField's validation is a hack, whereas TO32FlexEdit's is pretty clean. If Orpheus is any indication, you may write about 2-3x more code creating a custom control from scratch compared to inheriting from an existing control and then teaching it some new tricks. In the Orpheus documentation, they indicate that they were moving away from TOvcSimpleField toward TO32FlexEdit shortly before they got out of the tools business altogether. To quote: "New in Orpheus 4 is the TO32FlexEdit, O32*Validators, and the O32ValidatorPool. They represent the future of Orpheus data-entry..." Certainly there are times when nothing short of building something up completely from TCustomControl will do. But this is really, really a lot of work. For example, how many years have people been plinking away at SynEdit, trying to get it right? Thanks. -Phil ---------------------------------------------------------------------- Zaher · 2008-06-11 15:12 Quote from: PhilAlignment property for text and also right-to-left support. I imagine most native edit controls support this in some fashion. As like BidiMode founded in TEdit but not supported by all platforms for example WinCE (not yet), that mean not worked in WinCE. I think Alignment must found in TEdit even not in all platforms support it (but i think it must).