Space between letters

In edit box char is #.
How can I add more empty space
between characters that appear
like : # # # # instead of ####?
BosanacAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BlackDeathCommented:
while typing?
0
haehnenCommented:
for count := 0 to length(str) do begin
count := count + 1; //+2
insert(' ', str, count);
end;

maybe some problems .. not testet .. :-))

bye
0
BosanacAuthor Commented:
while typing?
>>No,on LoadFromFile...
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

raidosCommented:
Drop it into a temp string instead of editbox..then

For loop := 1 to Length(tempStr) do
  Editbox.text := TempStr[Loop]+' ';

That should do it

I think..
0
raidosCommented:
Sorry Didn't think...
0
CalvinDayCommented:
You use a fixed pitch font or yoou can derive your own component that overrides the default painting. In the case, you can use the windows api function ExtTextOut like in the following component. It gets a little hairy if you want to do this while typing in it.

unit spaceedit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,mask,dbctrls;

type
  TSpaceEdit = class(TCustomEdit)
  private
    FCanvas: TControlCanvas;
    FSpacing: integer;
    procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
  protected
    procedure Change; override;
  published
    property Text;
    property OnChange;
    property Spacing:integer read FSpacing write FSpacing;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TSpaceEdit]);
end;

procedure TSpaceEdit.Change;
begin
  inherited Changed;
  Repaint;
end;

procedure TSpaceEdit.WMPaint(var Message: TWMPaint);
var
  Left,i: Integer;
  R: TRect;
  DC: HDC;
  PS: TPaintStruct;
  S: string;
  ExStyle: DWORD;
  d: array [0..255] of integer;
begin
  if FSpacing=0 then
    FSpacing:=1;
  for i:=0 to 255 do
    d[i]:=FSpacing;
  if FCanvas = nil then
  begin
    FCanvas := TControlCanvas.Create;
    FCanvas.Control := Self;
  end;
  DC := Message.DC;
  if DC = 0 then DC := BeginPaint(Handle, PS);
  FCanvas.Handle := DC;
  try
    FCanvas.Font := Font;
    with FCanvas do
    begin
      R := ClientRect;
      if not (NewStyleControls and Ctl3D) and (BorderStyle = bsSingle) then
      begin
        Brush.Color := clWindowFrame;
        FrameRect(R);
        InflateRect(R, -1, -1);
      end;
      Brush.Color := Color;
      if not Enabled then
        Font.Color := clGrayText;
      S := Text;
      if PasswordChar <> #0 then FillChar(S[1], Length(S), PasswordChar);
      Left :=1;
      ExtTextOut(FCanvas.Handle,Left,0,ETO_CLIPPED,@R,Pointer(S),length(s),@d);
    end;
  finally
    FCanvas.Handle := 0;
    if Message.DC = 0 then EndPaint(Handle, PS);
  end;
end;
end.
0
srbenavrbeCommented:
Wow!
0
CalvinDayCommented:
>Wow!

I stole most of this from TDBEDIT and changed TextRect(R, Left, Margins.Y, S); to ExtTextOut(FCanvas.Handle, Left, 0, ETO_CLIPPED, @R, Pointer(S), length(s), @d).

I was really surprised it worked the first time. It only took about 10 minutes. I thought, what the heck, might as well post it.

What's really funny is the letters will actually overwrite each other with small spacing values.


   
0
BosanacAuthor Commented:
Points to Calvin!
0
CalvinDayCommented:
Thanks.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.