PocketPC / SmartPhone compatibility - Form Scrolling & Control positioning RRS feed

  • Question

  • I have a form that has number of Link Buttons listed on it.  There is a PictureBox containing an Icon also on the page which would keep on moving based on the currently fucused Link Button's index from top.


    In Pocket PC, when PictureBox's Location is set, it takes the Screen's top-left corner (below the Title bar) always as (0,0).  So, if the form is scrolled, while positioning the PictureBox, we have to add this.AutoScrollPosition.Y (which would have negative value if scrolled) to the calculated Y-axis co-ordinate to position the icon properly.

    PocketPC - Code Snippet

    picArrow.Location = new Point(15,
     lblFirstOption.Top + (mnCurrentIndex * (lblSecondOption.Top -
     lblFirstOption.Top)) + this.AutoScrollPosition.Y);



    In SmartPhone, the Form's top-left corner is considered as (0,0) co-ordinate and in this case, the scrolled portion of the form does not need to be considered.

    SmartPhone - Code Snippet

    picArrow.Location = new Point(15,
     lblFirstOption.Top + (mnCurrentIndex * (lblSecondOption.Top -



    If someone has a better idea to make it generic, comments are welcome.


    13th September, 2008

    Further complications.  Pocket PCs based on Windows Mobile 5 behave as per the above explanation.  The same application when run on Pocket PC based on Windows Mobile 6 Professional edition emulators, it does not require handling for Scrolled portion of the form.  I.e. this.AutoScrollPosition.Y should not be added.


    The application being developed supports resolutions 240x240, 240x320, 320x240, 320x320, 480x480, 480x640 & 640x480, on both Windows Mobile 5 & 6.


    The code base is same for all the PPCs.  Is there a way to make it generic so that a single application would work on all the platforms without any problem (especially the scrolling related problem & control positioning)?


    Another problem is on higher resolutions, (e.g. 480x480, 480x640 & 640x480), if the Width & Height of the components are set directly, the values are set as is.  But if Location or Size is set, the values are automatically doubled.  E.g. if Size is set to (10x10), the control would have the size (20x20).  But, if Width & Height are individually set, the size remains 10x10.  Is there any work around for this?

    Friday, September 12, 2008 1:58 PM


  • For installation of Windows Mobile 6 Professional SDK, I had to install Visual Studio 2005 SP1.  During the installation of this SP1 itself, some libraries must have been updated.


    The old binary that had + this.AutoScrollPosition.Y added to the Y co-ordinate is also working fine.  And the latest build without adding this scroll factor is also working fine.


    The only thing not working is the build that has this factor added to Y co-ordinate, but the project compiled after the SP1 was installed a few days back is incorrectly reducing the Y-value.


    Now, the new build (without this.AutoScrollPosition.Y) is also working on the Windows Mobile 5 - which was earlier not working properly.  So, I just need to remove this (and also find out other bugs that I might have tried to work around that might have been solved by SP1 and now might be giving the reverse effect).

    Monday, September 15, 2008 9:00 AM