Converting twips to client coordinates

Posted on 2005-04-15
Last Modified: 2013-11-20
I'm using a rich edit control which supports tables. I need to convert twips (which indicate the column width) into client coordinates. Any help?
Question by:ashugarg00
    LVL 1

    Expert Comment


    A twip is a 20th of a typographical point, which is 1/72 th of an inch.
    The resolustion of an inch on screen can be found with GetDeviceCaps,
    So, a twip (height) is LOGPIXELSY/72/20.

    This function could help you

    #define TWIPS_PER_INCH 1440

    int TwipsToPixels(CDC* pDC, int iNbTwips, BOOL bY)
      int iNbPixels = 0;

      if (pDC != NULL)
        int iDeviceCaps;

        if (bY == TRUE)
          iDeviceCaps = pDC->GetDeviceCaps(LOGPIXELSY)­;
          iDeviceCaps = pDC->GetDeviceCaps(LOGPIXELSX)­;

        iNbPixels = MulDiv(iNbTwips, iDeviceCaps, TWIPS_PER_INCH);

      return iNbPixels;
    LVL 1

    Accepted Solution



    The above function will return in screen coordinates. You will need to change it to client coordinates using the ScreenToClient API


    Author Comment

    Thanks a lot,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    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 …
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    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.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 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

    11 Experts available now in Live!

    Get 1:1 Help Now