🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12222

Re: Alignment.

#12222
From: Safari
Date: Tue, 16 Dec 2003 09:21
103 lines
4129 bytes
Very thanks JD,
Safari

"JD" <nospam@nospam.com> wrote in message
news:3fdc6187$1@newsgroups.borland.com...
|
| "Safari" <Safari@alloymail.com> wrote:
| > I want to have a TEdit with taCenter alignment,
|
| You could use the SetWindowLong() function or subclass the
| TEdit and dynamically allocate the object:
|
| class TCEdit : public TEdit
| {
|     public:
|         __fastcall TCEdit( TComponent* Owner ) : TEdit( Owner )
|         {
|         }
|         void __fastcall CreateParams( TCreateParams& Params )
|         {
|           TEdit::CreateParams( Params );
|           Params.Style |= ES_CENTER;
|         }
| };
|
| TCEdit* CenteredEdit = new TCEdit( this );
|
| Note : you can also use the same code to make a right-aligned
| edit by replacing ES_CENTER with ES_RIGHT (and changing the
| name of course).
|
|
| OR derive your own component and install it to a package. Click Component
| New Component and make the code look like this:
|
| //---- header
| //-------------------------------------------------------------
| #ifndef CEditH
| #define CEditH
| //-------------------------------------------------------------
| #include <SysUtils.hpp>
| #include <Classes.hpp>
| #include <Controls.hpp>
| #include <StdCtrls.hpp>
| //-------------------------------------------------------------
| class PACKAGE TCEdit : public TEdit
| {
| private:
| protected:
| public:
|         __fastcall TCEdit(TComponent* Owner);
|    virtual void __fastcall CreateParams( TCreateParams& Params );
| __published:
| };
| //-------------------------------------------------------------
| #endif
| //-- cpp
| //-------------------------------------------------------------
| #include <vcl.h>
|
| #pragma hdrstop
|
| #include "CEdit.h"
| #pragma package(smart_init)
| //-------------------------------------------------------------
| // ValidCtrCheck is used to assure that the components created do not have
| // any pure virtual functions.
| //
|
| static inline void ValidCtrCheck(TCEdit *)
| {
|         new TCEdit(NULL);
| }
| //-------------------------------------------------------------
| __fastcall TCEdit::TCEdit(TComponent* Owner) : TEdit(Owner)
| {
| }
| //-------------------------------------------------------------
| void __fastcall TCEdit::CreateParams( TCreateParams& Params )
| {
|     TEdit::CreateParams( Params );
|     Params.Style = Params.Style | ES_CENTER; // ES_MULTILINE;
| }
| //-------------------------------------------------------------
| namespace Cedit
| {
|         void __fastcall PACKAGE Register()
|         {
|                  TComponentClass classes[1] = {__classid(TCEdit)};
|                  RegisterComponents("Samples", classes, 0);
|         }
| }
| //-------------------------------------------------------------
|
| Then save the files and click Component | Install Component
| and select a new package that you will provide the name for.
|
| Also note that not all versions of Windows support ES_CENTER
| and ES_RIGHT for single-line edit controls. The alternative is
| to use a TMemo instead, sized to a single line, and disable the
| Enter key and strip out carriage returns when pasting text.
|
| ~ JD
Technical Details
Message-ID: <3fdf87d4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fdc4d0c@newsgroups.borland.com> <3fdc6187$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,5ff3c30c3de5a5e
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-16 14:40:07 PST
From: "Safari" <Safari@alloymail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <3fdc4d0c@newsgroups.borland.com> <3fdc6187$1@newsgroups.borland.com>
Subject: Re: Alignment.
Date: Tue, 16 Dec 2003 12:51:16 +0330
Lines: 105
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 194.225.63.168
Message-ID: <3fdf87d4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1071613908 194.225.63.168 (16 Dec 2003 14:31:48 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail