Solved

Dialog edit text control

Posted on 1998-12-27
2
220 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

16 Experts available now in Live!

Get 1:1 Help Now