1

我是新的移动开发人员,我正在开发 Windows Mobile 6.0 Os 和 CF 2.0 上的概念验证应用程序

我尝试使用 Adob​​e Photoshop 为我的应用程序设计新的背景,我在 codeproject.com 上找到了一个教程,根据 Windows Mobile 文章中 Dr.Luiji 的iPhone UI使用 Pinvoke api 解决 windows mobile 全屏问题和应用程序图像背景问题

当我尝试添加表单背景时,一些渐变图像。 替代文字 http://img268.imageshack.us/img268/8482/ppc2.jpg

图像质量似乎很差。但我试图在我的表单背景中添加另一个背景图像,看起来不错。

替代文字 http://img199.imageshack.us/img199/9812/ppc3.jpg

我不明白问题出在哪里,我试图将我的背景图像更改为 bmp、png、jpg 等。它仍然很差。我在用 Photoshop 做错了什么?
(注意:另一方面,我还没有在真正的袖珍电脑上尝试过这种设计。不是吗?)

但是,我的另一个真正问题是移动表单上的 OnPaintBackground 方法。正如我在上面所写的,我使用 Pinvoke api 来绘制全屏表单。这是示例代码:

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);

        }

    }
}

我正在尝试在表单上添加一些控件,然后在应用程序第一次运行时控件显示为透明。如果您尝试将光标移动到这些控件上,这些控件将正常转向。

我能做些什么来解决这个问题?

谢谢你。

替代文字 http://img508.imageshack.us/img508/6717/ppc1.jpg

4

1 回答 1

0

首先,您的代码需要一些清理:

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 的经典博客讨论了 CF 中的位图。你需要小心:

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

毕竟,我不确定你的问题是什么。你可以再详细一点吗?例如,我没有看到任何 P/Invokes,但你说你使用了一些。他们在哪?

于 2009-08-27T20:04:22.287 回答