iT邦幫忙

DAY 38
3

Windows Mobile系列 第 38

[Windows Mobile]使用 AlphaMobileControls 實現透明控制項

在上一篇文章中,提到如何使用 AlphaMobileControls,接著透過 AlphaMobileControls 實現透明控制項
更多文章,請到我在點部落所建立的部落格「.NET菜鳥自救會」閱讀
http://www.dotblogs.com.tw/chou/

  1. 簡介
    在上一篇文章中,提到如何使用 AlphaMobileControls,接著透過 AlphaMobileControls 實現透明控制項

  2. 方法
    2.1 加入圖檔
    將背景透明的圖檔加入專案內,並且在屬性裡,設定為嵌入資源

2.2 程式撰寫
表單配置如下圖所示,由上往下為 三個為 AlphaImageButton,三個 PictureBox,一個 AlphaImageButton,一個 AlphaLabel

以下程式碼功能為 三個為 AlphaImageButton,三個 PictureBox 顯示相同的圖檔,而最底下的 AlphaImageButton 點選後,AlphaLabel 顯示 Button Clicked!

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using AlphaMobileControls;

namespace SmartDeviceProject1
{
    public partial class Form1 : AlphaForm  // 將 Form1 繼承 AlphaForm
    {
        public Form1()
        {
            InitializeComponent();
            // 表單中最上面三個 alphaImageButton 載入圖檔
            alphaImageButton2.BackgroundImage = AlphaImage.CreateFromResource("SmartDeviceProject1.Resources.1.png");
            alphaImageButton3.BackgroundImage = AlphaImage.CreateFromResource("SmartDeviceProject1.Resources.2.png");
            alphaImageButton4.BackgroundImage = AlphaImage.CreateFromResource("SmartDeviceProject1.Resources.3.png");

            alphaLabel1.Text = "Alpha Mobile Controls";
            // 表單最底下 alphaImageButton 載入圖檔
            alphaImageButton1.BackgroundImage = AlphaImage.CreateFromResource("SmartDeviceProject1.Resources.Btn1.png");
            alphaImageButton1.ActiveBackgroundImage = AlphaImage.CreateFromResource("SmartDeviceProject1.Resources.Btn1_Pushed.png");
            alphaImageButton1.DisabledBackgroundImage = AlphaImage.CreateFromResource("SmartDeviceProject1.Resources.Btn1_Disabled.png");
        }

        // 當 alphaImageButton1 Click 時
        private void alphaImageButton1_Click(object sender, EventArgs e)
        {
            alphaLabel1.Text = "Button Clicked!";  // alphaLabel1 顯示 Button Clicked!
        }
    }
}
  1. 執行結果
    最上面三個 AlphaImageButton,圖檔透明的部份顯示透明,但三個 PictureBox 則顯示白色。下方AlphaImageButton 點選後,AlphaLabel 顯示 Button Clicked!


上一篇
[Windows Mobile]使用 AlphaMobileControls 的前置作業
下一篇
[Windows Mobile]Windows Mobile Widget Emulator
系列文
Windows Mobile41
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言