Solved

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

Posted on 1999-01-12
2
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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