C♯相談室 Part2
■ このスレッドは過去ログ倉庫に格納されています
019544
NGNGその後、以下のコードを組んで非矩形ウィンドウを実現したが、
ウィンドウバーの高さを知ることが出来てないため少々不恰好になって候。
当方調査中ですが、直ぐにお分かりになる方あれば、是非ご教示くだされば幸い也。
using System;
using System.Drawing;
using System.Windows.Forms;
class ImageForm : Form {
Bitmap bitmap = null;
Graphics graph = null;
Region region = null;
// Window Title Height 暫定値。
int wth = 50;
// メインフォームだよ
public ImageForm (){
bitmap = new Bitmap("test.bmp");
// ビットマップ読み込み失敗したら、速攻終了だ
if (bitmap == null) {
Application.Exit();
}
// 最左上端を透過色にする
bitmap.MakeTransparent();
region = new Region(new Rectangle(0, 0 + wth, 1, 1));
// 透過色部分をウィンドウリージョンに加える
for(int i=0; i<bitmap.Height; i++){
for(int j=0; j<bitmap.Width; j++){
if(bitmap.GetPixel(j, i).A != 0){
region.Union(new Rectangle(j, i + wth, 1, 1));
}
}
}
this.Height = bitmap.Height + wth;
this.Width = bitmap.Width;
this.Region = region;
this.FormBorderStyle = FormBorderStyle.None;
}
protected override void OnPaint(PaintEventArgs pea) {
graph = pea.Graphics;
graph.Clear(Color.Gray);
}
public static void Main(){
Application.Run(new ImageForm());
}
}
■ このスレッドは過去ログ倉庫に格納されています