Question

I'm new mobile development and i'm working on an proof of concept application on Windows Mobile 6.0 Os and CF 2.0

I tried to design new backgorund for my application with the Adobe Photoshop, i found a tutorial on the codeproject.com about solving the windows mobile fullscreen problem and app image background issue with Pinvoke api according to Dr.Luiji's iPhone UI in Windows Mobile article

When i tried to add form background some gradient image. alt text http://img268.imageshack.us/img268/8482/ppc2.jpg

Image quality seems poor. But i tried to add another background image to my form background, it seems good.

alt text http://img199.imageshack.us/img199/9812/ppc3.jpg

I don't understand where is the problem, i tried to change my backgorund image to bmp, png, jpg etc. it still poor. What am i doing mistake with photoshop ?
(Note : on the other hand, i haven't tried this design on real pocketpc yet. is it not ?)

However, My another real problem is OnPaintBackground method on the mobile forms. as i wrote above i have used Pinvoke api for drawing fullscreen forms. Here is the sample code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Microsoft.WindowsMobile.Status;

namespace My_Mobile
{
    public partial class MainForm : Form
    {

        Globals _globals = new Globals();
        Graphics _gxBuffer;
        Bitmap _offsetBitmap;  

        Bitmap backgroundVertical = null;
        public MainForm()
        {
            InitializeComponent();
            backgroundVertical = new Bitmap(_globals.ApplicationPath + @"\Resources\wallpaper.bmp");
            _offsetBitmap = new Bitmap(this.Width, this.Height);

        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }


        protected override void OnPaintBackground(PaintEventArgs e)
        {
            //base.OnPaintBackground(e);
        }


        protected override void OnPaint(PaintEventArgs e)
        {
                _gxBuffer = Graphics.FromImage(_offsetBitmap);

                _gxBuffer.Clear(this.BackColor);

                _gxBuffer.DrawImage(backgroundVertical, 0, 0);
                this.Invalidate();

                e.Graphics.DrawImage(_offsetBitmap, 0, 0);

        }

    }
}

I'm trying to add some controls on the form then controls are shown transparent when the application run the first time. If you try to move cursor over the these controls, these are turn to normally.

What can i do for solve this problem ?

Thank you.

alt text http://img508.imageshack.us/img508/6717/ppc1.jpg

Was it helpful?

Solution

First of all, your code needs some clean up:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Microsoft.WindowsMobile.Status;

namespace My_Mobile
{
    public partial class MainForm : Form
    {

        Globals _globals = new Globals();

        Bitmap backgroundVertical = null;
        public MainForm()
        {
            InitializeComponent();
            backgroundVertical = new Bitmap(_globals.ApplicationPath + @"\Resources\wallpaper.bmp");
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
        }


        protected override void OnPaintBackground(PaintEventArgs e)
        {
            //base.OnPaintBackground(e);
        }


        protected override void OnPaint(PaintEventArgs e)
        {
             using (Bitmap buffer = new Bitmap(this.Width, this.Height))
             using (Graphics gfx = Graphics.FromImage(buffer))
             {
                gfx.Clear(this.BackColor);
                gfx.DrawImage(backgroundVertical, 0, 0);
                //this.Invalidate();  Don't call Invalidate here, it shouldn't be needed
                e.Graphics.DrawImage(buffer, 0, 0);
             }
        }
    }
}

Chris Tacke's classic blog talks about Bitmaps in the CF. You need to be careful:

http://blog.opennetcf.com/ctacke/PermaLink,guid,987041fc-2e13-4bab-930a-f79021225b74.aspx

After all that, I'm not really sure what your question is. Could you be more specific? Like for example, I don't see any P/Invokes, but you said you used some. Where are they?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top