Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dialog edit text control

Posted on 1998-12-27
2
Medium Priority
?
258 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
[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 3

Accepted Solution

by:
boonstra earned 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 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