locked
Problem drawing text upside down in WM 6.5 (Working in WM 6 and 6) RRS feed

  • Question

  • Hi

    Im having a problwm when i draw som text upside down. It works fine on the WM 5 and 6 emulators but in the WM 6.5 emulator the text gets sort of cut off for some reason.. Picture to ullustrate:
     
    Heres the code wich i used in the pictures above, wich by the way is from this site
    http://msdn.microsoft.com/en-us/library/ms404359.aspx. Oh, another thing, when i switch from portrait to landscape the text eppears as it should, but when  i refresh the form again i get the same problem..

    namespace

     

    SmartDeviceProject1
    {
    public partial class Form1 : Form
    {
    Font rotatedFont;
    SolidBrush redBrush;
    private string rTxt = "abc ABC 123";
    private int rAng = 180;
    private const int curDPI = 96;
    private string rFnt = "Arial";
    public Form1()
    {
    this.MinimizeBox = false;
    this.Text = "Rotated Font";
    this.rotatedFont = CreateRotatedFont(rFnt, rAng);
    this.redBrush = new SolidBrush(Color.Red);
    }
    Font CreateRotatedFont(string fontname, int angleInDegrees)
    {
    LogFont logf = new Microsoft.WindowsCE.Forms.LogFont();
    Graphics g = this.CreateGraphics();
    logf.Height = (int)(-18f * g.DpiY / curDPI);
    logf.Escapement = angleInDegrees * 10;
    logf.Orientation = logf.Escapement;
    logf.FaceName = fontname;
    logf.CharSet = LogFontCharSet.Default;
    logf.OutPrecision =
    LogFontPrecision.Default;
    logf.ClipPrecision =
    LogFontClipPrecision.Default;
    logf.Quality =
    LogFontQuality.ClearType;
    logf.PitchAndFamily =
    LogFontPitchAndFamily.Default;
    g.Dispose();
    return Font.FromLogFont(logf);
    }
    protected override void OnPaint(PaintEventArgs e)
    {
    if (this.rotatedFont == null)
    return;
    e.Graphics.DrawString(rTxt, this.rotatedFont, this.redBrush, 75,125,
    new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.NoClip));
    }
    }
    }

    • Edited by dziation Saturday, August 8, 2009 5:36 PM
    Saturday, August 8, 2009 4:58 PM

Answers

All replies

  • Hi

    you have to debug you code and test i hope you in you code some where height and width problem that's why you are facing this problem.



    Pavan Pareta | If you find my post is helpful for you then mark as a answer.
    Saturday, August 8, 2009 5:45 PM
  • Done that :) All values seem to bee in order, and giving that im using exactly the same code as in the msdn example http://msdn.microsoft.com/en-us/library/ms404359.aspx i pretty lost here. Does WM 6.5 handle the paint event differently than WM5 an 6? Or could this simply be a bug with my emulator? As said before... It works fine on WM 5 and 6.
    Saturday, August 8, 2009 8:35 PM
  • Hi dziation,

    From your screen shots, I think you are using emulator of resolution 240 X 400 for Windows Mobile 6.5(WQVGA).
    You can check your application on Windows Mobile 6.5 QVGA emulator. I will work fine.
    To run your application on both emulators, you have to handle resolutions.
    Please check it and let me know it works or not.

    Best Regards,
    Pariksheet.
    Monday, August 10, 2009 11:58 AM
  • I have tested the app on all WM 6.5 emulators wich come with the Windows Mobile 6.5 Developer Toolkit, QVGA, WQVGA, QVGA etc. and i get the same problem on all the emulators. Weird... Could someone test the code on their WM 6.5 emulators to check if they get the same problem?! A bit much to ask, iknow.. But it would make me very happy! :) 

    Monday, August 10, 2009 2:22 PM
  • Hi dziation,

    I have check your code in my MFC application.
    It also shows me improper text.
    I observed that, when we rotate text, it does not change the starting point of it while drawing.
    Then I changed the angle little bit, then it shows me better text.
    OR you can increase your text control's height and width.

    I am not sure that it will work.
    You can try it.

    Best Regards,
    Pariksheet.
    Wednesday, August 12, 2009 11:11 AM
  • I dont know about you guys but i think that msdn needs to change their sample code because it clearly does NOT work on WM 6.5. To illustrate my point: Try running the "RotatetText" solution wich can be found in the Microsoft press example code wich come with the "Microsoft Development Handbook" (Capter12/CS/RotatedText). You can downlad it here: http://www.microsoft.com/mspress/companion/9780735623583/

    However i found an approach that works on WM 6.5  http://blog.markarteaga.com/DrawingRotatedTextInNETCompactFramework20.aspx
    • Marked as answer by dziation Friday, August 14, 2009 9:14 AM
    Friday, August 14, 2009 9:14 AM
  • Thanks Dziation for the link. It works.

    I happen to write my code in native code C/C++ and still have problems with rotated text in WM 6.5. Do you have any idea on how to translate this approach into C/C++? Thanks.
    Sunday, November 1, 2009 3:28 PM