#9
by Math » 5年前
Windows10,VisualStudio2017Communityでは普通に透過されてるようですが。(開発者ようコマンドプロンプト)
c.bat
コード:
csc.exe /r:DxLibDotNet.dll c1.cs
c1.exe
pause
c1.cs
コード:
//program.cs
//Form.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DxLibDLL;//DxLibを使用
namespace DesctopMascot
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form = new Form1();
form.Show();
//Application.Run(new Form1());
while (form.Created)
{
form.MainLoop();
Application.DoEvents();
}
}
}
public partial class Form1 : Form
{
private int modelHandle;
public Form1()
{
InitializeComponent();
//ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);//画面サイズの設定
ClientSize = new Size(800, 600);//画面サイズの設定
//DX.ChangeWindowMode(DX.TRUE);
//DX.SetOutApplicationLogValidFlag(DX.FALSE);//Log.txtを生成しないように設定
DX.SetUserWindow(Handle);//DxLibの親ウインドウをこのフォームに設定
DX.DxLib_Init();//DxLibの初期化処理
DX.SetDrawScreen(DX.DX_SCREEN_BACK);//描画先を裏画面に設定
modelHandle = DX.MV1LoadModel("Lat式ミクVer2.3_Normal.pmd");//3Dモデルの読み込み
DX.SetCameraNearFar(0.1f, 1000.0f);//奥行0.1~1000をカメラの描画範囲とする
DX.SetCameraPositionAndTarget_UpVecY(DX.VGet(0.0f, 10.0f, -30.0f), DX.VGet(0.0f, 10.0f, 0.0f));//第1引数の位置から第2引数の位置を見る角度にカメラを設置
}
public void MainLoop()
{
DX.ClearDrawScreen();//裏画面を消す
DX.DrawBox(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, DX.GetColor(255, 0, 0), DX.TRUE);//背景を設定(透過させる)
DX.MV1DrawModel(modelHandle);//3Dモデルの描画
//ESCキーを押したら終了
if (DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) != 0)
{
Close();
}
DX.ScreenFlip();//裏画面を表画面にコピー
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
DX.DxLib_End();//DxLibの終了処理
}
private void Form1_Shown(object sender, EventArgs e)
{
//FormBorderStyle = FormBorderStyle.None;//フォームの枠を非表示にする
TransparencyKey = Color.Red;//透過色を設定
}
}
partial class Form1
{
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
/// <param name="disposing">マネージ リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows フォーム デザイナーで生成されたコード
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 600);
this.Name = "Form1";
this.Text = "Form1";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
this.Shown += new System.EventHandler(this.Form1_Shown);
this.ResumeLayout(false);
}
#endregion
}
}
わかり易いよう800x600画面ウィンドウ,枠を表示させてます
http://www2.koyoen.birdview.co.jp/~abcxyz/x0527.png
Windows10,VisualStudio2017Communityでは普通に透過されてるようですが。(開発者ようコマンドプロンプト)
c.bat
[code]
csc.exe /r:DxLibDotNet.dll c1.cs
c1.exe
pause[/code]
c1.cs
[code]
//program.cs
//Form.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DxLibDLL;//DxLibを使用
namespace DesctopMascot
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form = new Form1();
form.Show();
//Application.Run(new Form1());
while (form.Created)
{
form.MainLoop();
Application.DoEvents();
}
}
}
public partial class Form1 : Form
{
private int modelHandle;
public Form1()
{
InitializeComponent();
//ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);//画面サイズの設定
ClientSize = new Size(800, 600);//画面サイズの設定
//DX.ChangeWindowMode(DX.TRUE);
//DX.SetOutApplicationLogValidFlag(DX.FALSE);//Log.txtを生成しないように設定
DX.SetUserWindow(Handle);//DxLibの親ウインドウをこのフォームに設定
DX.DxLib_Init();//DxLibの初期化処理
DX.SetDrawScreen(DX.DX_SCREEN_BACK);//描画先を裏画面に設定
modelHandle = DX.MV1LoadModel("Lat式ミクVer2.3_Normal.pmd");//3Dモデルの読み込み
DX.SetCameraNearFar(0.1f, 1000.0f);//奥行0.1~1000をカメラの描画範囲とする
DX.SetCameraPositionAndTarget_UpVecY(DX.VGet(0.0f, 10.0f, -30.0f), DX.VGet(0.0f, 10.0f, 0.0f));//第1引数の位置から第2引数の位置を見る角度にカメラを設置
}
public void MainLoop()
{
DX.ClearDrawScreen();//裏画面を消す
DX.DrawBox(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, DX.GetColor(255, 0, 0), DX.TRUE);//背景を設定(透過させる)
DX.MV1DrawModel(modelHandle);//3Dモデルの描画
//ESCキーを押したら終了
if (DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) != 0)
{
Close();
}
DX.ScreenFlip();//裏画面を表画面にコピー
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
DX.DxLib_End();//DxLibの終了処理
}
private void Form1_Shown(object sender, EventArgs e)
{
//FormBorderStyle = FormBorderStyle.None;//フォームの枠を非表示にする
TransparencyKey = Color.Red;//透過色を設定
}
}
partial class Form1
{
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
/// <param name="disposing">マネージ リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows フォーム デザイナーで生成されたコード
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 600);
this.Name = "Form1";
this.Text = "Form1";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
this.Shown += new System.EventHandler(this.Form1_Shown);
this.ResumeLayout(false);
}
#endregion
}
}
[/code]
わかり易いよう800x600画面ウィンドウ,枠を表示させてます
[url]http://www2.koyoen.birdview.co.jp/~abcxyz/x0527.png[/url]