Solved

Dialog edit text control

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 78
either24  challenge 19 97
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 94
Is there a simple front-end menu system. 9 89
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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