Announcement

Collapse
No announcement yet.

Textausrichtung in TEdit

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Textausrichtung in TEdit

    Hallo .........

    Wie stelle ich ein das ein Text bei TEdit Rechtsbuendig usw. ausgegeben wird ?

    Ich finde es einfach nicht :-(

    bye ....

  • #2
    Hallo,

    folgenden habe ich im Intenet zu diesem Thema gefunden. Vielleicht funktioniert es auch mit GetWindowLong und SetWindowLong. Das weiß ich nicht.

    <pre>

    Implementing an edit control which contains right-alligned text requires deriving a new component from TEdit
    and overriding the CreateParams method. With the introduction of Windows98/2000 (NT5), the
    ES_MULTILINE restriction was lifted when adding the ES_RIGHT style. If you are developing for Windows
    95/NT4 platforms, also flag the ES_MULTILINE style, but be aware, you may have to add carriage return
    trapping.

    KEYWORDS: ES_RIGHT, CreateParams

    //-----------------------------------------------------------------------------
    // REditCode.h ===========================================
    //---------------------------------------------------------------------------
    #ifndef REditCodeH
    #define REditCodeH
    //---------------------------------------------------------------------------
    #include <vcl\SysUtils.hpp>
    #include <vcl\Controls.hpp>
    #include <vcl\Classes.hpp>
    #include <vcl\Forms.hpp>
    #include <vcl\StdCtrls.hpp>
    //---------------------------------------------------------------------------
    #if (__BORLANDC__ < 0x0530)
    //---------------------------------------------------------------------------
    // BCB 1.0
    //---------------------------------------------------------------------------
    #define PACKAGE
    #define DYNAMIC

    #endif
    //---------------------------------------------------------------------------

    class PACKAGE TREdit : public TEdit
    {
    private:
    protected:
    public:
    __fastcall TREdit(TComponent* Owner);
    virtual void __fastcall CreateParams(TCreateParams &Params);
    __published:
    };
    //---------------------------------------------------------------------------
    #endif

    //---------------------------------------------------------------------------
    // REditCode.cpp ==========================================
    //---------------------------------------------------------------------------
    #include <vcl\vcl.h>
    #pragma hdrstop

    #include "REditCode.h"
    //---------------------------------------------------------------------------
    #if (__BORLANDC__ < 0x0530)
    //---------------------------------------------------------------------------
    // BCB 1.0
    //---------------------------------------------------------------------------
    static inline TREdit *ValidCtrCheck()
    {
    return new TREdit(NULL);
    }
    //---------------------------------------------------------------------------
    #else
    //---------------------------------------------------------------------------
    // BCB 3.0/4.0
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    //---------------------------------------------------------------------------
    // ValidCtrCheck is used to assure that the components created do not have
    // any pure virtual functions.
    //
    static inline void ValidCtrCheck(TREdit *)
    {
    new TREdit(NULL);
    }
    //---------------------------------------------------------------------------
    #endif
    //---------------------------------------------------------------------------
    __fastcall TREdit::TREdit(TComponent* Owner)
    : TEdit(Owner)
    {
    }

    //---------------------------------------------------------------------------
    void __fastcall TREdit::CreateParams(TCreateParams &Params)
    {
    TEdit::CreateParams(Params);
    Params.Style = Params.Style | ES_RIGHT;// ES_MULTILINE;
    }

    //---------------------------------------------------------------------------
    namespace Reditcode
    {
    void __fastcall PACKAGE Register()
    {
    TComponentClass classes[1] = {__classid(TREdit)};
    RegisterComponents("Samples", classes, 0);
    }
    }

    </pre>

    Ich hoff

    Comment


    • #3
      Hallo,

      folgenden habe ich im Intenet zu diesem Thema gefunden. Vielleicht funktioniert es auch mit GetWindowLong und SetWindowLong. Das weiß ich nicht.


      Implementing an edit control which contains right-alligned text requires deriving a new component from TEdit
      and overriding the CreateParams method. With the introduction of Windows98/2000 (NT5), the
      ES_MULTILINE restriction was lifted when adding the ES_RIGHT style. If you are developing for Windows
      95/NT4 platforms, also flag the ES_MULTILINE style, but be aware, you may have to add carriage return
      trapping.
      KEYWORDS: ES_RIGHT, CreateParams

      <pre>

      //-----------------------------------------------------------------------------
      // REditCode.h ===========================================
      //---------------------------------------------------------------------------
      #ifndef REditCodeH
      #define REditCodeH
      //---------------------------------------------------------------------------
      #include <vcl\SysUtils.hpp>
      #include <vcl\Controls.hpp>
      #include <vcl\Classes.hpp>
      #include <vcl\Forms.hpp>
      #include <vcl\StdCtrls.hpp>
      //---------------------------------------------------------------------------
      #if (__BORLANDC__ < 0x0530)
      //---------------------------------------------------------------------------
      // BCB 1.0
      //---------------------------------------------------------------------------
      #define PACKAGE
      #define DYNAMIC
      #endif
      //---------------------------------------------------------------------------
      class PACKAGE TREdit : public TEdit
      {
      private:
      protected:
      public:
      __fastcall TREdit(TComponent* Owner);
      virtual void __fastcall CreateParams(TCreateParams &Params);
      __published:
      };
      //---------------------------------------------------------------------------
      #endif
      //---------------------------------------------------------------------------
      // REditCode.cpp ==========================================
      //---------------------------------------------------------------------------
      #include <vcl\vcl.h>
      #pragma hdrstop
      #include "REditCode.h"
      //---------------------------------------------------------------------------
      #if (__BORLANDC__ < 0x0530)
      //---------------------------------------------------------------------------
      // BCB 1.0
      //---------------------------------------------------------------------------
      static inline TREdit *ValidCtrCheck()
      {
      return new TREdit(NULL);
      }
      //---------------------------------------------------------------------------
      #else
      //---------------------------------------------------------------------------
      // BCB 3.0/4.0
      //---------------------------------------------------------------------------
      #pragma package(smart_init)
      //-----------------------------------------

      Comment


      • #4
        Hi,

        ich habe im Internte ein Beispiel gefunden, wo die CreatParams Funktion von Edit überschrieben wird. leider will sich das Beispiel nicht ganz hier hinein kopieren lassen. Schicke mir bitte deine email, damit ich dir die datei rüberschicken kann. Es muss jedoch auch eine andere Möglichkeit geben, wenn man zum Beispiel in purer API schreibt. Dort überschreibt man ja nicht CreatParams. Ich schätze das hier die API Funktion SetWindowLong und GetWindowLong benutzt werden.

        <pre>
        __fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
        {

        LONG dwStyle = GetWindowLong(Edit1->Handle, GWL_STYLE);

        SetWindowLong(Edit1->Handle, GWL_STYLE, dwStyle | ES_RIGHT);
        }
        </pre>

        Den Code hab eich nicht getestet und kann keine Garantie geben, das er funktioniert. Probier diesen aber zuerst aus, weil das andere Beispiel etwwas komplizierter ist.

        Ciao Philip

        Comment


        • #5
          Hallo, warum nimmst Du nicht einfach eine TRichEdit-Komponente?
          Gruß Irmgar

          Comment

          Working...
          X