Solved

HELP!!! Problems with Edit Control!! urgent!!

Posted on 1999-01-12
2
168 Views
Last Modified: 2010-04-06
Hi all!!!

I have the following problem.... my main form has a lot of Edit controls... some of them are 22 units width (which accept 2 characters), and others 14 units (which accept 1 character). The font used is Courier New, 8 pts. The problem I have only with the Edit controls 14 units width. In my PC the text I want to display is shown correctly but only in the 1024x768x32 resolution (in other resolutions the controls appear in blank). When I ran the program in other PC, it was impossible for me to make the control show the text properly (the controls appear in blank again). I realized that the text is there, but too left justified, so the control doesn't show it. To make it work, I have to change either the width (to 21 units at least) or the font (small font, 7 pts, only).

What the hell can I do!!!!!! I HAVE to use Courier New font and that width. Is it a control problem? windows problem? If I would install a new edit control, would I solve the problem? where can I download a new one?

THANKS a lot in advance
Jaime
0
Comment
Question by:skel
2 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 70 total points
ID: 1356118
The problem lies in that the font size is fixed number of points (where one point = 1/72 inches) and the number of screen pixels taken by a character of a fixed point size depends on the physical dots per inch of the particular screen resolution.

Effectively your only solution is to modify the point size, or to force the form to scale with changes in resolution.

Here is a component that will do this (written by Viktornet I believe...):

unit Scaler;

         interface

         uses
           Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms,
         Dialogs;
         const
            ScreenWidth  : Integer = 800; //If you don't want to declare

    constants
                                         //you'd have to have a
            ScreenHeight : Integer = 600;//property for each of these
two so
    you can
        // declare it at //designtime
         type
           TScaler = class(TComponent)
           private
             FAllScaled : Boolean;
           protected
             { Protected declarations }
           public
             constructor Create(AOwner : TComponent);override;
             procedure Loaded;override;
           published
             { Published declarations }
           end;
         procedure Register;
         implementation
    constructor TScaler.Create(AOwner : TComponent);
    begin
      Inherited Create(AOwner);
      fAllScaled := False;
    end;
    procedure TScaler.Loaded;
    begin
      Inherited;
      if not(csDesigning in ComponentState) then
        if Owner is TForm then
        with TForm(Owner) do begin
          Font.Pitch := fpVariable;
          if (not
fAllScaled)and((Screen.Width<>ScreenWidth)or(Screen.Height<>ScreenHeight))then

           begin
             Scaled := True;
             AutoScroll := False;
              if Screen.Width < ScreenWidth then
             ScaleBy(Screen.Width, ScreenWidth)
             else ScaleBy(ScreenWidth, Screen.Width);
             fAllScaled := True;
           end;
         end;
    end;
    procedure Register;
    begin
      RegisterComponents('System', [TScaler]);
    end;
    end.


0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1356119
Instead of hard wiring 14, why not (in FormCreate) set the width property of the edit control to [YourForm.]Canvas.TextWidth('A');

You might like to add another 3 or 4 pixels to account for the edit's border maybe.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now