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
Solved

Dialog edit text control

Posted on 1998-12-27
2
232 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 105
WinWaitActive parameters 12 31
dog bark java program 15 109
move a line in eclipse 3 107
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

860 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