Solved

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

Posted on 1999-01-12
2
176 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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