?
Solved

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

Posted on 1999-01-12
2
Medium Priority
?
177 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 280 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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