locked
How to convert DialogUnit to Pixel Value (in C#) RRS feed

  • Question

  • Hello,

    I am trying to convert a DialogUnit value to a Pixel value. In particular, I have a Rectangle(left, top, width, height) where all these four values needs to be converted into its equivalent pixel values. Could you please suggest how can I do that?

    Thanks.

    Thursday, November 18, 2010 4:55 PM

Answers

  • Welcome to the MSDN Forums.

    "DLU's depend on the font used on the form. Quote from MSDN docs:

    " A DLU is based on the size of the dialog box font, normally 8-point MS Sans Serif. A horizontal DLU is the average width of the dialog box font divided by four. A vertical DLU is the average height of the font divided by eight."

    WIth this MS Sans Serif font you'll get about 12 pixels for a DLU both horizontally and vertically.

    If you are using VS 2005 in most cases just snaping the control to the guidelines generated by the designer when you move the control is enough to achive a correct interface."

    Reference: http://social.msdn.microsoft.com/forums/en-US/winformsdesigner/thread/e9c928df-9750-4b86-8c76-cc46ff146bc8/

    Regards,

    Yasser


    DO YOU STORE AND VERIFY PASSWORDS USING KEYS?! LEARN A BETTER WAY DURING A QUICK SIMPLE HOW TO:
    How To: Storing and verifying passwords
    • Proposed as answer by Mike Dos Zhang Monday, November 22, 2010 2:21 PM
    • Marked as answer by Mike Dos Zhang Thursday, November 25, 2010 3:32 PM
    Thursday, November 18, 2010 6:12 PM