Solved

Dialog edit text control

Posted on 1998-12-27
2
211 Views
Last Modified: 2013-12-26
I created a Dialog window and set the window's text font and text size to geneva 9. I also set the 3 edit text controls in the dialog to the same font and size. When I enter text in one of the edit text controls the text that is already in the control move and makes the new text unreadable. Am I doing somethin wrong?
0
Comment
Question by:dwp090598
2 Comments
 
LVL 3

Accepted Solution

by:
boonstra earned 50 total points
ID: 1291675
No, you're not doing anything wrong; the Dialog Manager is, and you have to work around it.  

The problem you describe is documented in Technote TB24 - Using 'ictb' to Change Edit Fields (25-October-96).  To quote from the Technote:

The Dialog Manager forgets to reset some of the fields of the TextEdit record when
it swaps the font and font size information stored in the 'ictb'. You need to reset the fontAscent and lineHeight fields of the TextEdit Record to match the size of the
font specified in the 'ictb'. By default those fields are set to the lineHeight and fontAssent of 12 point Chicago.

Below is code that shows how to set up the TextEdit record.

//------------------------------------------------------------------
static void SetUpEditField (DialogRef dlog,short fontNum,short fontSize)
//------------------------------------------------------------------
{
  FontInfo  info;
  DialogPeek  dpeek = (DialogPeek)dlog;

  if (dpeek != nil) {
    TEHandle te = dpeek->textH; //get the TEHandle

    if (te != nil) {
      short oldFont = dlog->txFont;   //save old info
      short oldSize = dlog->txSize;

      TextFont(fontNum);    //set the port to correct font info
      TextSize(fontSize);

      GetFontInfo(&info);

      // ok lets fix the TE record since the dialog manager
      // left it at 12 point

      te[0]->txFont   = fontNum;        // set font
      te[0]->txSize     = fontSize;
      te[0]->lineHeight = info.ascent+info.descent+info.leading;
//calculate the correct info
      te[0]->fontAscent = info.ascent ;
      TextFont(oldFont);  //reset the font info
      TextSize(oldSize);
    }
  }
}

And then when you set up your dialog:

  dlog = GetNewDialog(resID,nil,(WindowRef)-1);
  if (dlog) {
    SetPort(dlog);
    SelectDialogItemText(dlog,2,0x8000,0x8000); //set the cursor
    SetUpEditField(dlog,geneva,10);       // set the edit field
    (void)SetDialogDefaultItem(dlog,1);   // hilight the ok button
    ShowWindow(dlog);                     // show the dialog
    // ...
  }
0
 

Author Comment

by:dwp090598
ID: 1291676
This worked great, thanks Again!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

20 Experts available now in Live!

Get 1:1 Help Now